Exclude components using iLogic?

Exclude components using iLogic?

Anonymous
Not applicable
2,365 Views
8 Replies
Message 1 of 9

Exclude components using iLogic?

Anonymous
Not applicable

Is it possible to Exclude components using iLogic? I know how to disable or suppress, but I would like to exclude them instead - as this will also suppress all related constraints.

0 Likes
Accepted solutions (1)
2,366 Views
8 Replies
Replies (8)
Message 2 of 9

clutsa
Collaborator
Collaborator
Accepted solution

It's as easy as you hope it would be

Rod50 = Component.InventorComponent("ROD_50")
Rod50.Excluded = True

or if you really want to save lines of code

Component.InventorComponent("<Your part name>").Excluded = True

 and of course =false to "unexclude" 

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

Message 3 of 9

clutsa
Collaborator
Collaborator

Here is also some bonus code so that the parts can be removed on the drawing.

Dim doc As AssemblyDocument
doc = ThisDoc.Document
compDef = doc.ComponentDefinition
For Each part In compDef.Occurrences
        If part.Excluded Then 
		part.BOMStructure = BOMStructureEnum.kReferenceBOMStructure
	Else
		part.BOMStructure = BOMStructureEnum.kDefaultBOMStructure
	End If
Next

Then in the "Drawing View" wizard under the "Model State" tab in the "Reference Data" section change "Line Style" to "Off" 

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 4 of 9

Anonymous
Not applicable

Great, thanks!

0 Likes
Message 5 of 9

meck
Collaborator
Collaborator

This works fine.

Is there a way to specify a sub-assembly's occurrence name and exclude a component in only that sub-assembly. Your code will exclude the component in all sub-assemblies that have it.

Just trying to raise the bar. 😁

 

Any suggestions would be greatly appreciated!

Mike

Mike Eck
Master Drafter/ CAD Programmer
Using Inventor 2018
0 Likes
Message 6 of 9

clutsa
Collaborator
Collaborator

Couple of things on this subject. Before Inv2021 you could .Exclude a component in a regular assembly (non-iAssembly Factory) but you evidently were not supposed to because .Exclude was only supposed to be for iAssembly factories. That said you can still use .Exclude in Inv2021 but only on iAssembly Factories (they "fixed the glitch" so Milton is no longer receiving a paycheck in 2021.😭)

@meck For your question I believe the only way you could achieve what you're asking (in Inv2018) is to have the parts be different members of the same iAssembly Factory. Give them unique member names but the same part number and then switch between members.

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 7 of 9

Mario.van.der.raaf
Enthusiast
Enthusiast

I am trying to include and exclude parts based on your syntax above: 

Component.InventorComponent("ASME B16.5 Flange Welding Neck - Class 150 20:1").Excluded = True

But get the following error 

Mariovanderraaf_0-1667812076770.png

Mariovanderraaf_1-1667812086725.png

 

This is in an assembly where I am moving from using iAssembly's to only using iLogic. The reason for this is because some changes in my parametric model require iAssemblys to be regenerated. This regenerating takes place for all iAssembly configurations and therefore takes a lot of time.

 

Do I understand correctly that Component.InventorComponent.exlude is no longer available from Inventor 2021 and on?

 

0 Likes
Message 8 of 9

clutsa
Collaborator
Collaborator

Sorry for the late response. I'm a bit rusty on the topic but that sounds right. You can now only use the .exclude on iAssemblies. If you are using 2022 you can look into Model States that may be able to do what you want. I haven't had to use them yet but this post seems like a good start. 

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/create-model-states-using-ilogic/m-p... 

When I was forced to move away from .exclude I moved to ThisAssembly.BeginManage() and it's amazing! Completely changed the game. The answer in this post uses a drawing as an example, not an assembly, but it's the same concept. Wish I could find a better post about BeginManage

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/ilogic-beginmanage-and-endmanage-why... 

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

Message 9 of 9

Mario.van.der.raaf
Enthusiast
Enthusiast

Thanks for the reply, I have changed my model to use suppressions and model states. This has led me to another problem which I describe in this post: Re: Suppressing part within a nested assembly using iLogic - Autodesk Community - Inventor

0 Likes