Select and delete all fillets on a "dumb" imported solid

Select and delete all fillets on a "dumb" imported solid

DRoam
Mentor Mentor
2,811 Views
13 Replies
Message 1 of 14

Select and delete all fillets on a "dumb" imported solid

DRoam
Mentor
Mentor

Is there a quick way to select and delete all filleted faces on a dumb solid that was imported from a STEP file? Perhaps select all curved faces below a certain radius?

 

Using Inventor 2017.4.

0 Likes
2,812 Views
13 Replies
Replies (13)
Message 2 of 14

TheCADWhisperer
Consultant
Consultant

Perhaps Feature Recognition and then Delete?

Message 3 of 14

Daniel248
Collaborator
Collaborator

Try 'Delete Face' with Heal enabled

Message 4 of 14

johnsonshiue
Community Manager
Community Manager

Hi DRoam,

 

Another one. Place it into an assembly -> go through Shrinkwrap or Simplification workflow and then export it as a SAT or STEP and reimport it back.

Many thanks!

 



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 5 of 14

Mark.Lancaster
Consultant
Consultant

@DRoam

 

If you use the feature recognition tool and then bringing in the simplification tools, you can auto-select to remove all fillets.

 

2018-02-09_12-52-29.jpg 

 

But it will remove all fillets and not just certain ones based on a size.

Mark Lancaster


  &  Autodesk Services MarketPlace Provider


Autodesk Inventor Certified Professional & not an Autodesk Employee


Likes is much appreciated if the information I have shared is helpful to you and/or others


Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

Message 6 of 14

Curtis_Waguespack
Consultant
Consultant

Hi @DRoam,

 

This API / ilogic example looks at all the faces and then filters for cylindrical faces, adds them to a collection, and then creates a delete face feature with the heal option. 

 

What it's missing is an option to filter for radius size ... you might post on the Inventor Customization forum for that :
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveEditDocument

' a reference to the component definition.
Dim oCompDef As PartComponentDefinition
oCompDef = oDoc.ComponentDefinition

Dim oFaceColl As FaceCollection
oFaceColl = ThisApplication.TransientObjects.CreateFaceCollection

'look at each face and add to collection if the face is cylicdrical	
Dim oFace As Face
For Each oFace In oDoc.ComponentDefinition.SurfaceBodies(1).Faces
	If oFace.SurfaceType = SurfaceTypeEnum.kCylinderSurface Then
		Call oFaceColl.Add(oFace)
	End If
Next

If oFaceColl.count > 0 Then
	'delete faces and heal body
	Dim oDeleteFace As DeleteFaceFeature
	oDeleteFace = oCompDef.Features.DeleteFaceFeatures.Add(oFaceColl, True)
End If

 

EESignature

Message 7 of 14

DRoam
Mentor
Mentor

Thanks for all the great suggestions!

 

Since the parts I'm working with are complex, I want to keep them as dumb geometry, so Feature Recognition isn't ideal. I also wanted to avoid lots of steps and extra files, so Shrinkwrap would be a little to tedious.

 

Not sure why I assumed iLogic wouldn't be able to handle this. As usual, I was wrong, and as usual, Curtis set me straight.

 

With that helpful start I was able to put together a more complete rule that fits my needs. First, if there are multiple bodies, it prompts to select which body to operate on. Then it allows me to try several different radius limits and preview which faces will be deleted. I can also measure an existing fillet's radius for a starting point.

 

One important thing I added is the rule tries to select any tangent "fillet transition faces". If fillet transition faces/corners aren't selected then the Delete Face usually fails because it can't heal the corners properly in response to adjacent fillets being removed.

 

Anyway, if I'm happy with the preview I can say OK to automatically do the Delete Face, or I can cancel out to manually edit the selection before deleting myself.

 

In the small amount of testing I did with my test parts (attached), it successfully selects all necessary fillets and fillet transition faces without needing any manual selection-set tweaking. I'm sure it's far from perfect though. If anyone else uses this and runs into issues please share them here so it can be refined.

 

Thanks again for getting me started, Curtis!

 

NOTE: This rule is set up for working in inches. If working in cm, change "InputUnitToCM" to 1. If working in mm, change it to 0.1. And likewise for other units.

 

Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveEditDocument

InputUnitToCM = 2.54 'Conversion factor from input units to iLogic working units (centimeters)

'Create a reference to the component definition.
Dim oCompDef As PartComponentDefinition
oCompDef = oDoc.ComponentDefinition

Dim oFaceColl As FaceCollection
oFaceColl = ThisApplication.TransientObjects.CreateFaceCollection
Dim oSurfaceBody As SurfaceBody
Dim oFace As Face
Dim oFace2 As Face

