PrevSelectedObjects not working?


in a script I want to get the object that was used by dimangle.
But it doesn’t return the object:

Rhino.Command “_DimAngle”

arrObjects = Rhino.PrevSelectedObjects

If IsArray(arrObjects) Then
msgbox "Is an array"
msgbox "No array"
End If

In my tests it seem to work because I had an arc selected outside the script before.
In reality it doesn’t work.

What could I do?


No idea vor hint?

Hi Charles,

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"
		msgbox "No array"
	End If

You needed to use “LastCreatedObjects” rather than “PrevSelectedObjects”:
arrObjects = Rhino.LastCreatedObjects

Does that work?

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.

Other ideas?


Assuming the arc was pre-selected for the Rhino.Command to work,

arrObjects = Rhino.SelectedObjects, may work

Hey Charles,

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…


OK, I lied… the following bit of trickery works:

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…


I love it when you’re lying, scriptmaster!


Option Explicit
    'Script version 2013-12-04
    Rhino.AddStartupScript Rhino.LastLoadedScriptFile
    Rhino.AddAlias "DimArcLen", "_NoEcho _-Runscript (DimArcLen)"
    sub DimArcLen()
    	Dim dblLength 
    	Dim DimID
    	Dim strLength
    	Dim arcID
    	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?


Check this topic. Use backticks for code block, instead of preformatted text.

Msgbox "Got it!"