Hi @JhoelForshav
Thank you for providing this code. I am trying to use it, but my code is failing at CreateGeometryProxy.
Any help would be greatly appreciated.
I'm using Inventor 2024 and VS 2022
Below is my Subroutine. I have commented out many lines until I can troubleshoot the issue.
Public Sub RemoveableCores()
' Define component file paths
Dim AssyPathName As String = System.IO.Path.GetDirectoryName(oDoc.FullFileName)
Dim asmCompDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
' Define component file paths
Dim compPath1 As String = AssyPathName + "\" + "iCoreStrap.ipt"
' Add components to assembly
Dim occ1 As ComponentOccurrence = asmCompDef.Occurrences.Add(compPath1, g_inventorApplication.TransientGeometry.CreateMatrix())
Dim occ2 As ComponentOccurrence = asmCompDef.Occurrences.ItemByName("Frame S2")
Dim occ3 As ComponentOccurrence = asmCompDef.Occurrences.ItemByName("Frame L1")
' Get named faces for Strap
Dim Strap_face1 As Face = GetNamedFace(occ1.Definition.Document, "LeftFace1")
'Dim Strap_face2 As Face = GetNamedFace(occ1.Definition.Document, "TopFace")
'Dim Strap_face3 As Face = GetNamedFace(occ1.Definition.Document, "FrontFace")
Dim Strap_FaceProx1 As FaceProxy
'Dim oStrap_FaceProx2 As FaceProxy
'Dim oStrap_FaceProx3 As FaceProxy
occ1.CreateGeometryProxy(Strap_face1, Strap_FaceProx1)
'occ1.CreateGeometryProxy(Strap_face2, oStrap_FaceProx2)
'occ1.CreateGeometryProxy(Strap_face3, oStrap_FaceProx3)
' Get named faces for Frame S2
Dim FrameS2_face1 As Face = GetNamedFace(occ2.Definition.Document, "BShortInsideFace")
Dim FrameS2_Prox1 As FaceProxy
'occ2.CreateGeometryProxy(FrameS2_face1, FrameS2_Prox1)
' Get named faces for Frame L1
'Dim FrameL1_face1 As Face = GetNamedFace(occ3.Definition.Document, "BLongBottomFace")
'Dim FrameL1_face2 As Face = GetNamedFace(occ3.Definition.Document, "Face0")
'Constrain strap to Frame S2
asmCompDef.Constraints.AddMateConstraint(Strap_FaceProx1, FrameS2_Prox1, 0) ' InferredTypeEnum.kNoInference, InferredTypeEnum.kNoInference)
'asmCompDef.Constraints.AddMateConstraint(Strap_face2, FrameL1_face1, 0) ', InferredTypeEnum.kNoInference, InferredTypeEnum.kNoInference)
'asmCompDef.Constraints.AddMateConstraint(Strap_face3, FrameL1_face2, 0) ', InferredTypeEnum.kNoInference, InferredTypeEnum.kNoInference)
End Sub
Here is function for getting the named faces.
' Function to get a named face from a component occurrence
Function GetNamedFace(occ As Inventor.Document, faceName As String) As Face
Dim attribMgr As AttributeManager = occ.AttributeManager
Dim objsFound As ObjectCollection
objsFound = attribMgr.FindObjects("iLogicEntityNameSet", "iLogicEntityName", Name)
If objsFound.Count > 0 Then
Return (objsFound.Item(1))
Else
Return (Nothing)
End If
End Function
Here is the error I get.

The following images show the named entities in the first two part files.

