Hello
I have an assembly containing subassemblies and parts. If i have an part edge, is there a way to get all edgeproxies representing this edge in context of the main assembly? I can circle through all edgeproxies in the assembly context and check if the native object is my edge, but this is very slow.
Solved! Go to Solution.
Solved by JhoelForshav. Go to Solution.
Hi @Ralf_Krieg
Something like this maybe? 🙂
Sub Main 'Get a nativeobject for an edge, I dont know where you're getting the edge object from. Dim oEdge As Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Pick edge.").NativeObject Dim oPart As PartDocument = oEdge.Parent.ComponentDefinition.Document Dim oAsm As AssemblyDocument = ThisDoc.Document Dim oSelSet As SelectSet = oAsm.SelectSet Dim oEdgeCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection For Each oOcc As ComponentOccurrence In oAsm.ComponentDefinition.Occurrences.AllReferencedOccurrences(oPart) Dim oEdgeProx As EdgeProxy = CreateEdgeProxy(oOcc.OccurrencePath, oEdge) oEdgeCol.Add(oEdgeProx) Next oSelSet.SelectMultiple(oEdgeCol) End Sub Function CreateEdgeProxy(oOccList As ComponentOccurrencesEnumerator, oEdge As Edge) As Object Dim oProx As Object For i = oOccList.Count To 1 Step -1 If i = oOccList.Count Call oOccList(i).CreateGeometryProxy(oEdge, oProx) Else Call oOccList(i).CreateGeometryProxy(oProx, oProx) End If Next Return oProx End Function
Jhoel Forshav Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
I just realized you don't have to send the proxy up through each occurrence of the occurrencepath.
This will do.
'Get a nativeobject for an edge. Dim oEdge As Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Pick edge.").NativeObject 'Get the part document the edge belongs to. Dim oPart As PartDocument = oEdge.Parent.ComponentDefinition.Document 'Get the top level assembly Dim oAsm As AssemblyDocument = ThisDoc.Document 'Get the Assemblys select set. Dim oSelSet As SelectSet = oAsm.SelectSet 'Create an ObjectCollection to add all edge proxies to. Dim oEdgeCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection 'Loop through all occurrences of the part. For Each oOcc As ComponentOccurrence In oAsm.ComponentDefinition.Occurrences.AllReferencedOccurrences(oPart) 'Create a proxy for the edge Dim oEdgeProx As EdgeProxy oOcc.CreateGeometryProxy(oEdge, oEdgeProx) 'Add proxy to the object collection oEdgeCol.Add(oEdgeProx) Next 'Select everything in the object collection oSelSet.SelectMultiple(oEdgeCol)
Jhoel Forshav Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
Hello
Thank you. I have integrated your second code. Works perfect. 👍
Can't find what you're looking for? Ask the community or share your knowledge.