Getting Point coordinates [python]

That’s cool! :slight_smile:

Hi all @Helvetosaur @ivelin.peychev @Willem @jesterking , I wrote this code to get the X coordinate of the point in GH Python, but instead of I am getting an error. I have used this method earlier, but it seems to be not working here. Why? Any solutions or tips? Please. Thanks in advance.

The code is below,

c = rs.AddPoint(300,50,0)
print c.X

Error is,

Runtime error (MissingMemberException): ‘Guid’ object has no attribute ‘X’

line 44, in script

c will be the GUID of the point object you created using AddPoint(), not the point coordinates. Outside of GH you would need to use something like pt=rs.coerce3dpoint(c) to get the point3d object, which would then work with pt.X to get you the X coordinate.

Many people use AddPoint() incorrectly, it’s only designed for adding a point object to the Rhino document and returning its GUID, and many times you don’t need to do that, you just need the real point3d object which has coordinates as part of its properties.

You are working in GH? What is the input in this case?


Hi, @Helvetosaur thanks for the quick reply. I am working with GH. I am generating the points as a list, and try to get the X coordinates from them, only while I call it with an if function. rs.CreatePoint(x,y,z) worked. Thanks.

Could you expand on the right method to use then? Say, I want to create points using a loop and connect them later with a line? No need to draw the points individually.

Do you have any resources on getting the basics of geometry in Rhino Python (not GH). I am learning, but spending soooo much time on searching online for even the most basic answers to drawing simple geometry. Sorry, but the 101 is not much help to a beginner…

There are two ways to create a 3d point object:

  1. rhinoscriptsyntax

  2. RhinoCommon

import rhinoscriptsyntax as rs

for i in range(10):
    #create a 3d point
    #append it to the list
#add polyline

or maybe to make a segmented circle with 24 points…

import rhinoscriptsyntax as rs
import math

inc=2*math.pi/count  #math functions work in radians, 2*pi is full circle
#circle parametric formula
for i in range(count):
    #create your 3d point
    #append it to the list
#add first point to end of list (to close circular polyline)
#add polyline

Thank you!!!