rajawat
November 18, 2019, 6:08am
1
Hi,
In my plugin, I want to add the functionality to export the scene - after all the sections are applied - in .obj format. Right now when I export all the elements are exported irrespective of sections.
Only visible elements should be exported with proper cuts.
How to achieve that using Ruby scripts?
I don’t think obj has a section cut feature. You could try to physically cut the model with something like Eneroth Slicer before making the export.
I am not sure that it is possible yet. We’ve asked, but the “Create Group from Slice ” feature of the Section Plane
object has not yet been exposed in any of the APIs.
opened 03:01PM - 23 Jan 19 UTC
enhancement
Ruby API
SketchUp
logged
parity
### SketchUp Ruby API Feature Request
Please expose the internal method from … the section plane right-click context menu, to create "**Create Group from Slice**".
(Repeatedly asked for in the forums over the years. Currently hacky platform dependent send keys workarounds is all that can be done.)
```ruby
WIN ||=( Sketchup::platform == :platform_win rescue RUBY_PLATFORM !~ /darwin/i )
require 'win32ole' if WIN
def group_from_slice
if WIN
# Send the ESC key to close the Ruby console window, so that the
# main application window will receive the CTRL+ALT+S keystroke.
WIN32OLE::new('WScript.Shell').SendKeys('{ESC}^%s')
else
puts "Feature is PC Only"
end
end
```
----
#### Thinking that a SectionPlane is an Entity subclass the following attempt to use [**`Sketchup::Entities#intersect_with()`**](http://ruby.sketchup.com/Sketchup/Entities.html#intersect_with-instance_method) fails ...
```ruby
ents = Sketchup.active_model.entities
ents.intersect_with(true,IDENTITY,ents,IDENTITY,true,ents.active_section_plane)
#=> []
```
So, either the above method would be extended to accept a section plane object, **AND / OR** a new instance method added to the [**`Sketchup::SectionPlane`**](http://ruby.sketchup.com/Sketchup/SectionPlane.html) class that mimics the GUI menu command and creates the group of intersect edges within the current active edit context (or the section plane's parent's context, whichever makes more sense.)
Q: Would it be possible to create these intersect groups for ANY section plane, not only active section planes ?
----
Or, ... is there a constant integer ID that can be used with [**`Sketchup.send_action()`**](http://ruby.sketchup.com/Sketchup.html#send_action-class_method) ?
Or even better a send action string for both platforms ?
----
_Reference public forum threads:_
* [Outliner create slice group via API, somebody can help?](https://forums.sketchup.com/t/outliner-create-slice-group-via-api-somebody-can-help/69337)
* [How to export model part above the ground plane only](https://forums.sketchup.com/t/how-to-export-model-part-above-the-ground-plane-only/86134)
* [Create Section Plane Programmatically?](https://forums.sketchup.com/t/create-section-plane-programmatically/82986)
if you PM me a model with a scene for each camera position and I’ll see if my code runs on it…
exporting is the easy bit…
john