sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    How to apply attributes through code? and how do they work?

    Scheduled Pinned Locked Moved Developers' Forum
    21 Posts 4 Posters 567 Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • TIGT Offline
      TIG Moderator
      last edited by

      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 a Sketchup::ComponentInstance.
      You can find its definition thus definition=instance.definition

      Now you can find an instance.definition but conversely you can find a definition.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, so instance.definition.entities gives 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 ...

      ☀

      TIG

      1 Reply Last reply Reply Quote 0
      • 1
      • 2
      • 2 / 2
      • First post
        Last post
      Buy SketchPlus
      Buy SUbD
      Buy WrapR
      Buy eBook
      Buy Modelur
      Buy Vertex Tools
      Buy SketchCuisine
      Buy FormFonts

      Advertisement