Code:
Option ExplicitSub TextSub()
Dim rootProduct As Product
Dim PartProduct 'As Product
Dim PointCoord(2) 'As Double
Dim PartPos(11) 'As Double
Dim Ergebnis(2) 'As Double
Dim oPart As part
Dim hybridBodies1 As hybridBodies
Dim oHybridBody As hybridBody
Dim ohybridShapePoint 'As HybridShapePointCoord
'Postion des Parts bestimmen
Set rootProduct = CATIA.ActiveDocument.Product
Set PartProduct = rootProduct.Products.Item(1)
PartProduct.Position.GetComponents PartPos
'Koordinaten des Punktes bestimmen
Set oPart = PartProduct.ReferenceProduct.Parent.part
Set hybridBodies1 = oPart.hybridBodies
Set oHybridBody = oPart.hybridBodies.Item("Geometrisches Set.1")
Set ohybridShapePoint = oHybridBody.Hybridshapes.Item("Punkt.1")
ohybridShapePoint.GetCoordinates PointCoord
'Transformation
Call KoordTranformation(PartPos, PointCoord, Ergebnis)
End Sub
Sub KoordTranformation(ArrayPosition(), PointKoord(), ByRef PointKoordTrans())
'Routine um Punktkoordinaten(2) mit einen Catia-Positions-Array(11) zu Transponieren
'für die Rückgabe muss der PointKoordTrans(2) übergeben werden
Dim ArrayTransfromation(3, 3) As Double
Dim ArrayVektor(3) As Double
Dim ArrayErgebnis(3) As Double
Dim i As Integer
Dim j As Integer
'Transformationsmatrx füllen
'1. Spalte
ArrayTransfromation(0, 0) = ArrayPosition(0)
ArrayTransfromation(1, 0) = ArrayPosition(1)
ArrayTransfromation(2, 0) = ArrayPosition(2)
ArrayTransfromation(3, 0) = 0
'2. Spalte
ArrayTransfromation(0, 1) = ArrayPosition(3)
ArrayTransfromation(1, 1) = ArrayPosition(4)
ArrayTransfromation(2, 1) = ArrayPosition(5)
ArrayTransfromation(3, 1) = 0
'3. Spalte
ArrayTransfromation(0, 2) = ArrayPosition(6)
ArrayTransfromation(1, 2) = ArrayPosition(7)
ArrayTransfromation(2, 2) = ArrayPosition(8)
ArrayTransfromation(3, 2) = 0
'4. Spalte
ArrayTransfromation(0, 3) = ArrayPosition(9)
ArrayTransfromation(1, 3) = ArrayPosition(10)
ArrayTransfromation(2, 3) = ArrayPosition(11)
ArrayTransfromation(3, 3) = 1
'Vektor füllen
For i = 0 To UBound(PointKoord)
ArrayVektor(i) = PointKoord(i)
Next
ArrayVektor(3) = 1
'Matrixmultiplikation
For i = 0 To UBound(ArrayTransfromation, 1)
For j = 0 To UBound(ArrayTransfromation, 2)
ArrayErgebnis(i) = ArrayErgebnis(i) + ArrayTransfromation(i, j) * ArrayVektor(j)
Next
Next
'Werte in PointKoordTrans schreiben
For i = 0 To UBound(PointKoordTrans)
PointKoordTrans(i) = ArrayErgebnis(i)
Next
End Sub