In SketchUp 2023, the viewport size (view.vpwidth and view.vpheight) is not updating dynamically during iterations

Hi everyone,

I’m encountering an issue in SketchUp 2023 where the viewport size (view.vpwidth and view.vpheight) does not update dynamically during iterations in my Ruby script. Here’s the scenario:

  1. I’m attempting to resize the SketchUp window and dynamically capture the viewport size during each iteration.
  2. The viewport dimensions (view.vpwidth and view.vpheight) seem to lag and don’t immediately reflect the changes in the window size.
  3. This results in incorrect or stale values being captured during the iteration.

We need a little more information, e.g. your exact code is matter…

Some thoughts:

Are you using the resize_viewport method?

Did you considered the warning in a documantation:

__

Didi you used the #invalidate method or #refresh, after resizing?

I use the Win32APIs ShowWindow & MoveWindow methods.

showWindow = Win32API.new(“user32.dll”, “ShowWindow”, “LI”, “I”)
moveWindow = Win32API.new(“user32.dll”, “MoveWindow”, “LIIIII”, “I”)

I have no experience with Win32API (or fiddle), but for sure:
“Win32API is deprecated after Ruby 1.9.1; use fiddle directly instead”

Even with fiddle, no luck.

You will likely need to use a ViewObserver object.

There is no guarantee when making calls to external system APIs, that SketchUp will respond during the Ruby iteration loop. Sometimes the reaction does not happen until control returns to SketchUp.

Also, the Ruby Win32API class was removed in Ruby 3.0, so it is no longer present in the Ruby Standard Library for SketchUp 2024 and later.

Additionally, SketchUp is migrating to use the Qt framework libraries, so some window objects no longer respond well to old Win32API or MFC function calls.

When the Ruby console is closed, the issue seems to be more prominent. Any idea on that ? Issues with handler ?

I noticed there’s a patch for SketchUp 2023, named SU2023.1. Could anyone help me with the download link for it?

1 Like

Not really. There have been numerous issues with the console and how it has seized control of STDOUT.

It isn’t really a normal console window. Instead, it’s a dialog with a textarea control, making it quite slow in many respects.

One if the recent issues is that strings sent to STDOUT via the global puts() often do not display in the order of execution. This can make debugging difficult.

@Renjith Did you try an observer ?