[REQ] layer attribute from geometry to group
-
I believe there was recently a post asking for the reverse of this. I have received a model which has all layer attributes assigned to the actual geometry (faces/edges). When i try and export this to an external program it does not pick up the layer information as the top most groups are all showing Layer 0.
What i need is a script that recursively goes through all geometry and assigns the same layer attributes to the parent group(s) or components.
Does anyone know of such a script or if it is not too difficult have a quick play and see what is achievable?
Any help would be very much appreciated.
-
Are all entities inside each group/component-definition on a single layer.
It's unworkable if not...
If they are.... you can use:m=Sketchup.active_model;ds=m.definitions;m.start_operation('x');ds.each{|d|d.instances.each{|i|i.layer=d.entities[0].layer}};m.commit_operation;
copy+pasted into the Ruby Console + <enter>.
It is one-step undo-able.If you want to give the group/instance the internal contents' layer AND also revert the faces/edges in it to Layer0, this alternative is what you need:
m=Sketchup.active_model;ds=m.definitions;m.start_operation('x');ds.each{|d|d.instances.each{|i|i.layer=d.entities[0].layer};d.entities.grep(Sketchup;;Face).each{|e|e.layer=nil};d.entities.grep(Sketchup;;Edge).each{|e|e.layer=nil};};m.commit_operation;
We can't try to revert everything to Layer0 because if you have nested groups they'll be all over the shop as their layer alters...
-
TIG,
Thank you very much! That worked great.
Advertisement