Sketchup.active_model.active_view.vpwidth Shows Different Values in SU2023 Compared to SU2022

Hi SketchUp Community,

I’ve encountered an issue where the Sketchup.active_model.active_view.vpwidth method returns different values in SketchUp 2023 compared to SketchUp 2022, even when working with the same model on the same machine.

Has anyone else noticed this discrepancy? Could this be related to internal changes in the API, display scaling, or something else I’m missing?

I’ve checked for any scaling differences, and everything seems to be set the same on both versions.

Any insights or suggestions on why this might be happening, or how to resolve it, would be greatly appreciated!

Thanks in advance!

There is no . vpwidth method for the Sketchup.active_model.
Only for e.g. #active_view method.

The View #vpwidth method is used to retrieve the width of the viewport for the view.

This is depends on the size of the visible view of the “workspace”. So for example the Tray is different in SU2022 the in SU2023, then the width will be different. Will be different if your Sketchup is windowed or in a full window.
Also in SU2023 they turned to QT library for UI, so you can expect different size of UI elements.

I agree with @demo, that the tray is likely set to a differing width.

How to solve? Easy, do not rely upon the viewport width to be any certain width because the user can change it at any time by adding toolbars to the side docks or changing the tray width. (Also, in some cases SketchUp annoyingly will change the width. This has resulted in complaints.) The user can also de-maximize the window and adjust the overall application window smaller.

So, check the viewport width (or height) just before you need to display something either in a tool or an overlay. You can react to viewport size changes by attaching a ViewObserver to the model’s view object. But do so only when your tool or overlay is active.