I find myself wanting to get some measurements it both Imperial and Metric. I can set alternate unites in '_Dimensions but not '_Distance.
Hi -
You’ll need to run the command twice. You could set up a macro to do that with click or alias.
-wim
I’m not understanding how that works? Running the distance command twice just gives me the same distance twice, e.g. 25.4mm, in what ever units I’m working. When I want something like, 25.4mm [1"] Obviously I’m missing something?
I believe you would need to change the units and then re-run the distance command to have it reported back in your unit of choice. Is it possible to have an ai bot running that would then automatically tell you what the alternate units are?
Thanks all. I guess it’s probably more effort that it’s worth. I was hoping for an “alternate units” check box, or maybe a simple script.
macro for document-units
-_distance _units="Model_ Units"
Millimeters independent from document settings
-_distance _units=Millimeter
Inches independent from document settings
-_distance _units="Decimal_ Inches"
my guess this is what wim meant by running twice / set up macro
You can then chain those two macros but you’d want to throw in a None in front to deselect all before running the commands.
-wim
you mean
selNone
![]()
None works just the same.
Still not understanding. Where does “none” go? Before -_distance _units=Millimeter
before -_distance _units="Decimal_ Inches"
Before both? Neither works for me? I’m trying to get a one click process. Distance, pick points, result shows both measurements.
I have no idea how to do this in the macro editor. Copy and paste of the commands does not work. I assume there is syntax I’m missing?
Hi -
That doesn’t work with a macro. This simply chains commands, so you would have to pick the same two points one time for each unit. Also, I now see that the command actually lets you change the option with a preselection, so None is not needed. You have an extra space between Decimal_ and Inches that shouldn’t be there.
-wim
Thanks for trying to help. It still doesn’t work for me. This is what I have in the Macro editor:
-_distance _units=Millimeter
-_distance _units=“Decimal_Inches”
It only runs the first MM line. I thought maybe I shouldn’t have the quotes on decimal inches, but removing them just runs that command and ignore the mm.
If I can’t have one click, what would suffice would be a macro that would run the first distance Millimeter command, and after the measurement, the next response would be a toggle to then run the inches Distance command, or exit. Is that something that could be done? Not by me of course, I can’t code any of this. I tried using the internet and got this which also does not work. ![]()
! _-Units _DistanceDisplay _DistanceType Decimal _DistanceDisplayPrecision 4 _Enter _EnterEnd
_-Distance _Pause _Pause
_If _Pause "Run again in Inches"
_-Units _DistanceDisplay _DistanceType FeetAndInches _DistanceFractionalDisplay Decimal _Enter _EnterEnd
_-Distance _Pause _Pause
_Else
_Exit
_End
Here is a macro containing RhinoScript that outputs both units inline as so:
_NoEcho ! _-RunScript (
Call Distance_DualUnits()
Sub Distance_DualUnits()
Const rhUnitMillimeters = 2
Const rhUnitInches = 8
Dim intSystem
Dim arrPoint1, arrPoint2, dblDistance
intSystem = Rhino.UnitSystem
If Not ((intSystem = rhUnitMillimeters) Or (intSystem = rhUnitInches)) Then
Rhino.MessageBox "Model units not supported", 0, "Error"
Exit Sub
End If
arrPoint1 = Rhino.GetPoint("First point for distance")
If Not IsArray(arrPoint1) Then Exit Sub
arrPoint2 = Rhino.GetPoint("Second point for distance", arrPoint1)
If Not IsArray(arrPoint2) Then Exit Sub
dblDistance = Rhino.Distance(arrPoint1, arrPoint2)
If IsNull(dblDistance) Then Exit Sub
Dim intPrecision: intPrecision = Rhino.UnitDistanceDisplayPrecision
Dim dblMulitplierForUnit(1), strUnitSymbol(1)
dblMulitplierForUnit(0) = 1.0
If Rhino.UnitSystem = rhUnitMillimeters Then
dblMulitplierForUnit(1) = 1 / 25.4
strUnitSymbol(0) = " mm"
strUnitSymbol(1) = """"
Else
dblMulitplierForUnit(1) = 25.4
strUnitSymbol(0) = """"
strUnitSymbol(1) = " mm"
End If
Dim arrComponentSymbol(4)
arrComponentSymbol(2) = "dx"
arrComponentSymbol(3) = "dy"
arrComponentSymbol(4) = "dz"
Dim c 'Point component (x, y, z) per Rhino.Angle output
Dim arrAngle(1)
Dim intCS 'Coordinate system
Dim arrDeltaStrings(2)
intCS = 0 'CPlane
arrAngle(intCS) = Rhino.Angle(arrPoint1, arrPoint2, False)
arrDeltaStrings(intCS) = "CPlane angles:" & vbTab & " "
arrDeltaStrings(intCS) = arrDeltaStrings(intCS) & "xy = " & FormatNumber(arrAngle(intCS)(0), intPrecision,,, False)
arrDeltaStrings(intCS) = arrDeltaStrings(intCS) & " elevation = " & FormatNumber(arrAngle(intCS)(1), intPrecision,,, False) & vbCRLF
arrDeltaStrings(intCS) = arrDeltaStrings(intCS) & "CPlane deltas:" & vbTab
For c = 2 To 4
arrDeltaStrings(intCS) = arrDeltaStrings(intCS) & " " & arrComponentSymbol(c) & " = " & FormatNumber(arrAngle(intCS)(c) * dblMulitplierForUnit(0), intPrecision,,, False) & strUnitSymbol(0) & " ["
arrDeltaStrings(intCS) = arrDeltaStrings(intCS) & FormatNumber(arrAngle(intCS)(c) * dblMulitplierForUnit(1), intPrecision,,, False) & strUnitSymbol(1) & "]"
Next
intCS = 1 'World
arrAngle(intCS) = Rhino.Angle(arrPoint1, arrPoint2, True)
arrDeltaStrings(intCS) = "World angles:" & vbTab & " "
arrDeltaStrings(intCS) = arrDeltaStrings(intCS) & "xy = " & FormatNumber(arrAngle(intCS)(0), intPrecision,,, False)
arrDeltaStrings(intCS) = arrDeltaStrings(intCS) & " elevation = " & FormatNumber(arrAngle(intCS)(1), intPrecision,,, False) & vbCRLF
arrDeltaStrings(intCS) = arrDeltaStrings(intCS) & "World deltas:" & vbTab
For c = 2 To 4
arrDeltaStrings(intCS) = arrDeltaStrings(intCS) & " " & arrComponentSymbol(c) & " = " & FormatNumber(arrAngle(intCS)(c) * dblMulitplierForUnit(0), intPrecision,,, False) & strUnitSymbol(0) & " ["
arrDeltaStrings(intCS) = arrDeltaStrings(intCS) & FormatNumber(arrAngle(intCS)(c) * dblMulitplierForUnit(1), intPrecision,,, False) & strUnitSymbol(1) & "]"
Next
Rhino.Print arrDeltaStrings(0)
Rhino.Print arrDeltaStrings(1)
Rhino.Print "Distance = " & FormatNumber(dblDistance, intPrecision,,, False) & strUnitSymbol(0) & " [" & FormatNumber(dblDistance * dblMulitplierForUnit(1), intPrecision,,, False) & strUnitSymbol(1) & "]"
End Sub
)
_Echo
First point for distance
Second point for distance
CPlane angles: xy = 53.38110 elevation = 25.42399
CPlane deltas: dx = 48.72995" [1237.74079 mm] dy = 65.56974" [1665.47131 mm] dz = 38.83335" [986.36714 mm]
World angles: xy = 53.38110 elevation = 25.42399
World deltas: dx = 48.72995" [1237.74079 mm] dy = 65.56974" [1665.47131 mm] dz = 38.83335" [986.36714 mm]
Distance = 90.45456" [2297.54588 mm]
Thanks so much. It now works in the Macroeditor. How do I assign it to an alias? There is no save in the macro editor.
- Save
Distance_DualUnits.rvb (3.3 KB)
to where Rhino can find it per Linking to external scripts - Create an alias using this macro:
_NoEcho ! _-RunScript ( If Not Rhino.IsProcedure("Distance_DualUnits") Then Call Rhino.Command("_-LoadScript Distance_DualUnits.rvb", 0) : Call Distance_DualUnits Else Call Distance_DualUnits) _Echo
(This macro uses on-demand loading.)
Thanks so much. I have it working now!
Hi @spb
One problem with this is that it only works if you are in mm or inches templates if you are in the “foot template” rhino reports an error: “Model units not supported”.
I forgot how to get around this but you did in your other script, “CustomDistanceMeasurement.py”. Incidentally I have the same script but with different formatting and the one reason I didn’t post it was due to the template problem. Maybe it works in V8 I’m using V7.
Thanks for posting, I also enjoy using your custom Distance measurement script.
RM
That’s not mine: Cannot ‘Distance’ Imperial units when Model is in Metric - Rhino / Rhino for Windows - McNeel Forum
It also works in V8 but appears to report only in a single unit, somewhat similar to _Distance.
If your model units are feet, what do you want the secondary units to be, or does it vary?


