Resize_Viewport Am i using it wrong?

model = Sketchup.active_model
Sketchup.resize_viewport(model, 800, 800)

seems simple enough
cannot return TRUE no matter what numbers i put in there
when I try to export an images, I check box for use screen size, the numbers never match the viewport size that is set with resize viewport

How do i set my viewport to an exact size?

Set viewport to 800,600
Export says its 802*632
There are no trays open.
All toolbars are closed.

Always seems to be off by 2 in the X and 32 in the Y

Awesome google!
If i want 800x600
I set my viewport to 798x568
Lovely new command
Thank you.

Wikipedia said …

Trimble Navigation (now Trimble Inc.) acquired SketchUp from Google on June 1, 2012

… so Google has not owned SketchUp for more than 11 years.

I think this has been reported. It may be that the borders, caption bar and menu bar sizes are not handled well.

The official API Issue tracker is on GitHub …

BTW … the metrics are slightly different on my display.

model = Sketchup.active_model
Sketchup.resize_viewport(model, 800, 600)
#=> false
#=> 802
#=> 639

I suspect that the return value really has no good meaning as currently implemented.

Also, the documentation is quite old and the arguments are actually logical pixels that are scaled according to the display scaling, which have issues (especially on Windows platform). Ie, the result on a scaled display are not actually the dimensions requested.

  • There is a current bug that some features are scaled by the scaling factor of the Main display, rather than the display that SketchUp is using.

Likewise, the returned values from View#vpwdith and View#vpheight do not return the actual physical pixels but the logical pixels.

SketchUp is currently undergoing a multiple release cycle migration from the old deprecated MFC framework to the cross-platform Qt framework for it’s GUI.

So, some API functionality has not yet caught up with the migration.

Thank you Dan, much appreciated

1 Like

The true size of the viewport can be found with

1 Like