Hi,
I have my rhino set to decimal inches and I use vbscripts to quickly measure in other units without having to click in the command line, this way I can stay in decimal inches and check any other unit type quickly, however I find that something has changed and my scripts no longer work properly.
The Vb unit script below was working just fine but after upgrading to Sr 19 no longer works. I get unknown command instead of the units printed on the command line.
-RunScript (
Sub DisplayDistanceIn
Dim setunits,dblDistance
setunits = Rhino.UnitSystem (,false)
Rhino.UnitDistanceDisplayMode 2,true
Rhino.command "_Distance"
Rhino.UnitDistanceDisplayMode setunits,true
End Sub
DisplayDistanceIn
)
Here’s another example. I’m in decimal and choose fractional in the dialog box the fractional unit doesn’t print to the command line. Seems the distance command is acting differently. Beneath the script is the command history, seems like the distance command gets parsed differently in this vbscript syntax.
-RunScript (
Sub DisplayDistanceDecFracFtIn
Dim arrunits(2), strResult,intUnitSystem,setunits
setunits = Rhino.UnitSystem (,false)
arrunits(0) = "Decimal"
arrunits(1) = "Fractional"
arrunits(2) = "Feet and Inches"
strResult = Rhino.ListBox(arrunits, "Show distance in?","Display Unit Options")
If strResult = "Decimal" Then
Rhino.UnitDistanceDisplayMode 0,true
Rhino.command "_Distance"
Rhino.UnitDistanceDisplayMode setunits,true
Else
If strResult = "Fractional" Then
Rhino.UnitDistanceDisplayMode 1,true
Rhino.command "_Distance"
Rhino.UnitDistanceDisplayMode setunits,true
Else
If strResult = "Feet and Inches" Then
Rhino.UnitDistanceDisplayMode 2,true
Rhino.command "_Distance"
Rhino.UnitDistanceDisplayMode setunits,true
End If
End If
End If
End Sub
DisplayDistanceDecFracFtIn
)
DisplayDistanceDecFracFtIn
)
From the command history after command is run:
Subroutine to run ( List ): _Distance
First point for distance ( Units=Model_Units )
Second point for distance ( Units=Model_Units Undo )
CPlane angles and deltas: xy = -54.36845 elevation = 0.00000 dx = 3 11/32 dy = -4 11/16 dz = 0
World angles and deltas: xy = -54.36845 elevation = 0.00000 dx = 3 11/32 dy = -4 11/16 dz = 0
Distance = 5 3/4
Second point for distance ( Units=Model_Units Undo ): 5
Unknown command: 5
Command: _CommandHistory
Hi Roland,
I see this - I tried testing your first example - but I have no idea why…
I also tried to test in Python rhinoscriptsyntax, but unfortunately, there is no method rs.UnitDistanceDisplayMode() in rhinoscriptsyntax. The Help indicates there should be, but this is probably because the rhinoscriptsyntax help has just been pulled for the most part out of the Rhinoscript help. @dale
I’m not fluent enough in RhinoScript to tell you why your script fails, but I found the corresponding Rhinocommon methods and made a quick python script which should do the functionality you are describing:
Hi Mitch, Jarek,
Thanks to both of you for taking look and for confirming it. Hope it’s and easy fix for McNeel I have many more unit scripts that I use especially my custom unit scripts.
RM