Enable/Disable part through Ilogic

Enable/Disable part through Ilogic

mslosar
Advisor Advisor
2,082 Views
3 Replies
Message 1 of 4

Enable/Disable part through Ilogic

mslosar
Advisor
Advisor

Apparently the occurrences tab setting aren't easily accessible through the code snippets in ilogic.

 

How would one go about writing a rule that, in essense, would say:

 

If x = "whatever" then

occurrence.enabled = false

else

occurrence.enabled = true

end if

 

I've been reading that LOD's and suppression aren't the best course of action for assemblies especially when you're dealing with 20-40 parts as I am. I've got an assembly and parts controlled by a spreadsheet and when things are clicked off in the spreadsheet they need to be off in the model/drawings/bills etc. I have it working (to an extent) with suppression of parts in the assembly, but that casues LOD errors in the drawings. Research says parts are best disabled which is what i'm trying to do.

 

Thanks

 

0 Likes
2,083 Views
3 Replies
Replies (3)
Message 2 of 4

mslosar
Advisor
Advisor

I think i've found it:

 

doc = ThisDoc.Document

compo= Component.InventorComponent("Part:1")

compo.Enabled= false

compo.Visible= false

 

-------

 

At this point i'm not sure what the point of enabled is when used vs suppression. Well, other than you don't have to deal with LOD issues on drawing sheets.

 

Suppression via ilogic:

Makes part invisible

Removes from bill

Removes from weight calcs

 

Enabled(Disabled):

Leaves part on screen at about 80% transparent

Still lists in bill

Still calculates it's weight in the assembly.

 

 

Message 3 of 4

MCADAEPFW
Enthusiast
Enthusiast

I am not sure if this has been answer but what I do if I want a part to be hidden and not part of the the BOM I use:

	Component.Visible("ComponentName") = False 'Invisible
	Component.InventorComponent("ComponentName").BOMStructure = BOMStructureEnum.kReferenceBOMStructure  

 and then if I need it back I use:

	Component.Visible("ComponentName") = True 'Visible
	Component.InventorComponent("ComponentName").BOMStructure = BOMStructureEnum.kDefaultBOMStructure  

 

Found this is the best way to create an iLogic assembly and not have to use LOD. 

 

 

0 Likes
Message 4 of 4

dutt.thakar
Collaborator
Collaborator

The best way I would deal with this issue is to use Visibility and Invisibility of the components that are needed in specific configurations. LOD's and suppressing components are not meant for this purpose they are used to reduce the amount of details in Large assemblies and unload them from your memory to increase the performance. even when you suppress the component, it does not go away from Bill of Materials.

 

You can use as, @MCADAEPFW  has mentioned, Component.Visible("Component Name") = True/False snippet to hide or unhide the components in your assembly the best way I found is, just use the above snippet as per your logic so for an example, 

 

If x = "true"

Component.Visible("Bracket-1") = True

Component.Visible("Bracket-2") = False

Else if x = "False"

Component.Visible("Bracket-1") = False

Component.Visible("Bracket-2") = True

End If

 

 

To change the BOM properties of visible and invisible components automatically rather than writing line for each component to change the BOM Structure, use below code which will run after you are done with visibility and invisibility stuff. I really find this handy as it automatically check whether your component is visible or not in the assembly and then automatically change its BOM properties. Imagine if you have 50 components that you are changing in each configuration and writing 50 lines to change BOM structure of each component

 

Dim oDef As AssemblyComponentDefinition = ThisApplication.ActiveDocument.ComponentDefinition
 
For Each oOcc As ComponentOccurrence In oDef.Occurrences
	If oOcc.Visible = True Then
		oOcc.BOMStructure = BOMStructureEnum.kDefaultBOMStructure
	Else
		oOcc.BOMStructure = BOMStructureEnum.kReferenceBOMStructure
	End If
Next

 

I hope this helps, If this has answered your question, please accept this as solution.

 

Regards,

Dutt Thakar

 

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes