Reliable retrieval of dynamic component attributes
-
Hi there,
Newbie here, trying to figure out dynamic component attributes. I'm trying to write a script that returns the name and the lenx, leny, lenz attributes of all the dynamic component instances in a model. I've got a script that works (ie it runs without error), but it doesn't return any values. It returns either empty strings or 'nil'. I've discovered that if I update the attributes of a particular instance with the 'Component Attributes' dialog, it will then return the values I have input, but only those values. Furthermore, those values don't change if I subsequently rescale the component with the scale tool.
Also, I've noticed that if I use the set_attribute method to update an attribute, the component in question will not change in the model, but I will be able to retrieve the updated value using get_attribute.
I've seen talk on these forums of 'redrawing' components, but there is no redraw method listed in the API. Have I missed something? Is there some way to update/refresh attributes as well as the model view? Any help would be greatly appreciated.
-
There are some special commands for redrawing DCs that are not in the main API docs, but the DC docs and other sources...
This has a ...
dcs = $dc_observers.get_latest_class dcs.redraw_with_undo(sang)
example
http://stackoverflow.com/questions/8507476/sketchup-dynamic-component-options-manipulating-from-ruby
Or here https://groups.google.com/forum/?fromgroups=#!topic/sketchupruby/630uerkDhJI
There are also several posts at SCF, like this one http://sketchucation.com/forums/viewtopic.php?f=180&t=41567
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