Ruby code for Setting Active Section Planes

Announcements, requests and support regarding SkIndigo - the Sketchup / Indigo exporter.
Post Reply
5 posts • Page 1 of 1
User avatar
mriedel
Posts: 14
Joined: Sat Apr 18, 2015 9:35 am
Location: Minnesota, USA
Contact:

Ruby code for Setting Active Section Planes

Post by mriedel » Thu Feb 02, 2017 2:55 pm

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
----
The Riedelian Law of Productivity: Every task will take twice as long as expected -- even if the Riedelian Law of Productivity is taken into account.

User avatar
Pibuz
1st Place 100
Posts: 2646
Joined: Tue Dec 11, 2007 7:58 am
Location: Padua, Italy
3D Software: SketchUp

Re: Ruby code for Setting Active Section Planes

Post by Pibuz » Fri Feb 10, 2017 3:32 am

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.

User avatar
mriedel
Posts: 14
Joined: Sat Apr 18, 2015 9:35 am
Location: Minnesota, USA
Contact:

Re: Ruby code for Setting Active Section Planes

Post by mriedel » Sun Mar 05, 2017 2:21 pm

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
----
The Riedelian Law of Productivity: Every task will take twice as long as expected -- even if the Riedelian Law of Productivity is taken into account.

User avatar
Pibuz
1st Place 100
Posts: 2646
Joined: Tue Dec 11, 2007 7:58 am
Location: Padua, Italy
3D Software: SketchUp

Re: Ruby code for Setting Active Section Planes

Post by Pibuz » Tue Mar 07, 2017 3:44 am

Ok gotcha.

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

User avatar
mriedel
Posts: 14
Joined: Sat Apr 18, 2015 9:35 am
Location: Minnesota, USA
Contact:

Re: Ruby code for Setting Active Section Planes

Post by mriedel » Tue Mar 07, 2017 9:18 am

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
----
The Riedelian Law of Productivity: Every task will take twice as long as expected -- even if the Riedelian Law of Productivity is taken into account.

Post Reply
5 posts • Page 1 of 1

Who is online

Users browsing this forum: No registered users and 26 guests