Showing results for 
Search instead for 
Did you mean: 

Set objects world coordinates in subframes

Solution Partner Legend Solution Partner Legend
Solution Partner Legend



I am working with objects in sub-sub-frames and similar.

I have a method where I dynamically want to move some objects in the sub-sub-frame to some calculated world-coordinates. I suppose I need to change the objects ._3d.position together with transformationmatrixes, but I do not understand how. 


Greatly appreciates any help!


Re: Set objects world coordinates in subframes


Hi @_Busck 


You will have different coordinate systems, so you'll need to transfer a point from the sub-coordinates systems to their fathers until you get the global coordinates. If you just want to translate an object, you could use:



This expression is written in homogenous coordinates. Anyway, we just need to sum the vector containing the position of the object to be translated with the vector containing how much you want to move it in each direction.


Here is an example (also attached):




There is a Station inside a Frame, and I want to move this Station based on a Global coordinate without moving the Frame. So, we can get the coordinates of the objects with something like this:




So, the absolute Station coordinate is the coordinate of its father plus its relative coordinate.


Now, we can set a new coordinate to the Station as I said above:




Variable t is the translation vector. I am assuming a translation based on the global coordinates, but you can translate any object in any coordinate system as well. Finally, I set the new position of the Station based on this global transformations.


You can also use a rotation matrix, the concept is quite the same. Hope it helps you. Open the attached model and move the frame through space and get all coordinates just to check how the coordinates behave.




Best Regards,
Paulo Araujo

Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.

Re: Set objects world coordinates in subframes

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Thanks for a great explanation! It helped me develop the method I am in need of. 


To conclude, I wanted to set ._3D.getWorldCoordinate easily. This attribute is read-only, so it cannot be simply changed. I think this would be a great enhancement to Plant...


However,  I developed the method setWorldCoordinate(Object : object, Coordinate : length[3])


So I can for example use this syntax:

var station := root.subFrame1.subFrame2.Station2

setWorldCoordinates(station, [10, -18, 0])

--now the station have moved inside it's subframe so 
--station._3D.getWorldCoordinates = [10,-18,0]

If anyone needs the functionality the metod is attached here:

param obj:object, worldPos:length[3]

//This method sets the world position of a object, regardless of where it is placed.
//World-position in this case corresponds to ._3D.getWorldCoordinate.

//set objLoc to the frame the object is currently positioned in
var objLoc:object
objLoc := obj.~
while objLoc.internalClassName /= "Network"
	objLoc := objLoc.~

//calculate .coordinate3D for obj
--subtract world pos with all subframes coordinates
var objPos:length[3]
var objLocPos:length[3]
objLocPos := objLoc.Coordinate3D
objPos := worldPos - objLocPos
--subtract coordinates for one more level:
while objLoc /= root
	objLoc := objLoc.~
	objLocPos := objLoc.coordinate3D
	objPos -= objLocPos

//set .coordinate3D
obj.coordinate3D := objPos

//check so everything works
if obj._3D.getWorldCoordinate /= worldPos
	--something went wrong