5

How do you access the current model in the Sketchup ruby console?

I'm trying to do a custom filter for surface and would like to see the resulting ones (to go above and beyond the "filter tool"), and would like to write some lines of code directly in the sketchup ruby console, but I'm unclear on how to select the current model, so I can do stuff like model.getSurfaces.

How can I access the current model in the Sketchup ruby console?

Julien Marrec's avatar
29.7k
Julien Marrec
asked 2016-01-13 09:12:22 -0500
__AmirRoth__'s avatar
4.4k
__AmirRoth__
updated 2016-01-13 09:25:40 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

5

I think I got it from searching the source code:

In [1]: sketchup_model = Sketchup.active_model
In [2]:model = sketchup_model.model_interface.openstudio_model
In [3]:model.class
Out[3]: OpenStudio::Model::Model
Julien Marrec's avatar
29.7k
Julien Marrec
answered 2016-01-13 09:30:07 -0500
edit flag offensive 0 remove flag delete link

Comments

That's the secret code, be careful you can break things using the Ruby console. Another line that might be useful to you is

Sketchup.active_model.selection[0].drawing_interface.model_object

which gets the OpenStudio ModelObject for the currently selected SketchUp object.

macumber's avatar macumber (2016-01-13 11:21:55 -0500) edit
add a comment see more comments