hallo rkauskh,
bin nun endlich mal dazu gekommen, dass mit der Matrizenmultiplikation auszuprobieren:
Also bei mir funktioniert meine Gedachte vorgehensweise. Also Positionsmatrix des Bauteils auslesen und dann mit einer Rotationsmatrix drehen.
Hier ist mein Code.
Um den Code zu verwenden folgende Vorgehensweis: Neue Baugruppe, ein Bauteil reinladen (dieses am besten in den Ursprung legen, keine Abhängigkeiten vergeben). Bauteil selektieren und Code ausführen.
Jedes mal wenn der Code ausgeführt wird, wird das Bauteil um 30° um die x-Achse der Baugruppe gedreht.
Public Sub Rot_x()
'Rotation um x-Achse
Dim pi
pi = 4# * Atn(1#)
    'Referenz auf Applikation
    Dim oApp As Application
    Set oApp = ThisApplication
    'Referenz auf Dokument
    Dim oDoc As AssemblyDocument 
    Set oDoc = oApp.ActiveDocument
    
    Dim oTransGeom As TransientGeometry
    Set oTransGeom = oApp.TransientGeometry
    Dim oPosMatrix As Matrix
    Dim oRotMatrix As Matrix
    Set oPosMatrix = oTransGeom.CreateMatrix
    Set oRotMatrix = oTransGeom.CreateMatrix
    
    Dim ss As SelectSet
    Set ss = oDoc.SelectSet
    
    
    'Bauteil aus Selektion:
    Dim oCompOcc As ComponentOccurrence
    Set oCompOcc = ss.Item(1)
    
 
    'Winkel 30°:
    Dim theta As Double
    theta = 30 * pi / 180
    'Postionsmatrix vom Bauteil:
    Set oPosMatrix = oCompOcc.Transformation
    'RotationsMatrix erzeugen:
    Set oRotMatrix = rot_x_Matrix(theta)
    
    'Matrizenmultiplikation:
    Call oRotMatrix.PostMultiplyBy(oPosMatrix)
    
    
    'Bauteil anhand Matrix positionieren:
    oCompOcc.Transformation = oRotMatrix
         
End Sub
Function rot_x_Matrix(theta As Double) As Matrix
'Rotation um x-Achse
Dim oMatrix As Matrix
    Set oMatrix = ThisApplication.TransientGeometry.CreateMatrix
    '1. Spalte
    oMatrix.Cell(1, 1) = 1
    oMatrix.Cell(2, 1) = 0
    oMatrix.Cell(3, 1) = 0
    oMatrix.Cell(4, 1) = 0
    
    '2. Spalte
    oMatrix.Cell(1, 2) = 0
    oMatrix.Cell(2, 2) = Cos(theta)
    oMatrix.Cell(3, 2) = Sin(theta)
    oMatrix.Cell(4, 2) = 0
    '3. Spalte
    oMatrix.Cell(1, 3) = 0
    oMatrix.Cell(2, 3) = -Sin(theta)
    oMatrix.Cell(3, 3) = Cos(theta)
    oMatrix.Cell(4, 2) = 0
    '4.Spalte
    oMatrix.Cell(1, 4) = 0
    oMatrix.Cell(2, 4) = 0
    oMatrix.Cell(3, 4) = 0
    oMatrix.Cell(4, 4) = 1
    
    Set rot_x_Matrix = oMatrix
End Function
Gruss Dennis
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP