# How to refresh VCB when Units change

**URL:** <https://forums.sketchup.com/t/how-to-refresh-vcb-when-units-change/81318>\
**Category:** Ruby API\
**Created:** [November 15, 2018, 10:59pm UTC](https://forums.sketchup.com/t/how-to-refresh-vcb-when-units-change/81318 "2018-11-15T22:59:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![JDTS](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/jdts/32/59066_2.png) [@JDTS](https://forums.sketchup.com/u/JDTS)\
**Post date:** [November 15, 2018, 10:59pm UTC](https://forums.sketchup.com/t/how-to-refresh-vcb-when-units-change/81318/1 "2018-11-15T22:59:48Z")

</div>

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

```auto
   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?

---

<div class="post-metadata">

**Author:** ![JDTS](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/jdts/32/59066_2.png) [@JDTS](https://forums.sketchup.com/u/JDTS)\
**Post date:** [November 19, 2018, 7:57pm UTC](https://forums.sketchup.com/t/how-to-refresh-vcb-when-units-change/81318/2 "2018-11-19T19:57:11Z")

</div>

Just bumping this to see if anyone has ideas.

---

<div class="post-metadata">

**Author:** ![john\_drivenupthewall](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@john\_drivenupthewall](https://forums.sketchup.com/u/john_drivenupthewall)\
**Post date:** [November 19, 2018, 8:10pm UTC](https://forums.sketchup.com/t/how-to-refresh-vcb-when-units-change/81318/3 "2018-11-19T20:10:16Z")

</div>

this works on a mac…

```ruby
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

---

<div class="post-metadata">

**Author:** ![JDTS](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/jdts/32/59066_2.png) [@JDTS](https://forums.sketchup.com/u/JDTS)\
**Post date:** [November 19, 2018, 10:10pm UTC](https://forums.sketchup.com/t/how-to-refresh-vcb-when-units-change/81318/4 "2018-11-19T22:10:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JDTS](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/jdts/32/59066_2.png) [@JDTS](https://forums.sketchup.com/u/JDTS)\
**Post date:** [November 19, 2018, 10:57pm UTC](https://forums.sketchup.com/t/how-to-refresh-vcb-when-units-change/81318/5 "2018-11-19T22:57:29Z")

</div>

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

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

```

Full extension:  
[toggleConfig.rb](https://forums.sketchup.com/uploads/short-url/FD40J0kHr4bp9uUyfwaecYnw9b.rb) (1.3 KB)

---

<div class="post-metadata">

**Author:** ![tt\_su](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tt_su/32/17_2.png) [@tt\_su](https://forums.sketchup.com/u/tt_su)\
**Post date:** [November 26, 2018, 3:23pm UTC](https://forums.sketchup.com/t/how-to-refresh-vcb-when-units-change/81318/6 "2018-11-26T15:23:50Z")

</div>

> [@JDTS](#):
>
> 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.

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`? [Module: UI — SketchUp Ruby API Documentation](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.

---

<div class="post-metadata">

**Author:** ![JDTS](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/jdts/32/59066_2.png) [@JDTS](https://forums.sketchup.com/u/JDTS)\
**Post date:** [November 26, 2018, 4:33pm UTC](https://forums.sketchup.com/t/how-to-refresh-vcb-when-units-change/81318/7 "2018-11-26T16:33:51Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![tt\_su](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tt_su/32/17_2.png) [@tt\_su](https://forums.sketchup.com/u/tt_su)\
**Post date:** [November 28, 2018, 2:00pm UTC](https://forums.sketchup.com/t/how-to-refresh-vcb-when-units-change/81318/9 "2018-11-28T14:00:30Z")

</div>

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?

> **[GitHub - SketchUp/api-issue-tracker: Public issue tracker for the SketchUp...](https://github.com/SketchUp/api-issue-tracker)**
>
> Public issue tracker for the SketchUp and LayOut's APIs - GitHub - SketchUp/api-issue-tracker: Public issue tracker for the SketchUp and LayOut's APIs

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [November 28, 2018, 3:32pm UTC](https://forums.sketchup.com/t/how-to-refresh-vcb-when-units-change/81318/10 "2018-11-28T15:32:20Z")

</div>

> [@tt\_su](#):
>
> Hm… there’s `UI.refresh_toolbar` , but that’s an even longer shot than `refresh_inspectors` .

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 !**
