Make Layer0 Plugin
-
Hi Guys,
Does anyone know a plugin that will iterate down a component or group tree and make all entities in the tree on 'Layer0'? I have had a look around but couldn't find what i was looking for.Most of my work is imported from Autocad (by others). I have tried different workflows to avoid the issue but i always seem to end up with components that have deep deep layered entities which screws with my layer management further down the line. I want to have a component that can be on a specific layers but have all the branches and entities within on layer0.
If there is nothing around and no dev's are interested i might have a crack at this myself.. Does anyone else have a need for such a tool?
Thanks.
-
See http://forums.sketchucation.com/viewtopic.php?p=47033#p47033
My 'Default Layer Geometry' - this puts all geometry - even within groups/components onto Layer0 - in a selection [use Edit>Select_All to get everything].
However, it does not place groups/instances onto Layer0.
BUT this one-liner will do that step for youSketchup.active_model.definitions.each{|d|d.instances.each{|i|i.layer=nil}}
Copy/Paste it into the Ruby Console + <enter> - BUT use with care!
Remember to 'Purge' the unused Layers when you are done...
I'll post a 'nuke-all' version asap... -
Here's a short script that makes 'Layer0' the layer for absolutely everything [geometry, text, dims, groups, instances etc] that are in the model AND also 'everything' inside all nested groups and components too; it also purges all of the unused layers; and it is one-step undoable. just in case you change your mind after running it !
module TIG UI.menu("Plugins").add_item("TIG.layer0_ALL"){self.layer0_ALL()}unless file_loaded?(File.basename(__FILE__)) file_loaded(File.basename(__FILE__)) def self.layer0_ALL() model=Sketchup.active_model model.start_operation("TIG.layer0_ALL") model.entities.each{|e|e.layer=nil} model.definitions.each{|d|d.entities.each{|e|e.layer=nil}} model.layers.purge_unused model.commit_operation end end
Copy all of the code and paste it into a file called say '
TIG-layer0_ALL.rb
' in the Plugins folder. It will add an item to the 'Plugins' menu 'TIG.layer0_ALL
' [unless you add # in front of the two lines of 'menu making' code at the start of the def] or you can typeTIG.layer0_ALL
into the Ruby Console too... -
This is awesome and exactly what i was looking for, thanks a lot!
Advertisement