Automatically Print Scene to Size and Aspect Ratio

Hello all,

I am trying to write a script that prints/exports a series of scenes in a model, at a certain sizes and aspect ratios, to PDF.

I have tried changing the aspect ratio for the active view’s camera, but the grey space surrounding the view still exports/prints.

I cannot simply re-size the SketchUp window, as this process needs to be fully automated and each scene requires a different size and aspect ratio. Unless someone knows how to re-size the SketchUp window using the command line…

Is there any way to get SketchUp to print only the active view? Or print a portion of the view that I select?

ANY help would be greatly appreciated.


in a mac extension of mine, I rewrite the ‘default’ window size using ‘system’, and then close and re-open the file…

on Windows I believe you can use builtin Ruby calls for the same outcome…

@eneroth3 does change the viewport size in one of her ‘Windows only’ extensions, but I’ve never looked how she does it…


With the scene you want displayed and fully transitioned:


… BUT, this brings up the Print dialog.

Better to export to the PDF file and print later using the Sketchup::Model#export() method.

It may be necessary to use a FrameChangeObserver to know when the scene page transition is complete before you do the export. (We’ve discussed this in other topic threads in this category,… hint, search feature, hint hint.)

Likewise you may need to check that the previous scene’s file has been written to disk before you transition to the next scene page. (Use File class methods to check for existence.)

I’ve looked into my old Window Resizer plugin and it can be called from another script if you want to batch export several scenes. Unfortunately it’s Windows only because of the API I’ve been using.

If the plugin is installed this code should resize the viewport to 400 px width and 200 px height.

Ene_ViewprtResizer.resize(true, [400, 200])

Unfortunately the plugin simply resizes the active window, which if the code is run in the Ruby console is the Ruby console. If you make a script that you call from a menu within SketchUp it should however work. If you just want to test the code from the console you can also wrap it in a timer and switch focus to the main SketchUp window as soon as the timer is started. This example gives you one second to click anywhere in the main SketchUp window after having executed the code in the console.

UI.start_timer(1) { Ene_ViewprtResizer.resize(true, [400, 200]) }

@DanRathbun I can’t seem to find any parameters in the #export method that allows you to limit the area printed to one section of the screen. I am trying to print a square area, but obviously my screen is a rectangle, so when SketchUp prints there is blank space in the PDF on either side of the square.

I also am struggling with the #export method getting rid of my textures when I export.

I have looked at the documentation on the page you referenced, but they give no detail about the functionality the parameters you can add to the export. Are these discussed elsewhere?

Thank you so much for your help!

vector exports only have flat colours…

if you want both vectors and textures you need to export both raster and vector and combine them elsewhere…

can you post an example skp file?


@john_drivenupthewall Here you go. I just need a PDF that looks like the below image (textures, no empty white space).

Test House.skp (406.0 KB)

@eneroth3 Your plugin works great. I would like to avoid resizing the window if possible, as I feel it would be an unattractive UI and could lead to errors if the user interfered during the process. If I can find no other way, this is a great alternative.

Do you know of any way I can control what portion of the model will be printed/exported? Selecting the component beforehand? Specifying points on the screen? Points in the model?


Did not say it does.

Currently, there is nothing in the API that does take a screen grab like you wish. Coders have used 3rd party C libraries in the past. It was discussed either here or at SketchUcation.

exporting a png or tiff with transparency will avoid the ‘grey’ space, but if you want to output a multi image pdf then you could do that by placing images in a HtmlDialog and exporting/printing the result…


Thank you thank you @john_drivenupthewall!!! :raised_hands: That will totally work. You rock.

This topic was automatically closed after 91 days. New replies are no longer allowed.