Is there a way to select Scene by its name and access sectionplane tribute/entities?

Hi, I just created 4 Scene and named them as Scene 1 to 4. And also created 4 cube model as group. Each one of the cube has a sectionplane to hide or show them. I tried to use the command

entities = Sketchup.active_model.entities
all_groups = entities.grep(Sketchup::SectionPlane)

but Ruby gives me a blank array as: Ruby Code Editor: Ruby says:

When I tried the same thing as entities.grep(Sketchup::Scene). Ruby says: uninitialized constant Sketchup::Scene

Is there a way to select Scene by its name and modify the section plane as Active or not? I wish there would be a way to change sectionPlane value to be active or nil in different Scene.

Hi, I tried the command

model = Sketchup.active_model # Open model
but console gives me this apply:

Ruby says: Nil result (no result returned or run failed)

even though I have created a Scene renamed as “001”


that code gives you all the names from the array of model pages…

it also gives a clue on where to look in the API >> [Pages]…

page_names =

page_name = model.pages['001'] # => returns a reference to the page


Before the GUI called them “Scenes” they were first known as “Pages”.
They got renamed “Scenes” in the GUI, but still retained the old classname in the API.

Because you grepped the model’s entities collection which does not have any section planes.
So the empty array was the correct result from the grep call.

To get a hash of the scene pages from each cube group …

entities = Sketchup.active_model.entities
all_groups = entities.grep(Sketchup::Group)
section_planes = {}
all_groups.each { |grp|
  section_planes[]= grp.entities.active_section_plane

Now section_planes is a hash with group names as the keys and active section plane references as the values.

When you get an error, you should always take a look at the error message:

SyntaxError: (eval):2: syntax error, unexpected tINTEGER, expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END

which points to the token &:001 which has incorrect syntax. Then you look up the documentation of map and find that its normal (not shortened) usage is like:{ |a_single_page|

(which is often shortened to
As method name you used 001 which is not a valid name for Ruby methods.

1 Like