[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 moduleEDIT:
- 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 "
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement