Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I think I've got issue with understanding proxies of subcomponents and I can't figure it out by myself... I've got nice working SUB that constrains part with other part by faces within one assembly. However I can't write a sub that creates constrain in assembly using part with named entity and in part that is contained in another assembly that is put into main assembly. Do I need to create geometry proxy of component occurence? Snip of code that I've got below. It crashes on adding constraint. As addition, can I use directly faces from features? Or do I need to create another proxy to use it? Any help appreciated... Using VS2022 as IDE and creating standalone app.
Public Sub Constrain(invapp As Inventor.Application, strPart1 As String, strPart2 As String)
Dim oAssyDoc As Inventor.AssemblyDocument
oAssyDoc = invapp.ActiveDocument
Dim oCompDef As Inventor.AssemblyComponentDefinition
oCompDef = oAssyDoc.ComponentDefinition
Dim o1Comp As Inventor.ComponentOccurrence
Dim o2Comp As Inventor.ComponentOccurrence
Dim oSubAssy As Inventor.AssemblyComponentDefinition
o1Comp = oCompDef.Occurrences.ItemByName(strPart1)
oSubAssy = oCompDef.Occurrences.ItemByName(strPart2).Definition
o2Comp = oSubAssy.Occurrences.ItemByName("PIPE:1")
Dim oPart1 As Inventor.PartDocument
Dim oPart2 As Inventor.PartDocument
oPart1 = o1Comp.Definition.Document
oPart2 = o2Comp.Definition.Document
Dim o1PartFace As Inventor.Face
Dim o2PartFace As Inventor.Face
Dim oFP1 As Inventor.FaceProxy
Dim oFP2 As Inventor.FaceProxy
' o1PartFace = oPart1.ComponentDefinition.Features.ExtrudeFeatures.Item("CylinderExtrude").Faces.Item(1)
' o2PartFace = oPart2.ComponentDefinition.Features.ExtrudeFeatures.Item("CutOutForNozzleExtrude").Faces.Item(1)
o1PartFace = oPart1.AttributeManager.FindObjects(,, "NAME1")(1)
o2PartFace = oPart2.AttributeManager.FindObjects(,, "NAME2")(1)
o1Comp.CreateGeometryProxy(o1PartFace, oFP1)
o2Comp.CreateGeometryProxy(o2PartFace, oFP2)
oCompDef.Constraints.AddMateConstraint(oFP1, oFP2, 0, InferredTypeEnum.kInferredLine, InferredTypeEnum.kInferredLine,,)
End Sub
Solved! Go to Solution.