oDoc.SelectSet.Clear

If oDoc.ComponentDefinition.SurfaceBodies.Count > 1 Then
	'Prompt to select a body
	oSurfaceBody = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartBodyFilter, "Pick a Body to operate on")
Else
	oSurfaceBody = oDoc.ComponentDefinition.SurfaceBodies(1)
End If

Dim UserInput As String
Dim MaxRadius As Double
Dim oRadius As Double

UserInputDefault = "a"
GetUserInput:
PreviousUserInput = UserInput
UserInput = InputBox("Enter the max fillet radius to delete (fillets of exactly this size WILL be deleted)" & vbNewLine & vbNewLine & "Type ""a"" to select all fillets or ""m"" to measure a reference fillet size." & vbNewLine & vbNewLine & "When satisfied, type ""d"" or simply hit Enter/OK to delete selection." & vbNewLine & vbNewLine & "To cancel, type ""c"" or hit Esc/Cancel to keep the selection and exit without deleting.", "Auto-Delete Fillet Faces", UserInputDefault)

Select Case UserInput
	Case "" 'Cancel
		Return
	Case "m"
		oCamera = ThisApplication.ActiveView.Camera
		oCircularEdge  = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeCircularFilter, "Select a circular edge")
		If oCircularEdge Is Nothing Then Goto GetUserInput
		Try
			oRadius = oCircularEdge.Geometry.Radius
			MaxRadius = Ceil(oRadius * 100000) / 100000 'Round up to nearest .00001 cm
		Catch
			MessageBox.Show("Could not get a radius from the selected arc. It may be an elliptical arc." & vbNewLine & vbNewLine & "Please try a different input.","Radius Measure Error",MessageBoxButtons.OK,MessageBoxIcon.Error)
			Goto GetUserInput
		End Try
		UserInputDefault = MaxRadius / InputUnitToCM 'Convert to input units
		UserInput = UserInputDefault 'This is so that if the user simply hits "Enter" again, the selected faces will be deleted
		'Restore the camera to its location from before taking the measurement
		oCamera.Apply
		'Continue on to select fillet faces
	Case "d",PreviousUserInput
		oCount = oFaceColl.count
		If oCount > 0 Then
			Try
				oTransaction = ThisApplication.TransactionManager.StartTransaction(ThisDoc.Document, "Auto-delete Fillet Faces Under " & Round(MaxRadius/InputUnitToCM,5))
					Dim oDeleteFace As DeleteFaceFeature
					oDeleteFace = oCompDef.Features.DeleteFaceFeatures.Add(oFaceColl, True)
				oTransaction.End
				MessageBox.Show(oCount & " faces successfully deleted.")
				Return
			Catch
				oTransaction.Abort
				MessageBox.Show("An error occurred while attempting to delete the selected faces.")
				Return
			End Try
		Else
			MessageBox.Show("No faces were deleted.")
			Return
		End If
	Case "a"
		MaxRadius = 0
		UserInputDefault = "a"
		'Continue on to select fillet faces
	Case Else
		Try
			If UserInput > 0 Then
				MaxRadius = Ceil(CDbl(UserInput) * InputUnitToCM * 100000)/100000 'Convert to cm, then round up to nearest .00001 cm
				UserInputDefault = UserInput
				'Continue on to select fillet faces
			Else
				MessageBox.Show("An invalid max radius was entered. Please make a valid entry.")
				Goto GetUserInput
			End If
		Catch
			MessageBox.Show("An invalid max radius was entered. Please make a valid entry.")
			Goto GetUserInput
		End Try
End Select

oDoc.SelectSet.Clear
oFaceColl.Clear

For Each oFace In oSurfaceBody.Faces
	If oFace.SurfaceType = SurfaceTypeEnum.kCylinderSurface And oFace.GeometryForm.Equals(9) Then
		oRadius = Floor(oFace.Geometry.Radius * 100000) / 100000 'Round down to nearest .00001 cm
		
		If MaxRadius = 0 Or oRadius <= MaxRadius Then
			'Geometry Form = 9 ensures that no cylindrical holes will be selected.
			oDoc.SelectSet.Select(oFace)
			oFaceColl.Add(oFace)
			
			'Now check for tangent fillet "transition" faces, which need to be selected or else the Delete Face operation will fail.
			For Each oFace2 In oFace.TangentiallyConnectedFaces
				If oFace2.SurfaceType = SurfaceTypeEnum.kSphereSurface Or oFace2.SurfaceType = SurfaceTypeEnum.kTorusSurface Or oFace2.SurfaceType = SurfaceTypeEnum.kBSplineSurface Then
					oDoc.SelectSet.Select(oFace2)
					oFaceColl.Add(oFace2)
				End If
			Next 'Tangent face
		End If
	End If
