Python: Corner to Center


(Edward) #1

I want to try to shorten a grasshopper route with python. But, how?
I cannot get the 3D-coordinates of the corner-point somehow, what am I doing wrong?

python corner to center (7.3 KB)

(Martinspence84) #2

Hey @Edward,
I think you misspelled the method you are trying to call. It should be PointCoordinates, and I also think you should revise your input.
See here for further info:

(Edward) #3

Thank you for your response.
Do you also know how to add values (sum)?

Sum or math.fsum does not work.

python corner to center (8.7 KB)

(Martinspence84) #4

Check out the error you are getting. The fsum() only takes one argument, and you are feeding it two :-).

You could put them in a list to get around this:

>>> x = 10
>>> y = 43.5929
>>> sum([x,y])
>>> import math
>>> math.fsum([x,y])

Sorry for the snippet. I don’t have access to R3D/GH atm.

(Matt Gaydon) #5

Another way to make it smaller without using Python, just makes it as an expression. (5.7 KB)

(Edward) #6

Somehow, I cannot stich the values together as a coordinate.
Do you know what I am doing wrong?

python corner to center (8.6 KB)


You should try :

center = rs.AddPoint(Xcenter, Ycenter, Zcorner)


You can also create a text string that the point component will “understand”.

center = "{"+str(Xcenter)+","+str(Ycenter)+","+str(Zcorner)+"}"

But this doesn’t create a point, only a comprehensive string.

(Edward) #9

Thank you! :smile: :