Layout Ruby and use of a template

I want to program something in the layout ruby (i don’t know how to use C)
I want to make from my sketchup model a layout-file with the use of a template layout-file. (And then also do a few other steps.)

I probably have found a way, but it seems a bit a long side road:

  1. Open the layout-template: doc =
    (now the layout model is yet not connected with the sketchup-model you want)
  2. Iterate over all Layout::SketchUpModel entities with each and do:
    2.1 Get all the information (bounds, scenes, …) of the current Layout::SketchUpModel and put it in tmp parameters
    2.2 Remove the current entity(Layout::SketchUpModel) doc.remove_entity()
    (still have to try if this works when iterating over them)
    2.3 Make a new entity with layout_view =, bounds)
    2.4 Put that entity in the layout file doc.add_entity(layout_view, layer, page)
  3. If you actually want to see the layout file, then you still have to save it:

You can probably also do first 2.3 and 2.4 when the ‘old’ layout view is still in the doc and do remove 2.2 after that.

When you manually do that, you just have to send it to layout and select a template and your done. So, it seems like a bit a complicated solution to do something simple. Also i have doubts if i will be able to get the views in layout exactly the same as they where.
Does anyone knows a better way?

Also, is there a web page like ‘coming soon in SU-2020’ ?
Will Sketchup make more possibilities with that Layout Ruby API?

So, before i program all this, i would like to know if there is an easier way (or coming soon)?

1 Like

Yes I opened an issue on this in the public issue tracker last August.
I’ve just added that there is no #path= setter method and inserted a link to this topic thread …

Your workaround code will be something like …

def send_to_layout(model_path,template_path)
  doc =
  this_page = doc.pages.first
  entities  = this_page.nonshared_entities
  old_model = entities.grep(Layout::SketchUpModel).first
  vp_bounds = old_model.bounds
  new_model =, vp_bounds)
  layer = old_model.layer_instance
  doc.add_entity( new_model, layer, this_page )
  model.render if model.render_needed?
1 Like

Trimble employees are not allowed to make “forward looking statements” (as Trimble is a publicly traded company and/or it’s just policy because the software market is very competitive.)
So no there is no such website and you’ll know when the next version is released and the API release notes are published.

You set up scenes in the SketchUp model for use as viewports in the LayOut document. This means you’ll usually also create some scenes that are only used for modeling (so you don’t mess up your LO viewports when modeling and moving the camera around.)
Just keep in mind that the index order for the current_scene= method is 1 more than the scene index in SketchUp (because 0 is used for the “Last Saved SketchUp View” in LO. Avoid using this and setup scenes inside SketchUp.)

It is also common to setup scenes and styles just for printing and making presentation images in the model.

Thank you very much for your answers!

1 Like

Use the GitHub issue tracker to log missing functionality:

We tend to prioritize such type of functionality parity issues.

1 Like

@DanRathbun may I consider that this is the generic way to send a model from Sketchup space into Layout? …Could you elaborate why old_model and new_model are needed?

I wish to create 2D drawings from the 3D space and the following is my current idea, in a pseudo code format :wink:

# Create a Layout
doc =
# Add Sketchup model
doc.add_entity( model, layer, this_page )
#Export layout to PDF
status = doc.export(export_path, options)

The first and third parts are working and fine, but I’m missing to add a Sketchup model. Basically add anything from .skp file. See my current working file as attached. layout_drawings.rb (2.0 KB)

NO. This thread is about a specific scenario where a LayOut document template that has preset model viewports. The original poster for this scenario needs to load the current model in SketchUp into one of the preset viewports (which is the first preset viewport on the first page of the new LO document made from the template file.)

So no it’s not a generic “Send to LayOut” clone.

Why not read the feature request that is logged in the official API Issue tracker ?

FYI: In the LayOut API they named the viewport object class Layout::SketchUpModel so that is what the references old_model and new_model are referring to … “the old viewport” and “new viewport” objects.

They are needed because of an oversight in omitting a way to set a LO viewport’s path to a model file.

That nice, but you are not using a LO file template, so this topic thread has nothing to do with your situation, … and everything from this statement on down is off-topic. Please begin a new topic thread for specific questions regarding your specific coding challenges.

@DanRathbun thanks, I’ll do so and open a new topic if needed.