[Code] GE "GeoLocation" AttributeDictionary v1.1.0
-
[ Code ] GoogleEarth "GeoLocation" AttributeDictionary
module Author # georeference_dictionary() # georeference_dictionary( [output=false [, popup=false]] ) # georeference_dictionary( ;output => true ) # georeference_dictionary( ;popup => true ) # # Returns the dictionary object if defined, or nil if not. # # Args; (all defaults are false.) # # [output] (boolean) If true, outputs to STDOUT. # [popup] (boolean) If true, shows info in messagebox. # def self.georeference_dictionary( *args ) #-- # Method Version; 1.1.0 #++ geodict = Sketchup.active_model.attribute_dictionary("GeoReference") return geodict if args.empty? if args[0].is_a?(Hash) args[0].keys.each{|k| args[0][k.to_sym]= args[0][k] if k.is_a?(String) } output =( args[0][;output] ? true ; false ) popup =( args[0][;popup] ? true ; false ) else output =( args[0] ? true ; false ) popup =( args.length>1 ? ( args[1] ? true ; false ) ; false ) end return geodict unless output || popup # unless geodict msg = %[Dictionary; "GeoReference" not defined. \n] puts( "\n"<<msg ) if output UI.messagebox(msg,MB_OK) if popup else msg = %[Dictionary; "GeoReference" (keys; #{geodict.length})] if geodict.length==0 msg<< " \n" else msg<< "\n" keywid = geodict.keys.max{|a,b| a.length <=> b.length }.length geodict.each {|k,v| msg<< %[ "#{k}"].ljust(keywid+7,'.')<<%[; "#{v}"\n] } msg<<"\n" end puts( "\n"<<msg ) if output if popup if geodict.length==0 UI.messagebox(msg,MB_OK|64) else UI.messagebox(msg,MB_MULTILINE,%q[ AttributeDictionary; "GeoReference"]) end end end # return geodict # end # def end # your module
EDIT:
- shortened method name to "
georeference_dictionary
"
You can always alias it or change the name in your module:
-
added two optional arguments to control output.
EDIT: v1.1.0 -
can now take Hash arguments* refined formatting of output
Screen shots:
- shortened method name to "
Advertisement