Next 'Face

Goto GetUserInput
Message 8 of 14

DRoam
Mentor
Mentor

So I did find an issue when testing it on a test part I created (attached, FilletTest3.ipt). For some reason, the corner transition on the right-hand corner is treated as a tangentially connected face to the 0.125" and 0.25" fillets on the left-hand side. As best I can tell, this is a fault with the ".TangentiallyConnectedFaces" property. It seems to think that the upper-right hand corner round is a member of the "TangentiallyConnectedFaces" object set for the 0.125" and 0.25" fillets, even thought it's clearly not connected.

 

@johnsonshiue, any idea why this might be? Is this an iLogic bug or just a consequence of how Inventor defines "TangentiallyConnectedFaces"? Either way, can I somehow identify "TangentiallyConnectedFaces" that aren't actually connected so I can ignore them during the "TangentiallyConnectedFaces" loop?

 

EDIT: To see what I mean, just use "0.125" as the input for the DeleteFillets rule.

0 Likes
Message 9 of 14

Curtis_Waguespack
Consultant
Consultant

Hi DRoam,

 

Very slick!

 

Thanks for posting the code and example files, I'm sure it'll help someone in the future should they have this need.

 

Here's a more basic example, incorporating just what JaneFan suggested on the other forum, in case it helps someone as well.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

'Get user Input
dValue = InputBox("Enter a radius size to remove" & vbLf & _
"(value is in centimeters)", "iLogic", "0.1")

Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveEditDocument

' a reference to the component definition.
Dim oCompDef As PartComponentDefinition
oCompDef = oDoc.ComponentDefinition

Dim oFaceColl As FaceCollection
oFaceColl = ThisApplication.TransientObjects.CreateFaceCollection

Dim oEdgeColl As EdgeCollection
oEdgeColl = ThisApplication.TransientObjects.CreateEdgeCollection

'look at each face and add to collection if the face is cylicdrical	
Dim oFace As Face
For Each oFace In oDoc.ComponentDefinition.SurfaceBodies(1).Faces
	If oFace.SurfaceType = SurfaceTypeEnum.kCylinderSurface Then	
		If oFace.Geometry.Radius <= dValue Then
			Call oFaceColl.Add(oFace)
		End If
	End If
Next

If oFaceColl.count > 0 Then
	'delete faces and heal body
	Dim oDeleteFace As DeleteFaceFeature
	oDeleteFace = oCompDef.Features.DeleteFaceFeatures.Add(oFaceColl, True)
	MessageBox.Show(oFaceColl.count & " cylicdrical faces removed.", "iLogic")
End If

EESignature

Message 10 of 14

DRoam
Mentor
Mentor

Thanks, Curtis!

 

FYI, @johnsonshiue, I posted a dedicated question for that "TangentiallyConnectedFaces" quirk in the Customization forum.

 

0 Likes
Message 11 of 14

johnsonshiue
Community Manager
Community Manager

Hi DRoam,

 

The behavior is wrong. For some reason the vertex blend (sphere) on the other side is selected. I think this is a bug. I will work with the project team to understand the behavior more but I don't anticipate a quick fix though.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 12 of 14

DRoam
Mentor
Mentor

Hi Johnson, thanks for looking into it. Actually I think I found out what's happening. The seemingly random selected face is due to "TangentiallyConnectedFaces" being meant to do more than I thought it did, and my code filtering out some specific faces. I think the iLogic is actually doing exactly what it's supposed to. If you could, please take a look at my comment on the other thread, here, and tell me what you think. Thanks!

0 Likes
Message 13 of 14

MGO-Norsyn
Advocate
Advocate

Hi

Were you able to arrive at a better solution for your iLogic rule? The one posted, selects a little bit too much. Thank you.

0 Likes
Message 14 of 14

rodney19701
Community Visitor
Community Visitor

Could this code be altered to only select radii that have a concentric counterpart?  What I am after is I want to erase inside and outside radius of a formed part. 

I process hundreds files by deleting these radii, correcting the thickness then adding back radii that in consistent with  our press brake tooling that we have. 

If i had this in a VBA macro i could use KwikBatch run and automatically complete 1/2 the work while I go get a cup of coffee.

Thanks for your help.  I have years of experience with Autolisp but have yet to dig in to VBA,  see tools that do what i need allows me to dissect them and learn how to create others.

0 Likes