Ruby script question

Is it possible to write a Ruby script that would export all sections in the model as slices? Looking to export and then link them as Xrefs in AutoCAD, so I can easily update changes to geometry…


Not sure exactly what you want. But the “Create group from Slice” context command, (when you right-click a section plane,) has not yet been exposed to the API.

There may be workarounds since you can get the geometric plane of the section plane object, and create a temporary face from that (using the target object’s bounding box for size,) and then intersect the face with the target object.

1 Like

Hey Dan, thanks for the reply. Was thinking that scenes would be set up with the proper view and active section manually. Then I would like to automate: file>export>section slice for all scenes, saving the files by scene name into a target folder. At this point I Xref the files to my AutoCAD drawing, then I can update the plan set with changes by running the export again. I currently do this manually and it can be time consuming with large models.

On Windows we have an automation ID assigned to that command which we can use to send an action …

Sketchup.send_action( 21359 )

I’m not sure if there is a cross platform send action string that can be used on Mac for this. @thomthom ?

If not, on Mac you’d need to assign a shortcut keychord, and then use cliclick or similar utility to mimic key presses. @john_drivenupthewall has posted in this category extensively about using cliclick .

1 Like

hmm… not that I can see… :confused: