Selecting adjacent with angle threshold

Selecting adjacent with angle threshold

simsekmelih2
Contributor Contributor
231 Views
3 Replies
Message 1 of 4

Selecting adjacent with angle threshold

simsekmelih2
Contributor
Contributor

Hi, I am trying to create a script that would select adjacent faces of the selected face within an angle threshold.Capture.JPG

I have many step files that I am simplifying such chamfers in. I couldn't think of a better way to quickly select those faces. How would you go about doing that?

0 Likes
232 Views
3 Replies
Replies (3)
Message 2 of 4

C_Haines_ENG
Collaborator
Collaborator

This doesn't quite do what you're asking because that could get COMPLICATED pretty fast, but this allows you to select part features, and will select all faces that were created by those features. Give it a go and see if it works for you. However if you placed multiple chamfers or did multiple extrusions at the same time it will grab those too.

 

To use this tool, select all features you want the faces of and when done press escape.

 

Sub Main

	Dim oDoc As PartDocument = ThisDoc.Document
	Dim oFaces As FaceCollection = ThisApplication.TransientObjects.CreateFaceCollection
	Dim oFeatures As New List(Of PartFeature)
	Dim oFeature As PartFeature
	Dim oHLS As HighlightSet = oDoc.CreateHighlightSet

	Do

		oFeature = ThisApplication.CommandManager.Pick(kPartFeatureFilter, "Select Feature")
		If oFeature Is Nothing Then Exit Do Else oFeatures.Add(oFeature)

	Loop

	For Each oFeature In oFeatures
		For Each oFace As Face In oFeature.Faces

			oFaces.Add(oFace)

		Next
	Next
	
	oDoc.SelectSet.SelectMultiple(oFaces)

End Sub

 

If the items you would be using this on look exactly like the feature shown in the image there might be an easier way of going about it. Let me know if this works for you or not. 

0 Likes
Message 3 of 4

simsekmelih2
Contributor
Contributor

Thanks a lot for your reply, much appreciated! However, I am not sure if this works for me. I do not have any features added. I am simply importing STEP files that were modeled in some other software. So all I have is one solid.

 

I realized I am able to select edge loops by double clicking (although sometimes it does not select all I want), so I managed to write a script that chooses every face that is adjacent to selected edges. Then I deselect faces I do not want to delete and I use Delete Face > Heal command.

 

It is taking a lot longer than ideal, so that's why I am looking for another script that would choose adjacent faces of the selected face by some angle threshold or something smarter I can't really think of.

 

Many thanks again!

0 Likes
Message 4 of 4

C_Haines_ENG
Collaborator
Collaborator

Ah I see, well I can attempt to write this code but without examples to base the code off of it could be hit and miss. Do you think you could upload some of these step files, or upload part files that contain the same geometry?

 

Its not the hardest thing in the world to write but it can get COMPLEX. getting an accurate normal of a face (especially curved faces) gets a little tricky. 

0 Likes