Changing units with one click

units
mac

#1

Here’s the issue:

Like most of the world, I work in metric and usually in mm. However, there are times when it is much better to be working in metres. It’s not difficult to change the units in Model Info and back again but it would be handy to have a shortcut that toggled between the two.

On a Mac, you have the option of Services under the Sketchup menu. I believe this enables you to write a small macro that could have a function key as the instigator. This could presumably invoke the Model Info dialog box and change the units. You would also have to change the precision because you don’t generally want precision of greater than 1mm when working in mm but you do generally want at least two decimal places when working in metres. Ideally, hitting the designated function key would swop you back but at worst case you would have to have two separate routines with different function keys. That would also enable you to build in the closing of the Model Info dialog box if you wanted.

Why do I need such a thing? Well, if I want to know the volume of foundation concrete (say), I find it hard reading 9 or 10 digits without any separators and trying to work out where the decimal point should be for reading in metres.

Of course, all this could also be achieved by SU having the alternative metre reading in the Entity Info box, but until then…

Does anyone know how to write the necessary macro? Or even know if it is possible?


#2

It’s doable.
There a comprehensive [old-but-working] plugin:
https://sketchucation.com/pluginstore?pln=Matt_Toggle_Units
It has a toolbar and a menu you could shortcut to…
Is this sufficient ?
It’s perhaps more complicated that you want ?


#3

It would be possible in Applescript (Mac only) as a UI Script, but you’d see the Model Info dialog appearing and the settings changing before your eyes as if someone had taken over your computer. Sometimes this is the only way to do things in a script, like I have scripts to turn on/off the mouse hot corners. This is easier in Ruby. Here’s a simple script that only has your two options of mm with no decimal places or metres with 2 places of precision. It’s only 50 lines and it is not encrypted, so you can change the settings to suit.

UnitSwitch.rbz (1.0 KB)

Go to Tools Menu > Unit Switch > millimetres or metres:
UnitSwitch%20Menu

Search for metres to set the shortcuts:
UnitSwitch%20Shortcuts


#4

Dynamic components.

If you create a component for the thing you are investigating, you can undertake any number of useful calculations using component attributes. I use this to calculate floor areas in m2, capacity of rooms etc.

The attributes can be a little awkward to initially set up, however I now have a template component which can be dropped into the model. This allows quick copying and pasting of attributes. eg: =ROUND(FACEAREA()/2*2.54 *2.54/10000,0) calculates the area of a flat rectangle, drawn in mm, and reports the value back in m2 to zero decimal places. Similarly, I can calculate capacity, or add attributes for cost/m2 and calculate overall costs per zone of the building.

There are others standard functions listed at https://help.sketchup.com/en/article/114561


#5

Isn’t this forum a wonder? Within hours of posting, a multitude of possible solutions. Lots of good ideas but I chose @McGordon’s for its simplicity and closeness to what I was after. It is now installed and working. Thanks mucho!

The beauty of this is that it not only affects the Entity Info display but also controls how dimensions are shown.

Surely that’s worth publishing as an official SU extension?