How to apply attributes through code? and how do they work?
-
Things [each called an
Entity] that are 'visible' in a model are typically geometry [lines, faces etc], and groups and components [what is commonly called a component is actually a 'component-instance']. These groups and instances contain geometry - they can also contain sub-groups and other instances. This is a simplified picture since there's also Images, Text, Dimensions etc etc but lets keep it simple !
Within the model's 'database' there are other things you can't see but that you can use - inside 'collections' called Materials, Layers, Styles and ComponentDefinitions. Each of these will have entries like Material, Layer, Style and ComponentDefinition.So far so good ?
When you look at the Components in the Browser you are looking into the model's database and seeing the Component-definitions available for use.
When you select [highlight] something in a model you can get its 'class' [typename etc] so with the initial examples above you have Sketchup::Edge, Sketchup::Face, Sketchup::Group and Sketchup::ComponentInstance.
Let's assume you have somehow set a variable
instance=ss[i]which is aSketchup::ComponentInstance.
You can find its definition thusdefinition=instance.definitionNow you can find an
instance.definitionbut conversely you can find adefinition.instances[i.e. all of that definition's instances]
Any particular definition's instance doesn't contain anything at all - it is a marker for the definition itself, soinstance.definition.entitiesgives you a list of entities inside the definition that that instance is using...
You can even 'swap' an instance's definition for another one:instance.definition=another_definition...
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