Selecting Named Face in Assembly

Selecting Named Face in Assembly

jake_pietrzak
Contributor Contributor
388 Views
2 Replies
Message 1 of 3

Selecting Named Face in Assembly

jake_pietrzak
Contributor
Contributor

First of all I wanted to say thank you to @Curtis_Waguespack  & @FINET_Laurent  for helping me with selecting a named face from part level.

 

But I have another problem(challenge ) 😉

Selecting faces named in part from assembly level.

 

Lets say I have Assembly called: Assembly 01 

 

 

In this assembly I have 3 parts called: Part 01, Part 02 & Part 03.

Parts: Part 01 & Part 02 have a face called: Face 01.

How can I  select Face 01 in each part from assembly level?

389 Views
2 Replies
Replies (2)
Message 2 of 3

Andrii_Humeniuk
Advisor
Advisor

Hi @jake_pietrzak . Try this code. You need to enter the name of the face in lines 17 and 19.

Sub main
	Dim oDoc As Document = ThisDoc.Document
	If Not TypeOf oDoc Is AssemblyDocument Then Exit Sub
	Dim oAsmDoc As AssemblyDocument = oDoc
	Dim oSelect As SelectSet = oAsmDoc.SelectSet
	Dim oFaceCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	Call FindFaces(oAsmDoc.ComponentDefinition.Occurrences, oFaceCol)
	Call oSelect.Clear()
	Call oSelect.SelectMultiple(oFaceCol)
End Sub

Private Function FindFaces(ByVal oOccs As ComponentOccurrences, ByRef oFaceCol As ObjectCollection) As ObjectCollection
	Dim iLogicAuto = iLogicVb.Automation
	For Each oOcc As ComponentOccurrence In oOccs
		Dim oNamedEntities As NamedEntities = iLogicAuto.GetNamedEntities(oOcc.Definition.Document)	
		If oOcc.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject Then
			If Not oNamedEntities.NameExists("Face 01") Then Continue For
			Dim oFaceProxy As FaceProxy
			oOcc.CreateGeometryProxy(oNamedEntities.FindEntity("Face 01"), oFaceProxy)
			oFaceCol.Add(oFaceProxy)
		Else If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
			If oOcc.SubOccurrences.Count = 0 Then Continue For
			Call FindFaces(oOcc.SubOccurrences, oFaceCol)
		End If
	Next
End Function

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

Message 3 of 3

Curtis_Waguespack
Consultant
Consultant

@jake_pietrzak 

 

I didn't see this new post, before replying to the previous post, but see this reply for another example:

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/selecting-a-named-face-with-ilogic/m...

 

It looks like @Andrii_Humeniuk and I  came up with very similar examples, however his example is more thorough in that it looks at the parts that are within subassemblies also. My example does not.

 

EESignature

0 Likes