SelectionObserver and get attributes....
-
Hello,
I see the classe http://code.google.com/intl/fr-FR/apis/sketchup/docs/ourdoc/selectionobserver.html, i use this to run a ruby script when i click on a component in skecthup.
for example:
My component "Component#1" has in "Component Attribute" an identity, adress, and others descriptions... i want when i click on this component, run my ruby script (I already did that), but i don't know to retrieve "Component Attribute". I wish put for example the attribute "identity" of "Componente#1" in a variable in ruby.
require 'sketchup.rb' class MySelectionObserver < Sketchup;;SelectionObserver def onSelectionBulkChange(selection) wd=UI;;WebDialog.new( "Somfy Controller", true, "",950, 700, 100, 100, false ) wd.show #################### #I WANT TO PUT IDENTITY ATTRIBUE OF MY COMPONENT#1 IN THIS VARIABLE identity= '000003' wd.set_url("http://localhost/final_programme/index.php?identity="+identity+"") #################### end end # Attach the observer. Sketchup.active_model.selection.add_observer(MySelectionObserver.new) # end of sample.rbthx to help me
Pauline
-
How to set attributes?
entity.get_attributehttp://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/entity.html#get_attribute
entity.set_attributehttp://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/entity.html#set_attribute -
Hi Pauline, the attributes for a Dynamic Component are in the the "dynamic_attributes" attribute_dictionary.
# Check "dynamic_attributes" dictionary for a Dynamic Component identity = selected[0].get_attribute("dynamic_attributes", "identity") # the Definition may have the attribute, so... if identity.nil? identity = selected.definition.get_attribute("dynamic_attributes", "identity") end if identity.nil? # there is not attribute named "identity" else # Yes, we found "identity" end
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