Update part list style with ilogic

Update part list style with ilogic

Anonymous
Not applicable
3,564 Views
5 Replies
Message 1 of 6

Update part list style with ilogic

Anonymous
Not applicable

Hello,

 

I recently updated my parts list styles and now I want to update some existing drawings.

I've already updated the style with the help of the Add-In ''Batch update styles''.

So far so good..

 

When I open a drawing with the updated styles, the parts list is not automatically renewed.

I must first click on the parts list and then select the parts list again in the annotate menu so that it is refreshed.

Could someone help me to get this done automatically with the help of ilogic or something similar?

 

I hope someone can help me with this! Smiley Happy

 

Regards,

Jeffrey

0 Likes
Accepted solutions (1)
3,565 Views
5 Replies
Replies (5)
Message 2 of 6

chandra.shekar.g
Autodesk Support
Autodesk Support

@Anonymous,

 

Try below iLogic code to change partslist style. Before running code, need to update the name of PartsListStyle in code.

 

Sub Main()
    Dim oDoc As DrawingDocument
    oDoc = ThisApplication.ActiveDocument
    
    Dim oStyleMgr As DrawingStylesManager
    oStyleMgr = oDoc.StylesManager
    
    Dim oPartListStyle As PartsListStyle
    oPartListStyle = oStyleMgr.PartsListStyles.Item("Parts List (ANSI-AIP)")
    
    Dim oPartsList As PartsList
    For Each oPartsList In oDoc.ActiveSheet.PartsLists
        oPartsList.Style = oPartListStyle
    Next
End Sub

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 6

Anonymous
Not applicable

@chandra.shekar.g

 

Thanks for Ilogic code.

I use 4 different part list styles.. (forgot to tell in the first message)

is it possible that the active part list is recognized and updated automatically during opening ?

 

Thanks.

 

 

Regards,

Jeffrey

0 Likes
Message 4 of 6

MechMachineMan
Advisor
Advisor
Accepted solution

I think this might be what you are looking for.

 

 

 

Sub Main()
    Dim oPL As PartsList
    For Each oSheet In ThisDoc.Document.Sheets
        For Each oPL In oSheet.PartsLists
            Call RefreshPartsListStyle(oPL)
        Next
    Next
End Sub

Sub RefreshPartsListStyle(oPartsList As PartsList)   
    
    Dim oDoc As Document
    oDoc = oPartsList.Parent.Parent

    Dim oStyleMgr As DrawingStylesManager
    oStyleMgr = oDoc.StylesManager
    
    oActivePLStyle = oPartsList.Style
   
    For Each oStyle In oStyleMgr.PartsListStyles
        If Not oStyle.Equals(oActivePLstyle)
            oNotActivePLStyle = oStyle
            Exit For
        End If
    Next
    
    oPartsList.Style = oNotActivePLStyle
    'oDoc.Update
    oPartsList.Style = oActivePLStyle
End Sub   

 


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

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 5 of 6

ramji.m
Participant
Participant

Hi ,

Can you help me with API TO ACCESS  importing partslist.XML

 

Cause am manually importing 

edit layers --> import styles--> browse and select partslist.xml for old drawing

Message 6 of 6

Anonymous
Not applicable

@ramji.m 

I am currently looking for a solution for the same problem, importing a style file *.styxml with the API.

As far as I have found out so far, it is NOT directly possible via API. I might try to copy a current style and then reading the properties of the *.styxml and editing the new style accordingly. But I am not sure what to do with all the (dozens of) settings where I don't have direct access via the API.

 

0 Likes