Below is the revised code. Apologies for the delay. I have simplified it to only focus on the coordinate transformation. There are two functions and a sub. The two functions involve mathematical calculations, specifically the 3x3 matrix inverse and determinant. You can replace them with your preferred ones if needed. The sub Coord_Transform is responsible for the actual coordinate transformation.
The arguments for the sub are as follows:
1. aRel() As Double: Matrix containing coordinates relative to the CATPart's axis system. These are typically obtained using the GetCoordinates method on a Point. The coordinates are as follows: aRel(0) for X, aRel(1) for Y, and aRel(2) for Z. You may need to convert variant types to double to avoid type mismatch.
2. aAbs() As Double: Matrix containing coordinates relative to the Axis System of the top-level CATProduct. This matrix will be empty initially and will be properly filled by the sub. Once again, the coordinates are aAbs(0) for X, aAbs(1) for Y, and aAbs(2) for Z.
3. oProduct As Product: This refers to the CATPart's Product. For example, if you are measuring the coordinates of "Point.1" in a CATPart named "Part.1", which is the first instance in a CATproduct named "RootProduct", then oProduct=RootProduct.Products.Item(1).
4. bRecursively As Boolean: This is True if you want to calculate the coordinates with respect to the top-level Product, regardless of the depth of your CATPart. It should be False if you want to calculate the coordinates only with respect to the CATPart's father Product.
You can simply paste the code in yours and call the Coord_Transform sub with the appropriate arguments. If needed, there is a similar routine that calculates coordinates considering different Axis Systems in a CATPart using the same matrix transformations. Hope this helps! Regards.
'---CODE START------------------------------------------------------
Function Det3x3(dX11 As Double, dX12 As Double, dX13 As Double, _ dX21 As Double, dX22 As Double, dX23 As Double, _ dX31 As Double, dX32 As Double, dX33 As Double) As Double
'3x3 matrix determinant calculation (direct)
Det3x3 = dX11 * dX22 * dX33 + dX12 * dX23 * dX31 + dX21 * dX32 * dX13 - _ dX13 * dX22 * dX31 - dX12 * dX21 * dX33 - dX23 * dX32 * dX11
End Function
Function Inv3x3(dX11 As Double, dX12 As Double, dX13 As Double, _ dX21 As Double, dX22 As Double, dX23 As Double, _ dX31 As Double, dX32 As Double, dX33 As Double, aInv() As Double) As Boolean
'3x3 matrix inverse calculation (direct)
Dim dDet As Double ReDim aInv(8) Inv3x3 = False dDet = Det3x3(dX11, dX12, dX13, dX21, dX22, dX23, dX31, dX32, dX33) if dDet = 0 Then Exit Function
aInv(0) = (dX22 * dX33 - dX23 * dX32) / Abs(dDet) aInv(1) = (dX13 * dX32 - dX12 * dX33)
' ... (continuing the code with the remaining lines)
End Function
Sub Coord_Transform(aRel() As Double, aAbs() As Double, oProduct As Product, bRecursively As Boolean)
' (continuing the code with the remaining lines)
End Sub"