auto update all styles in ipt

auto update all styles in ipt

Anonymous
Not applicable
1,060 Views
8 Replies
Message 1 of 9

auto update all styles in ipt

Anonymous
Not applicable

Good afternoon,

 

     Looking for vba code that would automatically update all styles when you open a ipt.  If anyone would be willing to share that would be great.

 

Thank you.

0 Likes
1,061 Views
8 Replies
Replies (8)
Message 2 of 9

sajith_subramanian
Autodesk Support
Autodesk Support

Hi fishermanfry,

 

Below is a piece of Ilogic code that may be something similar to what you are looking for.

 

If ThisApplication.ActiveDocumentType = kPartDocumentObject Then
    Dim doc As PartDocument
    doc = ThisApplication.ActiveDocument
    Dim style As LightingStyle
    For Each style In doc.LightingStyles
        If style.UpToDate = False Then
         style.UpdateFromGlobal
        End If
    Next
End If

 

 

If you want this rule to run automatically when an ipt is opened, you can hook it up to the "After Open Document" trigger.

 

Let me know if this helps.

 

Regards,

Sajith


Sajith Subramanian
Autodesk Developer Network
0 Likes
Message 3 of 9

reine_den_andra
Contributor
Contributor

Hi

I cant´t make this work.
Can you try to specify little more?
I am making a new rule with this and make a trigger for it, but I cant make it work.
I am using Inventor 2019.
/Reine
0 Likes
Message 4 of 9

sajith_subramanian
Autodesk Support
Autodesk Support

Hi @reine_den_andra,

 

Once you create your rule, navigate to Manage -> Event Triggers. This will show up a new dialog as shown below

Now you will see the rule you created in the left panel. Click and drag it over to the required event (in this case, I have dragged it to the "After Open Document"). Your rule will then show up on the right tab under the selected event.

 

iLogic.PNG 

 

Your rule should now be automatically triggered when the selected event fires. 

Hope this helps. 

 

Regards,

Sajith


Sajith Subramanian
Autodesk Developer Network
0 Likes
Message 5 of 9

reine_den_andra
Contributor
Contributor

Hi

Yes, I have done all that. But when I open an old part the rule is not there?

It is only there when I create an new part.

/Reine

0 Likes
Message 6 of 9

sajith_subramanian
Autodesk Support
Autodesk Support

Hi @reine_den_andra,

 

Not sure if I understood your question, but are you using an external rule in your case? Otherwise it would be applicable only for the open document.

 

Regards,

Sajith


Sajith Subramanian
Autodesk Developer Network
0 Likes
Message 7 of 9

reine_den_andra
Contributor
Contributor

Hi

Ok, lets start over. 😁

When I open and old part with old styles.

I want that old part to auto update all styles to match my styles library.

Is that possible?

/Reine

0 Likes
Message 8 of 9

sajith_subramanian
Autodesk Support
Autodesk Support

Hi @reine_den_andra,

 

Yes, it should be possible. You would need to call the UpdateFromGlobal API from the required object. 

Now for example, in the case of materials :

https://forums.autodesk.com/t5/inventor-customization/updatefromglobal-for-materials/m-p/5102012/hig...

 

Regards,

Sajith


Sajith Subramanian
Autodesk Developer Network