Rename Parts List with iAssembly Member Part Number

Rename Parts List with iAssembly Member Part Number

dliteful
Contributor Contributor
1,053 Views
8 Replies
Message 1 of 9

Rename Parts List with iAssembly Member Part Number

dliteful
Contributor
Contributor

We use iAssembly configurations in one drawing.  I'm hoping to automate the process of renaming the Parts List to reflect the Selected Member BOM.  I found this thread, but it never got around to addressing iAssemblies.  Works perfect otherwise.  https://forums.autodesk.com/t5/inventor-forum/parts-list-title/td-p/2826607/page/2

 

To keep with our current drawing practices, View1 is always the factory file and View2 is always the member file with the Parts List associated to it.

 

I attached a PDF of a generic drawing sample.  Any help or insight down the right path would be greatly appreciated.

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

chandra.shekar.g
Autodesk Support
Autodesk Support

@dliteful,

 

Can you please provide non confidential sample data to test the feasibility?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 9

dliteful
Contributor
Contributor

Please see attached.  It's a pretty basic version.  Please let me know if you need more information.  Thank you!

0 Likes
Message 4 of 9

chandra.shekar.g
Autodesk Support
Autodesk Support

@dliteful,

 

Actually, code in this forum (https://forums.autodesk.com/t5/inventor-forum/parts-list-title/td-p/2826607/page/2) is iLogic code. Try below VBA code to update title of partslist with part number.

 

    Sub Partslist()
       
        'set a reference to the drawing document.
        ' This assumes a drawing document is active.
        Dim oDrawDoc As DrawingDocument
        Set oDrawDoc = ThisApplication.ActiveDocument
        
        'set a reference to the first parts list on the active sheet.
        'This assumes that a parts list is on the active sheet.
        Dim oPartList As Partslist
        Set oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(1)
        
        'get the document referenced by the parts list
        Dim oRef As AssemblyDocument
        Set oRef = oPartList.ReferencedDocumentDescriptor.ReferencedDocument
        
        'set parts list title to be the same as the referenced file's
        'part number iProperty
        oPartList.Title = oRef.PropertySets.Item _
        ("Design Tracking Properties").Item("Part Number").Value
            
        
    End Sub

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 5 of 9

dliteful
Contributor
Contributor

That still renames it to the factory part number which is meant to be generic for all sheets.  I want to rename it to the member part number for each part list.  See attached.  Sometimes images relate info better.

 

I prefer iLogic if possible.  I was hoping to somehow grab the iAssemblyTableCell.Value

 

Thank you again for looking at this.

0 Likes
Message 6 of 9

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@dliteful,

 

Sorry for delay response,

 

Try below VBA code which updates partslist name with 2nd view of referenced document's part number.

 

Sub Partslist()
       
        'set a reference to the drawing document.
        ' This assumes a drawing document is active.
        Dim oDrawDoc As DrawingDocument
        Set oDrawDoc = ThisApplication.ActiveDocument
        
        'set a reference to the first parts list on the active sheet.
        'This assumes that a parts list is on the active sheet.
        
        Dim oPartList As Partslist
        Set oPartList = oDrawDoc.ActiveSheet.PartsLists.Item(1)
        
        Dim oView As DrawingView
        Set oView = oDrawDoc.ActiveSheet.DrawingViews.Item(2)
        
        'get the document referenced by the parts list
        Dim oRef As AssemblyDocument
        Set oRef = oView.ReferencedDocumentDescriptor.ReferencedDocument
        
        oPartList.Title = oRef.PropertySets.Item _
        ("Design Tracking Properties").Item("Part Number").Value
            
        
    End Sub

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 7 of 9

dliteful
Contributor
Contributor

Worked perfectly.  Thank you!

0 Likes
Message 8 of 9

dliteful
Contributor
Contributor

This works perfect if I run it from each sheet, but I'd like to to cycle through each sheet's parts list.  I can't seem to get the "For Each" statement to look at the correct views.  It just refers to the active sheet I launched the rule from.

 

Thank you again.

0 Likes
Message 9 of 9

dliteful
Contributor
Contributor
Accepted solution

With a little tweaking I managed to get it to rename each Parts List after the member.  Here's the code I used if anyone needs.

 

Sub Main()

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

    Dim oSheet As Sheet
    For Each oSheet In oDrawDoc.Sheets
    
        Dim oPartList As PartsList
        For Each oPartList In oSheet.PartsLists
        
        Dim oView As DrawingView
        oView = oSheet.DrawingViews.Item(2)
        
            'get the document referenced by the parts list
                Dim oRef As AssemblyDocument
                oRef = oView.ReferencedDocumentDescriptor.ReferencedDocument
                
            'set parts list title to be the same as the referenced file's
            'part number iProperty
                oPartList.Title = oRef.PropertySets.Item _
                ("Design Tracking Properties").Item("Part Number").Value
            
    
        Next
    Next

End Sub
0 Likes