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

    Component layer?

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 219 Views 2 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.
    • K Offline
      kat
      last edited by

      Hello,

      I have a issue about the layername of a component that I really don't understand.

      At the start of my program, new componentdefinitions are loaded from an external folder. Then I attach them to a layer with the following code:

      constructionlayer = $model.layers.add "Construction"
        componentdef.layer = constructionlayer 
        componentdef.entities.each{ |e| e.layer = constructionlayer }  
      

      When the component further is instanced in het model and asked for its layer with the following code snippet, it returns first "Construction" and then "Layer0". So the layer of the ComponentDEFINITION is initialized as "Construction", but the layer of the ComponentINSTANCE isn't.

      selection[0].definition.layer.name
      selection[0].layer.name
      

      When I then save the SU file, open it again and ask an other time for the component's layer with the same piece of code, I get first "Layer0" en secondly "Construction". I assume that the layer of the ComponentDEFINITION is now "Layer0" and the layer of the ComponentINSTANCE is "Construction".

      How is this possible?
      Does anyone know about a workarround for this problem?
      After building the SU model, I make a selection of components based on layername, so it is important that this is correctly set in both situations.

      Thanks a lot for all help!

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        You can't place ComponentDefinitions on layers - you need to place each instance on the layer you want.

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • K Offline
          kat
          last edited by

          But ComponentDefinition inherits from Drawingelement and this class has a layer method? I don't understand

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            You can assigned the entities in the ComponentDefinition a layer, and you can assign ComponentInstances a layer. And while practically you can apply a layer to a definition, SketchUp ignores this.

            Thomas Thomassen — SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

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

            Advertisement