Danke nochmal für dein immer schnelle Antworten.
Die Ersetzen habe ich schon gemacht. Jetzt muss ich nur die einzelne Elemente zussamen verknüpfen. Bisher läuft mein Code ohne Fehlern, aber es macht kein Referenez zu den Elementen.
Hier ist mein ganzes Code nochmal:
Sub CATMain()
Dim oSourceDoc As PartDocument
Dim oTartgetDoc As PartDocument
Dim oSelSource As Selection
Dim oSelTarget As Selection
Dim oSourcePart As Object
Dim oTartgetPart As Part
Dim sPathToFile as String
'Upload IGS File
msgbox" Upload IGS File from Autodesk Inventor"
strFilePath = CATIA.FileSelectionBox("Select .IGS Vermessung File", "*.igs", 0)
'Set objProd = objCATIA.Documents.Open("strFilePath")
'öffnen
CATIA.Documents.Open(strFilePath)
Set oSourceDoc = CATIA.ActiveDocument
Set oSelSource = oSourceDoc.Selection
Set oSourcePart = oSourceDoc.Part
'kopieren
oSelSource.Clear
oSelSource.Add oSourcePart.HybridBodies.Item(1)
oSelSource.Copy
'Geoset in Hauptfile löschen
msgbox" Upload Gabel CATIA Part File"
sPathToFile = CATIA.FileSelectionBox("Select Gabel Vermessungen File CATIA Part", "*.CATPart", 0)
CATIA.Documents.Open(sPathToFile)
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set hybridBodies1 = part1.HybridBodies
Set hybridBody1 = hybridBodies1.Item("Input Vermessung")
Set hybridBody2 = hybridBodies1.Item("Output Fahrgeometrie")
'Adding copied File from IGS File
Dim selection2 As Selection
Set selection2 = partDocument1.Selection
Set objSel2 = CATIA.ActiveDocument.Selection
Set objPart2 = CATIA.ActiveDocument.Part
selection2.Clear
objSel2.clear
objSel2.Add hybridBodies1
objSel2.Paste
'Renaming
hybridBodies1.Item(hybridBodies1.count).Name = "Input Vermessung"
'Cut Paste Output Fahrgeometrie
Set objSel3 = CATIA.ActiveDocument.Selection
Set objPart3 = CATIA.ActiveDocument.Part
objSel3.clear
objSel3.Add hybridBody2
objSel3.cut
objSel2.Add hybridBodies1
objSel2.Paste
'Deleting Geo Set Input Vermessungen
Set objSel = CATIA.ActiveDocument.Selection
Set objPart = CATIA.ActiveDocument.Part
objSel.clear
objSel.Add hybridBody1
objSel.delete
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Hier Fängt die Referenz Code Abschnitt an
'Refernce/Update
Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part
Set part1 = partDocument1.Part
Dim hybridShapeFactory1 As Factory
Set hybridShapeFactory1 = part1.HybridShapeFactory
Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies
Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.Item("Output Fahrgeometrie")
Dim hybridShapes1 As HybridShapes
Set hybridShapes1 = hybridBody1.HybridShapes
Dim hybridShapeInverse1 As HybridShape
Set hybridShapeInverse1 = hybridShapes1.Item("Schnittebene Hinterrad (inversed)")
Dim reference1 As Reference
Set reference1 = part1.CreateReferenceFromObject(hybridShapeInverse1)
Dim parameters1 As Parameters
Set parameters1 = part1.Parameters
Dim hybridShapeLineExplicit1 As Parameter
Set hybridShapeLineExplicit1 = parameters1.Item(" HA/Ln")
Dim reference2 As Reference
Set reference2 = part1.CreateReferenceFromObject(hybridShapeLineExplicit1)
Dim hybridShapeIntersection1 As HybridShapeIntersection
Set hybridShapeIntersection1 = hybridShapeFactory1.AddNewIntersection(reference1, reference2)
hybridShapeIntersection1.PointType = 0
hybridBody1.AppendHybridShape hybridShapeIntersection1
part1.InWorkObject = hybridShapeIntersection1
Dim hybridShapePlaneBetween1 As HybridShape
Set hybridShapePlaneBetween1 = hybridShapes1.Item("Schnittebene Vorderrad Rechtseinschlag")
Dim hybridShapeInverse2 As HybridShape
Set hybridShapeInverse2 = hybridShapes1.Item("Schnittebene Vorderrad Rechtseinschlag (inversed)")
Dim reference3 As Reference
Set reference3 = part1.CreateReferenceFromObject(hybridShapeInverse2)
Dim parameters2 As Parameters
Set parameters2 = part1.Parameters
Dim hybridShapeLineExplicit2 As Parameter
Set hybridShapeLineExplicit2 = parameters2.Item("VA/Ls/Ln")
Dim reference4 As Reference
Set reference4 = part1.CreateReferenceFromObject(hybridShapeLineExplicit2)
Dim hybridShapeIntersection2 As HybridShapeIntersection
Set hybridShapeIntersection2 = hybridShapeFactory1.AddNewIntersection(reference3, reference4)
hybridShapeIntersection2.PointType = 0
hybridBody1.AppendHybridShape hybridShapeIntersection2
part1.InWorkObject = hybridShapeIntersection2
Dim hybridShapeInverse3 As HybridShape
Set hybridShapeInverse3 = hybridShapes1.Item("Schnittebene Vorderrad Linkseinschlag")
Dim reference5 As Reference
Set reference5 = part1.CreateReferenceFromObject(hybridShapeInverse3)
Dim parameters3 As Parameters
Set parameters3 = part1.Parameters
Dim hybridShapeLineExplicit3 As Parameter
Set hybridShapeLineExplicit3 = parameters3.Item("VR/Ls/Ln")
Dim reference6 As Reference
Set reference6 = part1.CreateReferenceFromObject(hybridShapeLineExplicit3)
Dim hybridShapeIntersection3 As HybridShapeIntersection
Set hybridShapeIntersection3 = hybridShapeFactory1.AddNewIntersection(reference5, reference6)
hybridShapeIntersection3.PointType = 0
hybridBody1.AppendHybridShape hybridShapeIntersection3
part1.InWorkObject = hybridShapeIntersection3
Dim reference7 As Reference
Set reference7 = part1.CreateReferenceFromObject(hybridShapeLineExplicit3)
Dim reference8 As Reference
Set reference8 = part1.CreateReferenceFromObject(hybridShapeLineExplicit2)
Dim hybridShapePlane2Lines1 As HybridShapePlane2Lines
Set hybridShapePlane2Lines1 = hybridShapeFactory1.AddNewPlane2Lines(reference7, reference8)
hybridBody1.AppendHybridShape hybridShapePlane2Lines1
part1.InWorkObject = hybridShapePlane2Lines1
Dim parameters4 As Parameters
Set parameters4 = part1.Parameters
Dim hybridShapeLineExplicit4 As Parameter
Set hybridShapeLineExplicit4 = parameters4.Item(" SgA/Ln")
Dim reference9 As Reference
Set reference9 = part1.CreateReferenceFromObject(hybridShapeLineExplicit4)
Dim hybridShapePointOnCurve1 As HybridShape
Set hybridShapePointOnCurve1 = hybridShapes1.Item("gemessener Lenkkopfmittelpunkt")
Dim reference10 As Reference
Set reference10 = part1.CreateReferenceFromObject(hybridShapePointOnCurve1)
Dim hybridShapePlaneNormal1 As HybridShapePlaneNormal
Set hybridShapePlaneNormal1 = hybridShapeFactory1.AddNewPlaneNormal(reference9, reference10)
hybridBody1.AppendHybridShape hybridShapePlaneNormal1
part1.InWorkObject = hybridShapePlaneNormal1
Dim reference11 As Reference
Set reference11 = part1.CreateReferenceFromObject(hybridShapeLineExplicit4)
Dim reference12 As Reference
Set reference12 = part1.CreateReferenceFromObject(hybridShapePlaneNormal1)
Dim hybridShapeIntersection4 As HybridShapeIntersection
Set hybridShapeIntersection4 = hybridShapeFactory1.AddNewIntersection(reference11, reference12)
hybridShapeIntersection4.PointType = 0
hybridBody1.AppendHybridShape hybridShapeIntersection4
part1.InWorkObject = hybridShapeIntersection4
Dim reference13 As Reference
Set reference13 = part1.CreateReferenceFromObject(hybridShapeLineExplicit4)
Dim reference14 As Reference
Set reference14 = part1.CreateReferenceFromObject(hybridShapeIntersection4)
Dim hybridShapePlaneNormal2 As HybridShapePlaneNormal
Set hybridShapePlaneNormal2 = hybridShapeFactory1.AddNewPlaneNormal(reference13, reference14)
hybridBody1.AppendHybridShape hybridShapePlaneNormal2
part1.InWorkObject = hybridShapePlaneNormal2
Dim sketches1 As Sketches
Set sketches1 = hybridBody1.HybridSketches
Dim sketch1 As Sketch
Set sketch1 = sketches1.Item("Fahrbahn")
sketch1.CloseEdition
Dim reference15 As Reference
Set reference15 = part1.CreateReferenceFromObject(hybridShapePlaneNormal2)
Dim reference16 As Reference
Set reference16 = part1.CreateReferenceFromObject(hybridShapeLineExplicit1)
Dim hybridShapeIntersection5 As HybridShapeIntersection
Set hybridShapeIntersection5 = hybridShapeFactory1.AddNewIntersection(reference15, reference16)
hybridShapeIntersection5.PointType = 0
hybridBody1.AppendHybridShape hybridShapeIntersection5
part1.InWorkObject = hybridShapeIntersection5
End Sub
Im Anhang findet man das Screenshot von die manuelle Referenz Schritte
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP