Component definition name
-
Hi,
How to get the definition name from a selected component?
I tried the code below, assuming only one component selected which is correct. But this returns just the name not the definition name which is set when the component is created.model = Sketchup.active_model; selection = model.selection componentdef = selection[0] UI.messagebox(componentdef.name) -
You are making a reference to an Instance not a Definition.
An Instance can have a name separate from its Component's name...
Do it this waymodel = Sketchup.active_model; selection = model.selection component_instance = selection[0] component_definition = component_instance.definition ci_name = component_instance.name cd_name = component_definition.name ### to be clever count the instances too ;) num = component_definition.instances.length.to_s UI.messagebox("Component Definition Name = "+cdname+"\nComponent Instance Name = "+ciname+"\nThere are "+num+" Instances.") -
Works great, thanks.
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