Deactivate section plane

Hi, I am trying to make a plugins to make animation and hide/show group models. But so far I know how to activate section plane, but is there any command that could deactivate section plane?

entities = Sketchup.active_model.entities
sp = entities.add_section_plane([50, 50, 0], [1.0, 1.0, 0])
sp.activate

This is a simple code to activate section plane. but I cannot deactivate it using sp.deactivate(sp). Is that I am using it in a wrong way or it is not the ideal command?

Example to deactivate the section plane for entities object …

entities.active_section_plane= nil
1 Like

or you can turn the display of all off/on

Sketchup.active_model.rendering_options["DisplaySectionPlanes"] = false
Sketchup.active_model.rendering_options["DisplaySectionPlanes"] = true

john

Thank you for your apply. Here are my code to create section plane only for Group name ==“001”, I tried using sp.deactivate(sp)

all_groups = Sketchup.active_model.entities.find_all{|e| e.class == Sketchup::Group}
my_group = all_groups.select{|g| g.name == “001”}.first
my_entities = my_group.entities
my_entities.active_section_plane= nil

I tried and it works! thank you for your help!

Hi, John, I tried what Dan proposed and it worked!

I think what you proposed is to display sectionplane or not. It is only for appearance but not for functionality. In another way, this couldn’t turn plane active or deactive. but thesef function would be very useful later as well!
Thank you for you suggestion.

#grep is faster than your own iterator block …

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

#find returns a single object or nil if not found …

my_group = all_groups.find { |g| g.name == "001" } # nil if not found
my_group.entities.active_section_plane= nil if my_group

Thank you Dan.

I just improved it with my code.

1 Like