Page 1 of 1

Ruby code for Setting Active Section Planes

Posted: Thu Feb 02, 2017 2:55 pm
by mriedel
Sharing this in case it is of interest to anyone here...

For Sketchup section planes to be active in Indigo, then must be enabled by right-clicking "Enable Section Plane" from the Skindigo submenu. This provides flexibility: different section planes can be enable or disabled as one pleases. However, it can make the process of setting up a scene for export tedious.

I generally want exactly what I've got in Sketchup. Here is a little script that enables the Indigo section planes that are active in Sketchup and disables the rest. To use it:
1) You can place the script in your Plugins folder, in which case in will load when you restart Sketchup, or
2) You can manually load it from the Ruby console in Sketchup. Save the file somewhere, say as ~/Desktop/set_sp.rb. Then open Ruby console and type load "~/Desktop/set_sp.rb"

The script adds an item to the Extension menu, Skindigo: Set Section Planes.

I have some more Ruby scripts that I've written for specific tasks. For instance, I have one that exports every scene in a model, in turn. I'd be happy to share these scripts if there's interest.

--Marc


module SkIndigo

UI.menu("Extensions").add_item("Skindigo: Set Section Planes") {
SkIndigo.set_sp
}

##### set Indigo section planes to be active section planes
def SkIndigo.set_sp

model = Sketchup.active_model
entities = model.active_entities
sp = entities.grep(Sketchup::SectionPlane)

# for each section plane
sp.each { |plane|
# if section pane is active, activate it for SkIndigo
if plane.active? then
plane.set_attribute('indigo07_settings','active_section',true)
else
plane.set_attribute('indigo07_settings','active_section',false)
end
}
end

end

Re: Ruby code for Setting Active Section Planes

Posted: Fri Feb 10, 2017 3:32 am
by Pibuz
Hi Marc!
Thanks you're very generous (and competent :lol: )

Can you explain a little further what do you mean by "it disables all the rest?"

I never found complications when working and abilitating skindigo section planes, it's a littel difficult to me to understand in which specific cases it's annoyng for you (and potentially for all of us) getting the skindigo section planes to work.

Re: Ruby code for Setting Active Section Planes

Posted: Sun Mar 05, 2017 2:21 pm
by mriedel
Pibuz,

Sorry for not responding sooner! I agree: there's no real complication in working with section planes with Skindigo. But the following situation arises for me. I have a model with many different scenes. When I add a new section plane in a given scene, it is automatically set to be "active" for Skindigo. When I go back to render another scene that I set up earlier, the new section plane is still active for Skindigo, but not active in Sketchup. Since I don't see the section plane, I forget to disable it before rendering. (In general, finding and managing different section planes is cumbersome in SketchUp.)

Logical behavior would be that the scenes that are active for Skindigo and the same as those that are active for Sketchup. This is was the script above does.


--Marc

Re: Ruby code for Setting Active Section Planes

Posted: Tue Mar 07, 2017 3:44 am
by Pibuz
Ok gotcha.

But, is the section plane still Indigo-active event if it's SketchUp-hidden?

Re: Ruby code for Setting Active Section Planes

Posted: Tue Mar 07, 2017 9:18 am
by mriedel
Yes, the Indigo settings for active/inactive for section planes are independent of the Sketchup settings. It seems that when a new section plane is created in Sketchup, it is set to be active by default for Indigo. But disabling section planes in SketchUp does not disable them for Indigo.

--Marc