Ruby code for Setting Active Section Planes
Posted: 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
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