How to refresh VCB when Units change


#1

I have a simple extension which allows me to change the units encoding with a key shortcut:

   mymenu = UI.menu("Plugins").add_submenu("Toggle Config")
   mymenu.add_item("Toggle Units Type") {
      arch=Sketchup.active_model.options["UnitsOptions"]["LengthFormat"]
      Sketchup.active_model.options["UnitsOptions"]["LengthFormat"]= (arch+1) % 3
      Sketchup.set_status_text  # clear VCB
   }

The problem is, the VCB is only updated upon moving the cursor. I haven’t found a way to force redisplay of the information in the VCB (right now I just clear it). Any tips?


#2

Just bumping this to see if anyone has ideas.


#3

this works on a mac…

def set_status_text_test
  model = Sketchup.active_model
  view  = model.active_view
  Sketchup.set_status_text
  view.refresh
  Sketchup.set_status_text( "This is a Test" )
  view.refresh
  Sketchup.set_status_text( "Test:", SB_VCB_LABEL )
end

john


#4

Sorry, I should have been more specific. I want the currently active tool (line tool, measure tool, etc.) to be “told” to repopulate the VCB text it is responsible for. view.refresh does not do this. I select, e.g. the measure tool, start dragging out a measurement, hit a hotkey to change units, and ideally units are then updated. Right now I have to move the cursor for the active tool to update the VCB using the new units.

In the absence of a VCB.invalidate() method, is there a way to trick a tool into thinking the cursor has moved without actually moving it (e.g. move cursor to same position)?

Thanks.


#5

OK, I’ve come up with a method that works: if you deselect and then reselect the current tool, the VCB is updated:

model=Sketchup.active_model
model.tools.push_tool(nil)  # Refresh VCB
model.tools.pop_tool

Full extension:
toggleConfig.rb (1.3 KB)


Push_tool and pop_tool?
#6

Are you invoking the unit toggle via a shortcut? I’m still a bit unclear on the exact reproduction case here.

Also, have you tried UI.refresh_inspectors? http://ruby.sketchup.com/UI.html#refresh_inspectors-class_method

The Sketchup::View class is very specific to the viewport only. It’s responsibility isn’t the chrome around it.


#7

Yes, I use a shortcut u to switch the units format in “mid-flight” while, for example, measuring or creating geometry. Incredibly useful when working in e.g. feet and inches, and comparing to other dimensional references that switch between them.

Thanks for the suggestion; I tried UI.refresh_inspectors but unfortunately no luck. This method does update drawn dimensions, so it was useful to add. But I could find no method that invalidates VCB and tooltip contents, so I stumbled on this hack to push and immediately pop an invalid tool. Any other options to try for this?


#9

Hm… there’s UI.refresh_toolbar, but that’s an even longer shot than refresh_inspectors.

Could you log a feature request for this in the issue tracker?


#10

That was the 1st thing I tried under Windows as I myself have the VCB docked as a toolbar at the upper left (2nd row) of my toolbar container instead of in the lower right of the status bar. But it does not refresh the VCB !