Suppress component in a pattern by clicking

Suppress component in a pattern by clicking

tomislav.peran
Advocate Advocate
368 Views
5 Replies
Message 1 of 6

Suppress component in a pattern by clicking

tomislav.peran
Advocate
Advocate

@J-Camper 

 

Hello,

 

I saw on the following link an interesting code on how to suppress components by clicking.

 

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/ilogic-suppress-component/td-p/10072...

 

Sub Main
	If ThisApplication.ActiveDocumentType <> kAssemblyDocumentObject Then MessageBox.Show("This rule is designed to only work in assembly documents.", "Wrong Document Type") : Exit Sub
	
	Dim PickLeafOC As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select a Component to Supress")
	If IsNothing(PickLeafOC) Then Exit Sub ' If nothing gets selected then we're done
	
	PickLeafOC.Suppress()
	
End Sub

 

Is there a way to suppress a component that is in a pattern?

 

Regards,

Tom

0 Likes
Accepted solutions (2)
369 Views
5 Replies
Replies (5)
Message 2 of 6

SevInventor
Advocate
Advocate
Accepted solution

sorry misunderstood the question

0 Likes
Message 3 of 6

tomislav.peran
Advocate
Advocate

Hi SevInventor

 

I tested the code this morning and it did not work. Now it works. I am not sure what happened.

 

Do you know by any chance how to repeat this command so that it is not necessary to click the rule every time?

 

Tom

0 Likes
Message 4 of 6

tomislav.peran
Advocate
Advocate

To have the code repeating itself:

 

Do
	If ThisApplication.ActiveDocumentType <> kAssemblyDocumentObject Then MessageBox.Show("This rule is designed to only work in assembly documents.", "Wrong Document Type") : Exit Sub
	
	Dim PickLeafOC As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select a Component to Supress")
	If IsNothing(PickLeafOC) Then Exit Sub ' If nothing gets selected then we're done
	
	PickLeafOC.Suppress()
	
Loop

 I will double-test things next time before posting. 

 

Thanks,

Tom

0 Likes
Message 5 of 6

SevInventor
Advocate
Advocate
Accepted solution
Sub Main
	
	here:
	If ThisApplication.ActiveDocumentType <> kAssemblyDocumentObject Then MessageBox.Show("This rule is designed to only work in assembly documents.", "Wrong Document Type") : Exit Sub
	
	Dim PickLeafOC As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select a Component to Supress")
	If IsNothing(PickLeafOC) Then Exit Sub ' If nothing gets selected then we're done
	
	PickLeafOC.Suppress()
	
	GoTo here
	
End Sub
Message 6 of 6

tomislav.peran
Advocate
Advocate

Hi Sev,

 

Super. I do not have to remove Sub Main then.

 

Thanks,

Tom