Switch to scene by ruby script
-
If I know the name of a scene, how can I switch to it by ruby script?
-
page = Sketchup.active_model.pages["Page Name"]
Sketchup.active_model.pages.selected_page=page -
Jim, thank you very much.
It took some time to understand, that I have to copy your script lines in one line, separated by ;, as you see here:
page = Sketchup.active_model.pages["Szene 1"]; Sketchup.active_model.pages.selected_page=page
Now your script works. Phantastic!
-
You can write it as two lines without the semicolon ; The semicolon is not necessary in Ruby.
-
I would guess when the lines were copied and pasted, maybe they wrapped in such a way that they appeared to be 2 lines but were really one. Or possibly the newline wasn't copied correctly. Just replace the semi-colon with a newline.
-
On my Mac it runs with semi-colon, but not with newline.
-
You need to use the semicolon if you want to type it as one line in the Ruby Console.
The ruby console does not understand newlines.However, If you are using it in a ruby script that you then load from the console Jim is right and there is no need for semicolons, Ruby is semicolon free.
thanks.
Simone. -
Thanks for good explanation.
I see, I told not clearly, to type the only one script line in the ruby console.
Advertisement