Component layer?
-
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!
-
You can't place ComponentDefinitions on layers - you need to place each instance on the layer you want.
-
But ComponentDefinition inherits from Drawingelement and this class has a layer method? I don't understand
-
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.
Advertisement