[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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement