Inventor General Discussion

Inventor General Discussion

Reply
Distinguished Contributor
Infoseeker
Posts: 195
Registered: ‎03-15-2012
Message 1 of 34 (1,947 Views)
Accepted Solution

ILogic help needed!

1947 Views, 33 Replies
09-04-2012 11:42 AM

Is it possible to have iLogic rule create parts lists out of View Representations?

 

http://forums.autodesk.com/t5/Autodesk-Inventor/View-representation-parts-list-error/m-p/3606706/hig...

Hi Inventor users,

 

Here's the code snippets above combined into a rule that sets the BOM structure to Reference if the component is not visible.

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

 

' set a reference to the assembly component definintion.
' This assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
'check for and skip virtual components
If Not TypeOf oOccurrence.Definition Is VirtualComponentDefinition Then
'set BOM as default if the component is visible
If Component.Visible(oOccurrence.Name) = True Then
Component.InventorComponent(oOccurrence.Name).BOMStructure = _
BOMStructureEnum.kDefaultBOMStructure
'set BOM as reference if the component is not visible
ElseIf Component.Visible(oOccurrence.Name) = False Then
Component.InventorComponent(oOccurrence.Name).BOMStructure = _
BOMStructureEnum.kReferenceBOMStructure
End If
Else
End If
Next

 

*Expert Elite*
mcgyvr
Posts: 6,928
Registered: ‎12-01-2004
Message 2 of 34 (1,935 Views)

Re: ILogic help needed!

09-04-2012 11:57 AM in reply to: Infoseeker

tagging along..

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

-------------------------------------------------------------------------------------
2015 Product Design Suite Ultimate
Windows 7 64 bit
Core i7 4820k processor (OC'd to 4.4Ghz), Nvidia GTX 770, 16G RAM


*Expert Elite*
Curtis_Waguespack
Posts: 2,930
Registered: ‎03-08-2006
Message 3 of 34 (1,923 Views)

iLogic set BOM via LOD

09-04-2012 01:54 PM in reply to: Infoseeker

Hi  Infoseeker,

 

If you are use the iLogic function IsActive to suppress component instances, their BOM structure is set to Reference. Therefore the suppressed occurrence, and only that occurrence will be removed from the BOM.

 

So IsActive not only suppresses the occurrence it also set's it's BOM structure as if you'd right clicked on it and selected BOM Structure > Reference. Recall that this is different that setting the BOM structure in the BOM editor or via the Document Settings, those 2 methods set it per file, rather than per assembly occurrence.

 

With this in mind here is an example rule. In this rule you select an item (on screen or in the browser, and it will be toggled on/off, and removed or added to the BOM. This is just a quick example to demonstrate the concept.

 

But to speak to the original request: I suspect you could use this idea to look at each occurrence in an assembly and check it's visibility setting (per the current Design View Representation) and then toggle the BOM structure for that occurrence to Reference if the occurrence is not visible.

 

I'm short on time, so I can't have a look at this anytime soon, but I thought I'd throw this out in case someone else wants to give it a shot.

 

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

'set a reference to the assembly component definition.
'this assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'get currently selected component
Dim oOccurrence as ComponentOccurrence

Try
  oOccurrence = ThisDoc.Document.SelectSet.Item(1)
Catch
  MessageBox.Show("Please select a component before running this rule.", "iLogic")
  Return
End Try

'set the selected item
'oOccurrence = ThisApplication.ActiveDocument.SelectSet.Item(1)

'activate the Master LOD so we can read in the names of all the components
oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations("Master").Activate
InventorVb.DocumentUpdate(False)

'define an arraylist to hold the list of  LOD rep names
Dim NameList As New ArrayList()

'define LOD rep 
Dim oLODRep As LevelOfDetailRepresentation

'Look at the LOD reps in the assembly
For Each oLODRep In oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations
'set the list of names to the array list
NameList.add(oLODRep.Name)
Next

'check for an iLogic LOD rep and create it if not found
If Not NameList.Contains("iLogic LOD") Then
	'create iLogic LOD 
	oLODRep = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Add("iLogic LOD") 
	oLODRep.Activate
Else 
oLODRep.Activate
End If

'Toggle the selected component's active status
If Component.IsActive(oOccurrence.Name) = True Then
Component.IsActive(oOccurrence.Name) = False
Else
Component.IsActive(oOccurrence.Name) = True
End If

'Save File (set LOD changes)
ThisDoc.Save

 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





*Expert Elite*
mrattray
Posts: 2,501
Registered: ‎09-13-2011
Message 4 of 34 (1,921 Views)

Re: iLogic set BOM via LOD

09-04-2012 02:01 PM in reply to: Curtis_Waguespack

I think it would be much more user friendly if we toggled the bom structure directly instead of using isactive. This way we needn't deal with any LOD headaches.

 

You can use these snippets to control the bom structure at the assembly level:

Component.InventorComponent("occurence").BOMStructure = BOMStructureEnum.kDefaultBOMStructure
Component.InventorComponent("occurence").BOMStructure = BOMStructureEnum.kReferenceBOMStructure

 

You could then use a loop to cycle through each occurence checking it's visibility setting per Curtis's suggestion and set it's bom structure accordingly.

 

 

Mike (not Matt) Rattray

*Expert Elite*
Curtis_Waguespack
Posts: 2,930
Registered: ‎03-08-2006
Message 5 of 34 (1,917 Views)

Re: iLogic set BOM via LOD

09-04-2012 02:04 PM in reply to: mrattray

Hi mrattray,

I think you're spot on. And here's a snippet I had on hand, to iterate though the component occurrences of the assembly  in case it helps someone.

 

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

 

' set a reference to the assembly component definintion.
' This assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
'check for and skip virtual components
'(in case a virtual component trips things up)
If Not TypeOf oOccurrence.Definition Is VirtualComponentDefinition Then
'Show occurrence name In the message box body
MessageBox.Show(oOccurrence.Name, "iLogic")
Else
End If
Next

 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





*Expert Elite*
Curtis_Waguespack
Posts: 2,930
Registered: ‎03-08-2006
Message 6 of 34 (1,872 Views)

iLogic set BOM via Visibility

09-06-2012 01:45 PM in reply to: Infoseeker

Hi Inventor users,

 

Here's the code snippets above combined into a rule that sets the BOM structure to Reference if the component is not visible.

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

 

' set a reference to the assembly component definintion.
' This assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
'check for and skip virtual components
If Not TypeOf oOccurrence.Definition Is VirtualComponentDefinition Then
	'set BOM as default if the component is visible
	If Component.Visible(oOccurrence.Name) = True Then
	Component.InventorComponent(oOccurrence.Name).BOMStructure = _
	BOMStructureEnum.kDefaultBOMStructure
	'set BOM as reference if the component is not visible
	ElseIf Component.Visible(oOccurrence.Name) = False Then
	Component.InventorComponent(oOccurrence.Name).BOMStructure = _
	BOMStructureEnum.kReferenceBOMStructure
	End If
Else
End If
Next

 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Distinguished Contributor
Infoseeker
Posts: 195
Registered: ‎03-15-2012
Message 7 of 34 (1,859 Views)

Re: ILogic help needed!

09-06-2012 02:32 PM in reply to: Infoseeker

Awesome! Thanks.

This rule needs to be added to the .idw or .iam?

Distinguished Contributor
Infoseeker
Posts: 195
Registered: ‎03-15-2012
Message 8 of 34 (1,856 Views)

Re: ILogic help needed!

09-06-2012 02:37 PM in reply to: Infoseeker

I guess assembly.

Distinguished Contributor
Infoseeker
Posts: 195
Registered: ‎03-15-2012
Message 9 of 34 (1,849 Views)

Re: ILogic help needed!

09-06-2012 02:50 PM in reply to: Infoseeker

Does not work for me, maybe because I also use in my parts list substitute and grouping option... Or I am just missing something.

*Expert Elite*
mrattray
Posts: 2,501
Registered: ‎09-13-2011
Message 10 of 34 (1,816 Views)

Re: ILogic help needed!

09-07-2012 07:48 AM in reply to: Infoseeker

How does it not work? Is there an error message? Did you put it in the assembly?(it has no business being in the idw) Does it do something unexpected? We need more information than "it doesn't work" if we're going to be of any help to you. Can you post the files here?

Mike (not Matt) Rattray

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.