Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get all EdgeProxies of a given Edge

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Ralf_Krieg
879 Views, 4 Replies

Get all EdgeProxies of a given Edge

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.


R. Krieg
RKW Solutions GmbH
www.rkw-solutions.com
Labels (1)
4 REPLIES 4
Message 2 of 5
JhoelForshav
in reply to: Ralf_Krieg

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
Message 3 of 5
JhoelForshav
in reply to: JhoelForshav

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)

 

Message 4 of 5
Ralf_Krieg
in reply to: JhoelForshav

Hello

 

Thank you. I have integrated your second code. Works perfect. 👍


R. Krieg
RKW Solutions GmbH
www.rkw-solutions.com
Message 5 of 5
sam
Advocate
in reply to: JhoelForshav

Thanks for this one - took me a while to figure out edgeproxy (:$)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report