• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor

    Reply
    Distinguished Contributor
    Posts: 183
    Registered: ‎03-15-2012
    Accepted Solution

    ILogic help needed!

    961 Views, 30 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...

    Please use plain text.
    *Expert Elite*
    Posts: 5,604
    Registered: ‎12-01-2004

    Re: ILogic help needed!

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

    tagging along..

    Please click "Accept as Solution" if this response answers your question.
    -------------------------------------------------------------------------------------
    2012 Product Design Suite Ultimate
    Windows 7 64 bit
    90G OCZ SATA 3 SSD (My SSD is faster than your HDD)
    Core I7 920 processor, ATI HD6970 graphics card, 12G Corsair RAM


    Please use plain text.
    *Expert Elite*
    Curtis_Waguespack
    Posts: 1,964
    Registered: ‎03-08-2006

    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.

    Please use plain text.
    *Expert Elite*
    mrattray
    Posts: 1,485
    Registered: ‎09-13-2011

    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

    Please use plain text.
    *Expert Elite*
    Curtis_Waguespack
    Posts: 1,964
    Registered: ‎03-08-2006

    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.

    Please use plain text.
    *Expert Elite*
    Curtis_Waguespack
    Posts: 1,964
    Registered: ‎03-08-2006

    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.

    Please use plain text.
    Distinguished Contributor
    Posts: 183
    Registered: ‎03-15-2012

    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?

    Please use plain text.
    Distinguished Contributor
    Posts: 183
    Registered: ‎03-15-2012

    Re: ILogic help needed!

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

    I guess assembly.

    Please use plain text.
    Distinguished Contributor
    Posts: 183
    Registered: ‎03-15-2012

    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.

    Please use plain text.
    *Expert Elite*
    mrattray
    Posts: 1,485
    Registered: ‎09-13-2011

    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

    Please use plain text.