My work flow involves drawing the model from sources with multiple scales/units and exporting to STL/dxf/… in a different scale/units. I do this with unit changes involving CustomUnits for scale changes. This ends up requiring a whole bunch of rearranging, zooming and dimension scaling to get the layout back, so I finally decided to automate things when the CustomUnits behavior changed a few months ago in Rhino 5 on windows. The attached file is my solution to changing scale/units while preserving layout in case anyone else has this issue.
There are two functions.
SetScale allows changing both scale and units.
ToggleScale switches between the current and last SetScale values.
“Undo” won’t undo the script because it’s doing a bunch of Viewport commands, so the best way of preserving layouts with undo is to SetScale back to the original values, which undoes the Viewport commands, then run “Undo”
“Undo” can mess up the synch between the current scale and the value stored in UserData so there is an option in SetScale called “ResetScaleOnly” to simply change the saved value.
As far as my work flow is concerned, the only thing that doesn’t get properly resized in the view is certain lights. I don’t have plans to fix that unless someone sees a need. If anyone sees other items I’d like to know.
I didn’t opt to change the number of decimal digits in dimensions when changing scale/units like one would see on digital calipers when switching between in/mm. I may change that.
This button macro won’t terminate any running vbscript GetOption
So send ! to the command line to cancel any GetOption before running _ToggleScale/_SetScale
! _-NoEcho _-RunScript (
This won’t help other buttons terminate GetOption, but if used with SetScale and ToggleScale, at least those buttons won’t have clashes with multiple running scripts. Is there a better option here?
- UnitCustomUnitSystem doesn’t seem to be switching the units to custom, so I end up calling UnitSystem to switch to custom units then do the scaling. Is this a bug?
SetScale.rvb (10.1 KB)