still no solution,
here is an snippet code from autodesk to make projections a cross parts :
(make an new assembly and add 2 different new parts.)
vba :
Public Sub ProjectingAcrossParts()
' Set a reference to the assembly component definition.
Dim oAsmCompDef As AssemblyComponentDefinition
Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
' Get references to two occurrences.
' This arbitrarily gets the first and second occurrence.
Dim oOcc1 As ComponentOccurrence
Set oOcc1 = oAsmCompDef.Occurrences.Item(1)
Dim oOcc2 As ComponentOccurrence
Set oOcc2 = oAsmCompDef.Occurrences.Item(2)
' Create a sketch on the first part.
Dim oSketch1 As PlanarSketch
Set oSketch1 = oOcc1.Definition.Sketches.Add(oOcc1.Definition.WorkPlanes(1))
' Set a reference to the transient geometry collection.
Dim oTransGeom As TransientGeometry
Set oTransGeom = ThisApplication.TransientGeometry
' Create a sketch line on the sketch.
Dim oSketchLine1 As Object
Set oSketchLine1 = oSketch1.SketchLines.AddByTwoPoints(oTransGeom.CreatePoint2d(0, 0), _
oTransGeom.CreatePoint2d(4, 0))
' Because we need the sketch line in the context of the assembly
' we need to create a proxy for the sketch line. The proxy
' represents the sketch line in the context of the assembly.
Dim oSketchLine1Proxy As Object
Call oOcc1.CreateGeometryProxy(oSketchLine1, oSketchLine1Proxy)
' Create a sketch on the second part.
Dim oSketch2 As PlanarSketch
Set oSketch2 = oOcc2.Definition.Sketches.Add(oOcc2.Definition.WorkPlanes(1))
' Create a proxy for the sketch in the second part.
Dim oSketch2Proxy As PlanarSketchProxy
Call oOcc2.CreateGeometryProxy(oSketch2, oSketch2Proxy)
' Project the line in the sketch in the first
' part to the sketch in the second part
Dim oSketchLine2Proxy As SketchLineProxy
Set oSketchLine2Proxy = oSketch2Proxy.AddByProjectingEntity(oSketchLine1Proxy)
End Sub
ilogic :
Public Sub main()
' Set a reference to the assembly component definition.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
' Get references to two occurrences.
' This arbitrarily gets the first and second occurrence.
Dim oOcc1 As ComponentOccurrence
oOcc1 = oAsmCompDef.Occurrences.Item(1)
Dim oOcc2 As ComponentOccurrence
oOcc2 = oAsmCompDef.Occurrences.Item(2)
' Create a sketch on the first part.
Dim oSketch1 As PlanarSketch
oSketch1 = oOcc1.Definition.Sketches.Add(oOcc1.Definition.WorkPlanes(1))
' Set a reference to the transient geometry collection.
Dim oTransGeom As TransientGeometry
oTransGeom = ThisApplication.TransientGeometry
' Create a sketch line on the sketch.
Dim oSketchLine1 As Object
oSketchLine1 = oSketch1.SketchLines.AddByTwoPoints(oTransGeom.CreatePoint2d(0, 0), _
oTransGeom.CreatePoint2d(4, 0))
' Because we need the sketch line in the context of the assembly
' we need to create a proxy for the sketch line. The proxy
' represents the sketch line in the context of the assembly.
Dim oSketchLine1Proxy As Object
oOcc1.CreateGeometryProxy(oSketchLine1, oSketchLine1Proxy)
' Create a sketch on the second part.
Dim oSketch2 As PlanarSketch
oSketch2 = oOcc2.Definition.Sketches.Add(oOcc2.Definition.WorkPlanes(1))
' Create a proxy for the sketch in the second part.
Dim oSketch2Proxy As PlanarSketchProxy
oOcc2.CreateGeometryProxy(oSketch2, oSketch2Proxy)
' Project the line in the sketch in the first
' part to the sketch in the second part
Dim oSketchLine2Proxy As SketchLineProxy
oSketchLine2Proxy = oSketch2Proxy.AddByProjectingEntity(oSketchLine1Proxy)
End Sub
and run this snippet.
Now there in the second part an sketch with an cross-part-reference.
How can i break this link, without having errors?? (with code)
(i want to do this : oSketch2Proxy.RemoveProjectingEntityLink(oSketch2Proxy ) (or delete the object projectoSketch2Proxy)
i try it :
ilogic :
Public Sub main()
' Set a reference to the assembly component definition.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
' Get references to two occurrences.
' This arbitrarily gets the first and second occurrence.
Dim oOcc1 As ComponentOccurrence
oOcc1 = oAsmCompDef.Occurrences.Item(1)
Dim oOcc2 As ComponentOccurrence
oOcc2 = oAsmCompDef.Occurrences.Item(2)
' Create a sketch on the first part.
Dim oSketch1 As PlanarSketch
oSketch1 = oOcc1.Definition.Sketches.Add(oOcc1.Definition.WorkPlanes(1))
' Set a reference to the transient geometry collection.
Dim oTransGeom As TransientGeometry
oTransGeom = ThisApplication.TransientGeometry
' Create a sketch line on the sketch.
Dim oSketchLine1 As Object
oSketchLine1 = oSketch1.SketchLines.AddByTwoPoints(oTransGeom.CreatePoint2d(0, 0), _
oTransGeom.CreatePoint2d(4, 0))
' Because we need the sketch line in the context of the assembly
' we need to create a proxy for the sketch line. The proxy
' represents the sketch line in the context of the assembly.
Dim oSketchLine1Proxy As Object
oOcc1.CreateGeometryProxy(oSketchLine1, oSketchLine1Proxy)
' Create a sketch on the second part.
Dim oSketch2 As PlanarSketch
oSketch2 = oOcc2.Definition.Sketches.Add(oOcc2.Definition.WorkPlanes(1))
' Create a proxy for the sketch in the second part.
Dim oSketch2Proxy As PlanarSketchProxy
oOcc2.CreateGeometryProxy(oSketch2, oSketch2Proxy)
' Project the line in the sketch in the first
' part to the sketch in the second part
Dim oSketchLine2Proxy As SketchLineProxy
oSketchLine2Proxy = oSketch2Proxy.AddByProjectingEntity(oSketchLine1Proxy)
MessageBox.Show("next, remove the link", "remove projection")
If oSketchLine2Proxy.Reference Then
oSketch2Proxy.Adaptive = False
oSketchLine2Proxy.Reference = False
oSketchLine2Proxy.Delete
End If
oSketch2Proxy.Solve
End Sub
and now the code works, but if you check the sketch, there is an error on the-cross-part-reference.


same issue in all inventor versions that i try (2019,2023,2024)...