Convert point's coordinates to a new coordinate system

#1

Hi,
How can I obtain point’s coordinates in a specific coordinate system ?
It seems pretty simple but I can’t find the node to do that.
Thank you

Reading coordinates with respect to newly created coordinate system
#2

Hi @BCochin,

Here is a possible way with python and a custom node :

Convert%20Point%20in%20Coordinate%20Systems

#3

Have you tried comparing the point to the coordinate system’s origin?

3 Likes
#4

Thank you Alban,
This is not what I’m searching for.
I’m looking for a mathematical conversion of the point P coordinates from the general coordinate system (O, x, y, z) to any other coordinate system (A, i, j, k).

#5

Thank you for this proposal. It’s close to what I’m looking for. But your solution works only if coordinate systems are parallel. I’m searching for the general solution.

I was expecting to find something already existing. I will try to code the node, if I can remember my math…

#6

Ok, I made a custom node to do it.



pointRelativeCoordinate.dyf (63.9 KB)

If someone wants to convert it in python to make it faster, feel free … I will probably do it soon or later, but probably later…

1 Like
#7

Here is the python version:

def det(M):
	result = M[0][0]*(M[1][1]*M[2][2]-M[1][2]*M[2][1])-M[0][1]*(M[1][0]*M[2][2]-M[1][2]*M[2][0])+M[0][2]*(M[1][0]*M[2][1]-M[1][1]*M[2][0])
	return result

ptP = IN[0]
cs = IN[1]

pI, pJ, pK = ptP.X, ptP.Y, ptP.Z
aI, aJ, aK = cs.Origin.X, cs.Origin.Y, cs.Origin.Z

vecAP=[pI-aI, pJ-aJ, pK-aK]
vecU=[cs.XAxis.X, cs.XAxis.Y, cs.XAxis.Z]
vecV=[cs.YAxis.X, cs.YAxis.Y, cs.YAxis.Z]
vecW=[cs.ZAxis.X, cs.ZAxis.Y, cs.ZAxis.Z]

M=[vecU, vecV, vecW]

M1=[vecAP, vecV, vecW]
M2=[vecU, vecAP, vecW]
M3=[vecU, vecV, vecAP]

pU=det(M1)/det(M)
pV=det(M2)/det(M)
pK=det(M3)/det(M)

OUT = [pU, pV, pK]


pointRelativeCoordinatePython.dyf (17.2 KB)

1 Like
#8

Glad you solved it. For cases where the CS is not parallel, you could actually use the override for the Geometry.Transform node, feeding the identity transform as the context:

Under the hood it would do similar math

#9

Hi,
I am unable to open this file. An error message saying “Error opening corrupted file” appears.

Please guide me in rectifying this

Thank you

#10

I am not able to find some of the nodes in dynamo such as ‘pointRelativeCoordinate’ and ‘displayCoordinatesystem’. Should I install any package for it? I am not able to open the .dyf file also as it gives a message that the file is corrupted.

I am new to dynamo and Revit. Please help me with this problem.

Thank you

#11

Hi,
.dyf files are custom nodes that you need to load in your own library. I haven’t build any package so you have to install them manually.
This is pretty simple :

  1. download the file
  2. copy/paste in your directory C:\Users%YourName%\AppData\Roaming\Dynamo\Dynamo Revit\2.0\definitions (there may already be some dyf files in this directory)
  3. restart Dynamo

displayCoordinateSystem.dyf (36.9 KB)
pointRelativeCoordinate.dyf (63.9 KB)
pointRelativeCoordinatePython.dyf (17.2 KB)

#12

Thank you !
It was a great help