Python - Get Coordinate from point

Hi,

I need to get the coordinate of a point.

The result I get with my script is:

<Autodesk.DesignScript.Geometry.Point object at 0x0000000000004B23 [Point(X = -11.987, Y = 15.666, Z = 10.000)]>]

But I need:

(X = -11.987, Y = 15.666, Z = 10.000)

How can I get this?

Thank you in advance!

Can you show us how you’re getting this output? It looks more like a string than an object.

for room in rooms:
    #t.Start()
    room_loc = room.Location.Point
    boundaries = room.GetBoundarySegments(SBO)
    segGroup = []
    for bound in boundaries:
        pGroup=[]
        cLoops=[]
        for seg in bound:
            pGroup.append(seg.GetCurve().GetEndPoint(0).ToPoint())
   print(pGroup)

Ah. Looks like you’re using print instead of OUT. Print will log the output to the console. OUT will return the objects at the python node.

3 Likes

I am not using dynamo actually. I am running directly with python. Maybe that´s the problem.

Hmm. It’s still weird that it returns a description of the object.
Try printing the points individually instead of as a list.
image

I did that but the ouput is:
Point(X = -11.987, Y = 17.666, Z = 2.500)

image

I need:
(-11.987, 17.666, 2.500)


for room in rooms:
    #t.Start()
    room_loc = room.Location.Point
    boundaries = room.GetBoundarySegments(SBO)
    segGroup = []
    print(room_loc)
    for bound in boundaries:
        pGroup=[]
        cLoops=[]
        for seg in bound:
            pGroup.append(seg.GetCurve().GetEndPoint(0).ToPoint())
            for p in pGroup:
                print(p)

You should just need to convert them to Revit XYZs.

1 Like

I got it.

I need to append:

 pGroup.append(seg.GetCurve().GetEndPoint(0))

and not

 pGroup.append(seg.GetCurve().GetEndPoint(0).ToPoint())
for room in rooms:
    #t.Start()
    room_loc = room.Location.Point
    boundaries = room.GetBoundarySegments(SBO)
    segGroup = []
    print(room_loc)
    for bound in boundaries:
        pGroup=[]
        cLoops=[]
        for seg in bound:
            pGroup.append(seg.GetCurve().GetEndPoint(0))
            for p in pGroup:
                print(p)

This way I get: (-11.987, 17.666, 2.500)

Makes sense, obviously. :open_mouth:

Thanks for your help Nick :slight_smile:

3 Likes

Hello,
Out of curiosity you can reveal your beginning of code
it appears to be a memory stored object returned every time with the class
(I’m not strong, the terms are not necessarily the right ones)

cordially
christian.stan