Add all faces directly adjacent to the faces of the selected Feature to a List(Of Face)

Add all faces directly adjacent to the faces of the selected Feature to a List(Of Face)

Maxim-CADman77
Advisor Advisor
702 Views
1 Reply
Message 1 of 2

Add all faces directly adjacent to the faces of the selected Feature to a List(Of Face)

Maxim-CADman77
Advisor
Advisor

I need the solution that adds all faces directly adjacent* to the faces of the selected PartFeature to a List(Of Face).

I'm using iLogic like this:

 

Imports System.Linq
AddReference "System.Core"

Dim AllFaces As New List(Of Face)
Dim oIPT As PartDocument=ThisDoc.Document
Dim oCD As ComponentDefinition=oIPT.ComponentDefinition
Dim oFtr As PartFeature
Dim MsgBody As String

While Answer<>vbCancel

	AllFaces.Clear
	MsgBody=""

	oFtr = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFeatureFilter, "")
	
	AllFaces.AddRange(From f As Face In oFtr.Faces Select f)
	
	MsgBody &= "The feature faces QTY = " & AllFaces.Count & vbCrLf	

'	AllFaces.AddRange ???
	
	MsgBody &= "Faces Selected in Total = " & AllFaces.Count & vbCrLf		

	Answer=MsgBox(MsgBody & vbCrLf & "Select another feature?", MsgBoxStyle.OKCancel,"Face selection for """ & oFtr.Name & """:")
End While

 

... and need some hint for the commented line.

 

* I'm not 100% sure that word "adjacent" suits this case. Under adjacent face i mean face that touches the given one (has common edge or vertex). Maybe "CoFace" is more suitable word for this?

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Accepted solutions (1)
703 Views
1 Reply
Reply (1)
Message 2 of 2

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @Maxim-CADman77 

I think something like this is what you're looking for? 🙂

 

Dim oFeature As PartFeature = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFeatureFilter, "")
Dim AllFaces As New List(Of Face)
For Each oFace As Face In oFeature.Faces
	For Each oEdge As Edge In oFace.Edges
		For Each eFace As Face In oEdge.Faces
			If oFeature.Faces.OfType(Of Face)().Where(Function(x) x Is eFace).Count = 0 _
				Then AllFaces.Add(eFace)
		Next
	Next
Next

'Test to see that the correct faces are selected
For Each oFace As Face In AllFaces
ThisDoc.Document.SelectSet.Select(oFace)
Next
'------------------------------------------------