Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
m.maertens6DTZT
867 Views, 4 Replies

update styles library

Hello,

I'm Maarten and I'm trying to create a macro that allows me to update my entiry library from 2016 to 2018 automatically.
The library contains Parts, Iparts and iLogic components (assemblies).

So, 

Let me first explain the steps that I need to follow when I must do this manually.

1. Open the iPart - masterfile on toplevel and modify the iproperties by adding a new Authority nr. (I need to modify this for our ERP system)
2. Update all styles ( Tab Manage) 
3. Save

Then I insert this ipart into an assembly, update the style library and create all the variants according to the excell table.

I create all the parts by using following code:

 

2018-02-16 08_26_55-Edit Rule_ CreateAlliParts.png

And then all the parts are made.

 

But, I don't want to do this for all the iParts of my library.

What I want is to update styles, add authority nr, create all the variants in 1 action.

1. Insert ALL the iParts + parts in an assembly -

2. Press 1 button and the computer does the rest. 

 

I created the following script, but I can't manage to update the COLOR styles of the part.

See below

 

Sub UpdateToNewRelease()

'Add a New Stock Number (switch to new structure in 2018)


' step 1 Declare stuff
    Dim oAssyDoc As AssemblyDocument
    Dim oComponent As ComponentOccurrence
    Dim oRefDoc As PartDocument
    Dim invCustomPropertySet As PropertySet
    Dim PropAuthority As Property
    Dim oPartDoc As PartDocument
    Dim oFactoryDoc

    Set oAssyDoc = ThisApplication.ActiveDocument

' step 2 - ask user for value of iproperty
    Dim AuthorityNr As String
    AuthorityNr = InputBox("What is the new Authority Number (Old Stock Number)", "Set Number", "")

' step 2 get a reference to each part
        For Each oComponent In oAssyDoc.ComponentDefinition.Occurrences
        If oComponent.IsiPartMember = False Then
            'change the part Authority number directly
            
          
          'set the Autority iProperty's
            Set oRefDoc = oComponent.ReferencedDocumentDescriptor.ReferencedDocument
            Set invCustomPropertySet = oRefDoc.PropertySets.Item("Design Tracking Properties")
            Set PropAuthority = invCustomPropertySet.Item("Authority")
            PropAuthority.Value = AuthorityNr
       Else
            'it is an ipart
            'open the ipart and change the numnber
                Set oPartDoc = oComponent.ReferencedDocumentDescriptor.ReferencedDocument
                Set oFactoryDoc = oPartDoc.ReferencedDocumentDescriptors.Item(1).ReferencedDocument
                       
            'change the Autority Number of the factory document
                Set invCustomPropertySet = oFactoryDoc.PropertySets.Item("Design Tracking Properties")
                Set PropAuthority = invCustomPropertySet.Item("Authority")
PropAuthority.Value = AuthorityNr 'update styles Dim mat As Material For Each mat In oFactoryDoc.Materials If mat.UpToDate = False Then Call mat.UpdateFromGlobal Debug.Print mat.Name End If Next End If Next End Sub

 

When i open the ipart to verify - then I see that the authority nr is filled in, but the color is not updated automatically.

see below

Color styles.jpg

 

 

Is there someone that can help me out how I can update the style libraries (type color) automatically??

That would be great!

 

Thanks a lot.

 

 

 

 

Why not using task schedular?

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

nbarbars
in reply to: m.maertens6DTZT

If anyone from AutoDesk could take a look at this, I'm struggling with the same issue. I'm new to coding and ilogic and any help would be much appreciated. Looks like this has gone unanswered for a few years... @chandra.shekar.g  I saw you helped some people with ilogic, any chance you can help us out here?

dusan.naus.trz
in reply to: nbarbars