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?
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.
@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?
@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?
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…