I am aware how to find transformation matrix using API for a component of assembly using Toolkit.
Is this possible to find transformation matrix between two csys using Toolkit API? If yes, what should be the API or approach for same.
Any thought will be of great help.
Thanks and Regards
Solved! Go to Solution.
A cursory online search finds that there doesn't seem to be a function in the Toolkit API to calculate a transformation matrix. So, you'll likely have to delve into the linear algebra necessary to write your own function, or there is probably a linear matrix algebra library available for your language. You'll just have to find a non-toolkit solution.
In Creo Toolkit you can get the transformation matrix for
1. Assembly to Part / Part To Assembly (CSYS) usingProAsmcomppathTrfGet
2. Drawing sheetProDrawingSheetTrfGet
I figured it might be simple enough to use the mathematical libraries that have matrix manipulation routines, since the results I found on a search seemed to indicate that a simple "get transformation matrix" function wasn't evidently available. I also didn't know what language the initial poster was using. I've written such routines in the past and it's nothing very difficult when we're dealing with three dimensions.
Matrix wise it's just dividing the A matrix by the F matrix to get the transformation matrix from A to F to get T (or F to A?). Apparently this is determined by multiplying the A matrix by the inverse of the F matrix (or the F matrix by the inverse of the A matrix) You'll have to check to see which solution is the one that you will apply, but since multiplying A by T = F, it is easy to see that it's done right.
This seems like a good start: https://www.wikihow.com/Divide-Matrices
My experience is that the linear algebra for this stuff can be a bit of a pain, and as others have mentioned, it definitely requires a bit of attention to detail.
For example, coordinates returned via ProCsysDataGet() (or pfcCoordSystem_ptr->GetCoordSys() in OTK) returns the coordinates in a way that I typically find to be the exact OPPOSITE of what I typically need, so I almost always end up needing to take the inverse of the matrix.
Similarly, ProAsmcomppathTrfGet is useful to get the transformation from the "desired part" to the "top assembly"... but its never quite that simple.
I often find that if I need to find how "CSYS A" in "Y.PRT" is related to "CSYS B" in "Z.PRT", often times I need to run through the logic of:
FYI - there ARE some free libraries out there like Eigen and Ogre3D which can help with some of the heavy lifting. I can't say I've ever used them... but I've certainly thought about it several times 🙂
Hope this helps!