I have no knowledge of VBscript, but weren’t you suppose to declare the new variable (arrObjects) first?
Rhino.Command "_DimAngle"
Dim arrObjects
arrObjects = Rhino.PrevSelectedObjects
If IsArray(arrObjects) Then
msgbox "Is an array"
Else
msgbox "No array"
End If
I use lastcreatedobjects to get the created dimension afterwards and that works as expected.
I must get the arc that was selected for dimangle.
And the arc just exists, it was created not as last object.
I don’t think you’re going to make that work… If you do the operation manually, the same thing happens, SelPrev does not select the arc either. And DimAngle does not work with a pre-selected arc unfortunately.
SelPrev only works under certain specific circumstances, for the most part it’s pretty useless…
Option Explicit
Call TestDimAngle()
Sub TestDimAngle()
Dim arcID
arcID=Rhino.GetObject("Select an arc to dimension",4,True,True)
Call Rhino.Command("_DimAngle _SelID "&arcID)
End Sub
You always have access to the arc object as it is stored in the variable arcID…
Option Explicit
'Script version 2013-12-04
Rhino.AddStartupScript Rhino.LastLoadedScriptFile
Rhino.AddAlias "DimArcLen", "_NoEcho _-Runscript (DimArcLen)"
'DimArcLen
sub DimArcLen()
Dim dblLength
Dim DimID
Dim strLength
Dim arcID
SetLocale("en-us")
Call Rhino.UnselectAllObjects
arcID = Rhino.GetObject("Select an arc to dimension", 4, True, True)
If Not Rhino.IsCurve(arcID) Then Exit Sub
Call Rhino.Command("_DimAngle _SelID " & arcID)
If rhino.LastCommandResult <> 0 Then Exit Sub
DimID = Rhino.LastCreatedObjects()(0)
If Not Rhino.IsAngularDimension(DimID) Then Exit Sub
dblLength = Rhino.CurveLength(arcID)
strLength = "L="
strLength = strLength & formatnumber(dblLength, 2)
strLength = strLength & "mm"
Rhino.DimensionUserText DimID, strLength
end sub
Thank you very much Mitch!!!
Q: How do you get the syntax highlighting into the message?