Get Objects Group Name

If I have a group selected with “Rhino.LastObject” how can I get the name of the selected Group, using Rhinoscript. This isn’t working


	strObject = Rhino.LastObject

	If Not IsNull(strObject) Then

		strGroup = Rhino.ObjectTopGroup(strObject)

		If Not IsNull(strGroup) Then

Thanks Mark.

Doesn’t matter I figured it out. I found that running Sellast at the command line and Rhino.LastObject were not selecting the same object for some reason. Using Rhino.Command(“Sellast”) works though.

Mark

Rhino.LastObject is actually the first object added to the file (last item in the object table which is in chronological order). Rhino.FirstObject is actually the most recent object added to the document.

However if you want the last objects created by an operation, it is Rhino.LastCreatedObjects().

HTH, --Mitch

I need to select a point I created in vb script and both get its coordinates to print to a text file and find a distance between it and another point without using the command line in Rhino.

Using ‘Rhino.LastObject’ worked for selecting a surface and finding its area but for some reason keeps telling me it’s in the wrong format using points. Any help would be much appreciated.

Best,
Noah

I assume this was answered by Jarek in your other post…

It was for the most part, yes. I am still having confusion with the difference between First and Last Object. I have used Last Object in my brief experience of Rhino Script as the most recent object I have created or modified and it has worked for me. However, it seems now that I should be using First Object in this case. I am confused on the difference and when to use each.

No, contrary to what you might believe, FirstObject is the most recently created object, because objects are treated as a ‘stack’, the most recent being ‘on top’.

image

LastObject is the oldest object in the file because it’s on the bottom of the ‘stack’

image

If you are creating objects via scripting Rhino.Command(), you should be using Rhino.LastCreatedObjects() just after running your Rhino.Command(), it will be an array of any objects that were created. If the result is null, then something went wrong with the command…

Oh, and it’s actually pretty rare to need to use either FirstObject or LastObject. In general if you are creating things with Rhinoscript methods, the newly created object ID’s are output by the method already.