Looking for Plugin
-
Question:
Is there a plugin that will make scenes for each layer? So if I have 5 layer, run the plugin, the plugin will create 5 scenes with the name of the layer. Seems I have seen a plugin that did this, however, I can not find it, or I am using the wrong search text.
Thank you in advance
Ken
-
Copy+Paste this code into a file called
layer2scene.rb
in the Plugins foldermodule TIG def self.layer2scene() model.start_operation('layer2scene') layers=[];model.layers.each{|layer|layers<<layer.name} layers.sort.each{|name|model.pages.add(name)} end end
Restart Sketchup.
TypeTIG.layer2scene
in the Ruby Console to make a set of Scene tabs named after every Layer name... Making new scene tabs is not 'undo-able'... so save first and use with care!EDIT: use the corrected code in the post three on - this one has a typo
-
TIG
Thank you for your quick reply. I added the line as indicated below as it did not work with the code you provided. So, I get two for the price of one. Some code that I will try to add to a toolbar and a learning exercise in Ruby. It is a good day when you have corrected TIG's code.
module TIG
def self.layer2scene()
model=Sketchup.active_model # Added by Ken
model.start_operation('layer2scene')
layers=[];model.layers.each{|layer|layers<<layer.name}
layers.sort.each{|name|model.pages.add(name)}
end
endThanks
Ken
-
@unknownuser said:
It is a good day when you have corrected TIG's code
At times I wonder if he does this intentionally?
-
Of course I did !
The correct code ismodule TIG def self.layer2scene() model=Sketchup.active_model layers=[];model.layers.each{|layer|layers<<layer.name} layers.sort.each{|name|model.pages.add(name)} end end
There is no point in adding a start/commit block as adding scenes is not undo-able! I edit the code at the last minute when I realized that BUT removed the wrong line... I was rushing because my dinner was ready even I have to eat
Sorry for the balls-up - congrats on fixing it yourself... -
What?! You eat?!?
-
I eat and drink... like mere mortals
-
But you don't sleep
-
is it possible to hide the other layer excepte the one that hade the scene name? so you will have every layer in separate scene.
Advertisement