How to create the pulldown menu for DC
-
Hi !
I learn to write scripts for Sketchup, Π²ut has rested against a wall...
I can set attributes of components this code:entity.set_attribute 'dynamic_attributes','price', '0' entity.set_attribute 'dynamic_attributes','_price_label', 'price' entity.set_attribute 'dynamic_attributes','_price_formlabel', 'Price' entity.set_attribute 'dynamic_attributes','_price_units', 'STRING' entity.set_attribute 'dynamic_attributes','_price_access', 'TEXTBOX'It works!
But I could never understand how to write code using meta attributes to create the pulldown menu for DC ...
Show me a code fragment which it does.
Thanks ! -
You know where the DC Attributes are stored, so now you can inspect the "dynamic_attributes" Dictionary to see how to recreate any DC you find.
Here is a basic example of a dropdown list with 3 options:

-
@jim said:
You know where the DC Attributes are stored, so now you can inspect the "dynamic_attributes" Dictionary to see how to recreate any DC you find.
Here is a basic example of a dropdown list with 3 options:
Code:
sang = Sketchup.active_model.entities[0] sang_def = sang.definition sang_def.set_attribute 'dynamic_attributes','test', 'yes' sang_def.set_attribute 'dynamic_attributes','_test_access', 'LIST' sang_def.set_attribute 'dynamic_attributes','_test_formlabel', 'My test' sang_def.set_attribute 'dynamic_attributes','_test_label', 'my_test' sang_def.set_attribute 'dynamic_attributes','_test_options ','&yes=yes&no=no' sang_def.set_attribute 'dynamic_attributes','_test_units', 'STRING'Result on the image
What do I do not so?

-
I have found a problem!
It was necessary to use a symbol " instead of ' . -
You have an extra space in this line:
ang_def.set_attribute 'dynamic_attributes','_test_options[highlight=#ff0000:2ph6o4z3]_[/highlight:2ph6o4z3]','&yes=yes&no=no' -
@jim said:
You have an extra space in this line:
ang_def.set_attribute 'dynamic_attributes','_test_options[highlight=#ff0000:169f3gnp]_[/highlight:169f3gnp]','&yes=yes&no=no'Yes, thanks!
All has earned.
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