Get Points Created in Rhino to an Array in VB Script

I need to select a point I created in vb script through the centroid function 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. This involves converting the ObjectID to a usable format.

Best,
Noah

hi Noah,

I am only guessing since I don’t see your script code, but if you are getting a point object via LastObject, you
need to get it’s coordinates via this method:

Rhino.PointCoordinates
https://developer.rhino3d.com/api/rhinoscript/geometry_methods/pointcoordinates.htm

hth,

–jarek

Hi Jarek,

Thank you for the quick response! I did try using ‘PointCoordinates’ and my code is shown below:

Rhino.command("-_AreaCentroid _SelName fp_surf _Enter")
str_fp_centroid = Rhino.LastObject
arr_fp_cent = Rhino.PointCoordinates(str_fp_centroid)
Rhino.Print Rhino.Pt2Str(arr_fp_cent)

I’m using ‘Print’ just to check if it is doing what I want; however, I get the error that this must be an array, which I thought it was by using ‘PointCoordinates.’ It also will not write to a file.

Thank you,
Noah

Thank you for your help, I have figured it out. Using Rhino.LastObject does not work well with using Rhino commands. I used Rhino.MeshAreaCentroid to find the point combined with PointCoordinates and it is working now.

Noah