Rule to suppress features containg certain word

Rule to suppress features containg certain word

fakeru
Advocate Advocate
929 Views
5 Replies
Message 1 of 6

Rule to suppress features containg certain word

fakeru
Advocate
Advocate

Hi

Would it be possible that a rule can suppress all part's features that contain in their name a certain word.

I use to rename features for better workflow. More features that form a part of the model can contain same word, for instance "foot": foot_extrusion; foot_plate and so on.

When working with ilogic I have to specify each feature name, but I was thinking that may be would be easier to suppress the features by their name.

 

Thanks

Alexandru

Autodesk Inventor 2015 Certified Professional
0 Likes
Accepted solutions (1)
930 Views
5 Replies
Replies (5)
Message 2 of 6

rossano_praderi
Collaborator
Collaborator
Accepted solution

Hi Alexandru,

this piece of code che be your solution...

 

Sub Main
	Fsuppress(True)
	Fsuppress(False)
End Sub

Private Sub Fsuppress(suppress As Boolean)
myparam = InputBox("Feature Name", "Feature suppress", "")
If myparam <> "" Then
	Dim oDoc as PartDocument
	oDoc = ThisApplication.ActiveDocument
	Dim oFeature As PartFeature
	For Each oFeature In oDoc.ComponentDefinition.Features
		If oFeature.Name.ToUpper.Contains(myparam.ToUpper) Then
			oFeature.Suppressed = suppress
			oDoc.Update
		End If
	Next
End If
End Sub

 Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Message 3 of 6

fakeru
Advocate
Advocate

Thank you, this is almost what I wanted.

The difference is that, I don't need the input window.

For example I want a rule when it will be run to suppress al features with "nozzle" word in their name.

I tried to adapt the code, but didn't manage 😞

 

Autodesk Inventor 2015 Certified Professional
0 Likes
Message 4 of 6

rossano_praderi
Collaborator
Collaborator

Hi Fakeru, let me know if this is helpful to you.

 

myparam = "YOUR TEXT"
Dim oDoc as PartDocument
oDoc = ThisApplication.ActiveDocument
Dim oFeature As PartFeature
For Each oFeature In oDoc.ComponentDefinition.Features
  If oFeature.Name.ToUpper.Contains(myparam.ToUpper) Then
	oFeature.Suppressed = True
	oDoc.Update
  End If
Next

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
0 Likes
Message 5 of 6

fakeru
Advocate
Advocate

Yes, it works! Thank you so much!

Autodesk Inventor 2015 Certified Professional
0 Likes
Message 6 of 6

rossano_praderi
Collaborator
Collaborator
You are welcome.


--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
0 Likes