Servus
Ich bin ein gutes Stück weiter gekommen. Mit Hilfe eines aufgezeichenten Makros konnte ich nachvollziehen wie ein Replay erzeugt wird.-> siehe Anhang1
Zuerst werden die Mechanismuselemente durchnummeriert. Danach wird zur jeden Nummer und Timestep die Transformationsmatrix zugewiesen.
Mein Problem ist im Moment, dass ich die wirre Nummerierung der Mechanismuselemente nicht nachvollziehen kann. Derzeit nummeriere ich die Gelenke etc. wie im Baum durch und weise zu jedem Zeitschritt die aktuelle Transformationsmatrix dem Replay zu.
Ich kann mir mit Hilfe des Mechanismanalyse eine .txt herauschreiben. Darin kann ich die wirre Zuordnung bzw. Abfolge nachvollziehen.
Jetzt bentötige noch einen Befehl wie ich einen SuchString "D *Zahl* A" in einem String z.b. "blablabala 1235415 D 20 A bla bla bla" finde.
@Bernd: Sry für die späte Anwort, ich hatte zwei Gleittage. Nach Rücksprache mit meinem Chef kann ich das Skript nun einstellen.
'_____________________________________________________
Public replay1
Sub CATMain()
Dim productDocument1
Dim simulationWorkbench1
Dim KinematicsWorkbench1
Dim replayWorkbench1 As Workbench
CATIA.StartCommand ("Simulation with Commands")
'CATIA.ActiveWindow.Close
Set productDocument1 = CATIA.ActiveDocument
Dim RootProd As Product
Set RootProd = CATIA.ActiveDocument.Product
Set simulationWorkbench1 = productDocument1.GetWorkbench("SimulationWorkbench")
Set KinematicsWorkbench1 = productDocument1.GetWorkbench("KinematicsWorkbench")
Set replayWorkbench1 = productDocument1.GetWorkbench("ReplayWorkbench")
Dim MyDressups As Dressups
Set MyDressups = RootProd.GetTechnologicalObject("Dressups")
Dim mechanism1
Set mechanism1 = KinematicsWorkbench1.Mechanisms.Item(1)
Dim filein As File
Dim Datei As String
Dim DStrom As TextStream
Datei = CATIA.FileSelectionBox("Datei auswählen", "*.txt", CatFileSelectionModeOpen)
If Datei <> "" Then
Set filesys = CATIA.FileSystem
Set filein = filesys.GetFile(CStr(Datei))
Set DStrom = filein.OpenAsTextStream("ForReading")
Dim Index() As String
Dim i As Integer
i = 0
Do While DStrom.AtEndOfStream = False
Dim Zeile1 As String
Zeile1 = DStrom.ReadLine
i = i + 1
Loop
ReDim Index(i) As String
i = 0
Set DStrom = filein.OpenAsTextStream("ForReading")
Do While DStrom.AtEndOfStream = False
Dim Zeile As String
Zeile = DStrom.ReadLine
Index(i) = Zeile
i = i + 1
Loop
End If
Dim oMovingPart
Set oMovingPart = mechanism1.GetProduct(1)
Dim MechanikCommands
Set MechanikCommands = mechanism1.Commands
Dim AnzahlCommands
AnzahlCommands = MechanikCommands.Count
Dim Command()
Dim ResetCommand()
ReDim Command(AnzahlCommands - 1)
ReDim ResetCommand(AnzahlCommands - 1)
For i = 0 To AnzahlCommands - 1
ResetCommand(i) = 0
Next
mechanism1.PutCommandValues ResetCommand
mechanism1.Update
j = 0
For i = 0 To (2 * AnzahlCommands) - 1
Command(j) = Index(i)
i = i + 1
j = j + 1
Next
Dim CommandDouble()
ReDim CommandDouble(AnzahlCommands - 1)
For j = 0 To AnzahlCommands - 1
CommandDouble(j) = CDbl(Command(j))
Next
Dim replays1 As Replays
Set replays1 = replayWorkbench1.Replays
Set replay1 = replays1.Add("Replay.1")
Dim product1 As Product
Set product1 = productDocument1.Product
Dim products1 As Products
Set products1 = product1.Products
Dim rotmatrix As Variant
ReDim rotmatrix(oMovingPart.Parent.Count, 11)
Dim zaehler As Integer
zaehler = oMovingPart.Parent.Count
Dim curLong As Variant
ReDim curLong(oMovingPart.Parent.Count)
Dim curProduct As Object
Dim curRotmatrix(11)
Dim resetRotmatrix(11)
For i = 0 To 11
resetRotmatrix(i) = 0
Next
Dim TimeStep As Double
TimeStep = 2
m = 1
For n = 0 To TimeStep - 1
For i = 1 To oMovingPart.Parent.Count
If (i = 54) Then
Else
curLong(i) = replay1.AddProductMotion(oMovingPart.Parent.Item(i))
Set curProduct = oMovingPart.Parent.Item(i).Position
curProduct.GetComponents curRotmatrix
For k = 0 To 11
rotmatrix(i, k) = curRotmatrix(k)
Next
replay1.AddSample curLong(i), TimeStep, curRotmatrix
m = m + 1
End If
Next
mechanism1.PutCommandValues CommandDouble()
mechanism1.Update
Next
End Sub
'___________________________________________________
Grüße
Andreas
[Diese Nachricht wurde von AierMandi am 08. Feb. 2013 editiert.]
[Diese Nachricht wurde von AierMandi am 13. Feb. 2013 editiert.]
[Diese Nachricht wurde von AierMandi am 13. Feb. 2013 editiert.]
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP