Components to layers?
-
Is there a way to put many models into layer without opening each file individually opening each file and manually typing the layer name?
Sure I saw something on this a while ago but cant find anything through the search option or trawling pages of old requests and plugins.Many thanks in advance.
-
### if you have 'selected' an instance, then use defn=instance.definition ### now change the defn's entities' layer to 'newlayer' ### newlayer must be an existing layer... defn.entities.each{|e|e.layer=newlayer} ### defn's entities are now on the layer 'newlayer' ### you could also test with "e.layer=newlayer if e.layer==thislayer" etc
-
Sorry TIG. How do I use the code on unopended files? I have many individual models I want to be on a new Planting layer. How woul d I use the code to do that?
Many thanks.
-
@j_forrester said:
Sorry TIG. How do I use the code on unopended files? I have many individual models I want to be on a new Planting layer. How woul d I use the code to do that?
Many thanks.Please expand on these 'models' - are they lots of separate skp files that you want to open one after the other and 'process' ? If so you could make a Ruby that'd open all of these skps in a selected directory... and in turn change their layers...
How are these layers to change ? To default everything to 'Layer0' you could have the script run through the
model.entities.each{|e|...}
thenmodel.definitions.each{|d|d.entities....}
and set everything toe.layer=nil
... otherwise you need to find an existing layer by name or make the layer and name it then use that to set layers to...I had initially thought that you have several skps loaded into a model [as components] and wanted to change the layer(s) of their contents...
If we can hone in on exactly it is you want to do I'm sure it's achievable...
-
@j_forrester said:
I have many individual models I want to be on a new Planting layer.
When you File/Import you are given a Move handle and then you place the imported component. How would the plugin know where you had in mind?
-
@martinrinehart said:
@j_forrester said:
I have many individual models I want to be on a new Planting layer.
When you File/Import you are given a Move handle and then you place the imported component. How would the plugin know where you had in mind?
The import method imports without a 'move'... there are two methods for inserting skps too. I think he wants to change the layers in many separate component files...
-
Sorry TIG for my extremely long delay. Very busy and completely forgot about the post.
In it's most basic form, say I want to change the layers for all the default SU components. I would like all the people (2D silhouette, 2D Colour and 3D) to be put onto a "People Layer". All the Trees (including subfolders again) to be put onto a tree layer.
Then when I want to use these in new scenes they are already on the correct layer and not having to search the whole scene later and individually put them onto the required layer. I could and have gone through many default components and changed them but wanted to know if this could be automated. Each file is one model.
-
It IS possible but I'd not recommended it...
Best if a Component's base geometry is left on Layer0 and the Instances are placed on Specific Layers in each Model that way you can have some 'trees' on and some off by having them on TREE-PH01 and TREE-PH02 layers for example...An outline to do what you want is a tool you run and it asks you for a folder to process, starting in the Components folder. You navigate to say your 'Trees' folder and pick one of the SKPs in there.
Now it knows which folder to process.
Now asks for the Layer name - it could read the base-folder name and capitalize it and truncate to 4 characters to suit AIA standards etc - in the dialog you [accept or] enter a name - say 'TREE' for the layer.
It then imports each SKP file in turn as a Component.
It takes that Component-Definition's entitles [and any sub-component-instance definition's entities ?] and puts them onto a Layer called 'TREE'.
It then exports that Component back into the same location, overwriting the original.
All SKPs are processed.
You do a folder of similar Components at a time. You might need some pre-processing thinking and say split your Planting into folders like Trees, Shrubs, etc IF you want separate layers for these...My
import_from_folder.rb
is an example of how to import files... perhaps more applicable mybatchEraseFlatInstances.rb
which does something similar to what you want, BUT that goes through a list of SKPs in a selected folder - imports them, edits them to erase 'flat' instances within them and then does asave_as
on the definition back to where it was...*
The changing of layers etc is also to be found in many scripts available here and could be substituted for the erase 'flat'... part of this script*...
Advertisement