iLogic to Update Styles

iLogic to Update Styles

b.mccarthy
Collaborator Collaborator
328 Views
9 Replies
Message 1 of 10

iLogic to Update Styles

b.mccarthy
Collaborator
Collaborator

Hello.

 

I have been using this code to update styles to match the my client's standard. I found it on the forums, but cannot seem to locate the original poster:

 

Imports System.Windows.Forms


'Updates Drawing Styles To match active standard
Dim oCM As CommandManager = ThisApplication.CommandManager
Dim oCD As ControlDefinitions = oCM.ControlDefinitions
Dim oUpdateStyles As ControlDefinition = oCD.Item("UpdateStylesCmd")
oUpdateStyles.Execute2(False)
SendKeys.SendWait("Y ")

 It worked seamlessly for parts, assemblies and drawings, at least until I upgraded to 2027. I have migrated all of my styles using the Style Library Manager 2027.

 

I ran the code on a migrated 2026 idw but noticed that the table line colors which had previously been set to white...

 

2026-04-15 1232.png   2026-04-15 1234.png

 

...are being reset:

 

2026-04-15 1235.png   2026-04-15 1236.png

 

Anyone have any idea why this is happening?

 

TIA

0 Likes
329 Views
9 Replies
Replies (9)
Message 2 of 10

WCrihfield
Mentor
Mentor

Hi @b.mccarthy.  The code example looks like it simply simulates the manual user actions of clicking on the 'Update' button on the [Manage tab -> Styles and Standards panel], then clicking the 'Yes to All' button (Y), then clicking the 'OK' button (space).  If any colors changed, it should have been because a style in the 'global styles library' had a different color than the local style that it overwrote during the update step.  Those specific color settings can actually be found in two different locations within the Inventor API.  Under the TableFormat object, and under the TableStyle object.  I believe the TableStyle is the primary source of drawing table appearance settings, then the TableFormat can be used sort of like an overlay or override to a subset if its appearance related properties where 'custom' tables are concerned.

TableFormat.InsideLineColor 

TableFormat.OutsideLineColor 

TableStyle.InsideLineColor 

TableStyle.OutsideLineColor 

There are normal Inventor API ways of purging and/or updating most 'styles' found in parts, assemblies, and drawings, but unfortunately, there are still a few 'special' types of styles that can not seem to be reached through the API properties/methods.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 10

b.mccarthy
Collaborator
Collaborator

@WCrihfield

 

Thank you for the explanation. That is what I am expecting, and what occurred in 2026 and earlier.

 

I am still unclear on the how & why the code changes the settings I make to the active standard. Should these not persist?

0 Likes
Message 4 of 10

WCrihfield
Mentor
Mentor

As far as I know, nothing about the migration process should change any colors, within any styles, within any of the global style libraries.  And since using the Update tool overwrites styles stored within the local document with styles of the same type and same name from the 'active' global styles library, that update step should not be changing any colors of any local styles unless the global library version of a style is simply set to different colors than the local style is set to.  I would caution to just make sure Inventor is set to the correct/expected global styles library before doing the updates.  It is also possible that a local style could be created and named, without knowing that the same type of style, with the same name, already exists in the global styles library, and the two have nothing to do with each other, but if an update is performed, the local one gets overwritten by the one in the library with the same name, which may be unintended/unexpected.  If the global style's colors and the local style's colors appear to be identical when reviewed within their respective dialogs, but it is still changing a color on update, then I would say there may be a 'bug' in the process somewhere.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 10

b.mccarthy
Collaborator
Collaborator

@WCrihfield 

 

Thank you for your take on this.

 

I am hesitant to accept this as a solution, as Autodesk has not weighed in. If it is a "bug" as you believe, then Autodesk should research and provide a solution.

0 Likes
Message 6 of 10

WCrihfield
Mentor
Mentor

We may have to 'tag' one or more actual Autodesk employees here, to get their attention on this topic.  I noticed that River Cai @Yijiang.Cai  has been active on the main Inventor Forum lately, and is one who specialize in Inventor, so lets tag him on this.  I hope River doesn't mind, but we're not getting anywhere here without some 'inside' help.  If he is not the right person, or does not know the answer, he probably does know someone more appropriate at Autodesk who could look into this for us.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 10

b.mccarthy
Collaborator
Collaborator

Sounds like a plan. You are the only person responding, so another pair of eyes will be nice...

0 Likes
Message 8 of 10

JelteDeJong
Mentor
Mentor

When you send the key, I assume the "Y" is meant to confirm the "Yes to all" prompt. However, when I test this manually in 2027, the update appears to be applied only to the first style. I am not sure if this behavior was different in older Inventor versions.

afbeelding.png

Because of that, the SendKeys approach may no longer reliably update all styles.


You may get more consistent results by bypassing the command dialog entirely and updating the styles directly through the API. The following iLogic code updates all styles that exist both locally and in the library.

Dim doc As DrawingDocument = ThisDoc.Document

For Each style As Style In doc.StylesManager.Styles
    If (Style.StyleLocation <> StyleLocationEnum.kBothStyleLocation) Then Continue For
    Style.UpdateFromGlobal()
Next

This avoids UI automation. Howevere as @WCrihfield  pointed out you need to test this because some styles might not update as expected.

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 9 of 10

b.mccarthy
Collaborator
Collaborator

@JelteDeJong 

 

Thank you. The code seems to be functioning, although I Have only tested it on a few drawings.

 

@WCrihfield 

 

Thank you for your input, as well.

 

When Autodesk has chimed in with an explanation as to why this occurs in 2027, but not earlier versions, I will mark this as accepted solution.

0 Likes
Message 10 of 10

b.mccarthy
Collaborator
Collaborator

I spoke too soon...

 

While the styles do not change for the table line colors, section line tags do not respect the Style Manger settings.

 

I created a View Annotation Style many years ago:

2026-04-26 1238.png

 

These are the Text Style settings:

2026-04-26 1239.png

 

When I create a new section on a migrated drawing, the annotation styles does not match the standard (Section B-B was added in 2026):

2026-04-26 1240.png

 

These are the view settings for Section D-D:

2026-04-26 1241.png

 

You can see that the Text Style is set to Tahoma .1, but the text is coming in as Arial.

 

In addition to this, The <VIEW SHEET INDEX> property is not populating either. This is inconsistent behavior. These are on the same sheet:

2026-04-26 1242.png

 

Only View A-A populates correctly.

 

0 Likes