I need to get dynamic component definition, not instance name. I can’t find info about it. Maybe somebody can help me.
Taking you literally, the associated ComponentDefinition name is obtained by
instance.definition.name
But that is well-documented, so I wonder if that is really what you meant? Are you seeking to get at the attributes, options, etc. of the DC rather than simply the ComponentDefinition?
Thank you so, so much for the reply. Yes, i tried this before. And result was nothing. Maybe it was some others bugs, or my beginners fail, because, it is perfect result now.
But I can’t get description with that.
instance.definition.description
In documentation :
Get the description
componentdefinition = Sketchup.active_model.definitions[0]
description = componentdefinition.description
Maybe, i m using that stupidly?
In result, i need string.
If the definition has a description you code will return it - otherwise it’s empty ""
To see it use:
p description
or to see its ‘class’ use:
p description.class
However, if you are actually looking for the DC’s description it’s a different thing.
A DC definition has its own separate attributes which can be read…
componentdefinition.attribute_dictionary("dynamic_attributes").each_pair{|k,v| puts "#{k} = #{v}" }
will print out ALL of the definition’s DC attributes, including ‘description’,
which can be got thus:
dc_description = componentdefinition.get_attribute("dynamic_attributes", "description", "")
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.