Hi,
I want to update all styles in a 3D-document with VBA. I'm using Inventor 2018.3.3 (German).
I already wrote a code, that updates LightingStyles, TextStyles, RenderStyles, Materials and SheetMetalStyles, but I cannot find APIs for the last two styles (see picture). Are there any APIs to update these "DimensionStyles" and "StandardStyles" from 3D Annotations?
If anyone needs it, here is my code:
Public Sub Refresh3D_Styles()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
'Beleuchtungsstile
Dim oLightingStyle As LightingStyle
For Each oLightingStyle In oDoc.LightingStyles
If oLightingStyle.UpToDate = False Then
oLightingStyle.UpdateFromGlobal
End If
Next
'Textstile
Dim oTextStyle As TextStyle
For Each oTextStyle In oDoc.TextStyles
If oTextStyle.UpToDate = False Then
oTextStyle.UpdateFromGlobal
End If
Next
'Darstellungen (Farben)
Dim oRenderStyle As RenderStyle
For Each oRenderStyle In oDoc.RenderStyles
If oRenderStyle.UpToDate = False Then
oRenderStyle.UpdateFromGlobal
End If
Next
'Materialien
Dim oMaterial As Material
For Each oMaterial In oDoc.Materials
If oMaterial.UpToDate = False Then
oMaterial.UpdateFromGlobal
End If
Next
'Blechstile
If oDoc.ComponentDefinition.Type = kSheetMetalComponentDefinitionObject Then
Dim oSheetMetalStyle As SheetMetalStyle
For Each oSheetMetalStyle In oDoc.ComponentDefinition.SheetMetalStyles
If oSheetMetalStyle.UpToDate = False Then
oSheetMetalStyle.UpdateFromGlobal
End If
Next
End If
End Sub
Kind regards
Michael
Solved! Go to Solution.
Hi,
I want to update all styles in a 3D-document with VBA. I'm using Inventor 2018.3.3 (German).
I already wrote a code, that updates LightingStyles, TextStyles, RenderStyles, Materials and SheetMetalStyles, but I cannot find APIs for the last two styles (see picture). Are there any APIs to update these "DimensionStyles" and "StandardStyles" from 3D Annotations?
If anyone needs it, here is my code:
Public Sub Refresh3D_Styles()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
'Beleuchtungsstile
Dim oLightingStyle As LightingStyle
For Each oLightingStyle In oDoc.LightingStyles
If oLightingStyle.UpToDate = False Then
oLightingStyle.UpdateFromGlobal
End If
Next
'Textstile
Dim oTextStyle As TextStyle
For Each oTextStyle In oDoc.TextStyles
If oTextStyle.UpToDate = False Then
oTextStyle.UpdateFromGlobal
End If
Next
'Darstellungen (Farben)
Dim oRenderStyle As RenderStyle
For Each oRenderStyle In oDoc.RenderStyles
If oRenderStyle.UpToDate = False Then
oRenderStyle.UpdateFromGlobal
End If
Next
'Materialien
Dim oMaterial As Material
For Each oMaterial In oDoc.Materials
If oMaterial.UpToDate = False Then
oMaterial.UpdateFromGlobal
End If
Next
'Blechstile
If oDoc.ComponentDefinition.Type = kSheetMetalComponentDefinitionObject Then
Dim oSheetMetalStyle As SheetMetalStyle
For Each oSheetMetalStyle In oDoc.ComponentDefinition.SheetMetalStyles
If oSheetMetalStyle.UpToDate = False Then
oSheetMetalStyle.UpdateFromGlobal
End If
Next
End If
End Sub
Kind regards
Michael
Solved! Go to Solution.
Solved by WCrihfield. Go to Solution.
Solved by bindlmi. Go to Solution.
I've just been using this simple Macro, with a custom button on my ribbon.
It uses the built-in Styles & Standards Updater tool. After it activates that tool, it simulates clicking the "Yes to All" button, then pressing Enter.
Sub Update_All_Styles_And_Materials()
Dim oCM As CommandManager
Set oCM = ThisApplication.CommandManager
Dim oCD As ControlDefinitions
Set oCD = oCM.ControlDefinitions
Dim oUpdateStyles As ControlDefinition
Set oUpdateStyles = oCD.Item("UpdateStylesCmd")
oUpdateStyles.Execute2 (False)
AppActivate (ThisApplication.Caption)
SendKeys "{Y} + { }"
ThisApplication.UserInterfaceManager.DoEvents
End Sub
Wesley Crihfield
(Not an Autodesk Employee)
I've just been using this simple Macro, with a custom button on my ribbon.
It uses the built-in Styles & Standards Updater tool. After it activates that tool, it simulates clicking the "Yes to All" button, then pressing Enter.
Sub Update_All_Styles_And_Materials()
Dim oCM As CommandManager
Set oCM = ThisApplication.CommandManager
Dim oCD As ControlDefinitions
Set oCD = oCM.ControlDefinitions
Dim oUpdateStyles As ControlDefinition
Set oUpdateStyles = oCD.Item("UpdateStylesCmd")
oUpdateStyles.Execute2 (False)
AppActivate (ThisApplication.Caption)
SendKeys "{Y} + { }"
ThisApplication.UserInterfaceManager.DoEvents
End Sub
Wesley Crihfield
(Not an Autodesk Employee)
Nice idea, I thought about this too, but didnt know it is so easy to simulate clicks or how to "click" the buttons.
So, this works in my active document, but does it also work through all subdocuments of an assembly in a loop? I guess I would have to press enter for each subdocument.
Nice idea, I thought about this too, but didnt know it is so easy to simulate clicks or how to "click" the buttons.
So, this works in my active document, but does it also work through all subdocuments of an assembly in a loop? I guess I would have to press enter for each subdocument.
I haven't tried drilling it down through an assembly yet, but I'm guessing that if you use something like "oRefDoc.Activate()", before running this macro, it might work, because, you'll notice the macro doesn't specify ThisApplication.ActiveDocument, or other document reference.
Wesley Crihfield
(Not an Autodesk Employee)
I haven't tried drilling it down through an assembly yet, but I'm guessing that if you use something like "oRefDoc.Activate()", before running this macro, it might work, because, you'll notice the macro doesn't specify ThisApplication.ActiveDocument, or other document reference.
Wesley Crihfield
(Not an Autodesk Employee)
There is a standard Add-in that usually comes pre-installed with Inventor though, called "Batch Update Styles", that you might want to look into for this task. On my machine it is located on the Add-ins tab, on the Drawing Tools panel. I could be wrong though. You may have to install the usertools.msi file located in "C:\Users\Public\Documents\Autodesk\Inventor 2021\SDK\usertools.msi", to get it to show up there.
Wesley Crihfield
(Not an Autodesk Employee)
There is a standard Add-in that usually comes pre-installed with Inventor though, called "Batch Update Styles", that you might want to look into for this task. On my machine it is located on the Add-ins tab, on the Drawing Tools panel. I could be wrong though. You may have to install the usertools.msi file located in "C:\Users\Public\Documents\Autodesk\Inventor 2021\SDK\usertools.msi", to get it to show up there.
Wesley Crihfield
(Not an Autodesk Employee)
Do you use your Macro with Button created by an own Addin? I've tried your code, but it doesn't work. Neither by running it in VBA-Editor nor by putting the Macro as a button in a ribbon. If I start it, it runs through without any error or styleupdates. If I run it step by step with F8, the Macro stops when displaying the Style-Update-Window and waits until the Window is closed.
Maybe it doesn't work in 2018 yet. But thanks for your idea.
The usertools.msi may work, but installing things on our company-PCs is not that "easy". So I'll just wait for some APIs - I hope it will come 🙂
Do you use your Macro with Button created by an own Addin? I've tried your code, but it doesn't work. Neither by running it in VBA-Editor nor by putting the Macro as a button in a ribbon. If I start it, it runs through without any error or styleupdates. If I run it step by step with F8, the Macro stops when displaying the Style-Update-Window and waits until the Window is closed.
Maybe it doesn't work in 2018 yet. But thanks for your idea.
The usertools.msi may work, but installing things on our company-PCs is not that "easy". So I'll just wait for some APIs - I hope it will come 🙂
No it was not part of an Add-in.
I understand not being able to install stuff on company computers, but I had someone from our IT department install it for me.
Using the SendKeys method isn't always the most universally stable way to do it, but is usually the simplest & quickest way.
To get it to work right on your machine, you may have to try doing the actions manually, to see which combination of keyboard buttons, and how many key presses it takes to get to the options you want. To do this, first go to the Manage tab, and click on the Update tool (in the Styles and Standards panel), to launch it. This will bring you to the point in the code where it just executed the command. Now, tap your keyboards' TAB key untill the highlight (focus) moves to the option buttons on the dialog that you want to use, while counting how many times you had to tap the key to get there. Write that number down. Now tap your SPACEBAR keyboard key to toggle that setting. Write that action down too. Then tap your TAB key more times to get to the next option you want, counting how many taps it takes, etc. When you get to the OK button, press the ENTER (RETURN) keyboard key to finish. Once you have that pattern of keyboard key taps written down, you can simulate the same actions within the Macro, using the SendKeys sub.
You can reference its use from the following links:
Wesley Crihfield
(Not an Autodesk Employee)
No it was not part of an Add-in.
I understand not being able to install stuff on company computers, but I had someone from our IT department install it for me.
Using the SendKeys method isn't always the most universally stable way to do it, but is usually the simplest & quickest way.
To get it to work right on your machine, you may have to try doing the actions manually, to see which combination of keyboard buttons, and how many key presses it takes to get to the options you want. To do this, first go to the Manage tab, and click on the Update tool (in the Styles and Standards panel), to launch it. This will bring you to the point in the code where it just executed the command. Now, tap your keyboards' TAB key untill the highlight (focus) moves to the option buttons on the dialog that you want to use, while counting how many times you had to tap the key to get there. Write that number down. Now tap your SPACEBAR keyboard key to toggle that setting. Write that action down too. Then tap your TAB key more times to get to the next option you want, counting how many taps it takes, etc. When you get to the OK button, press the ENTER (RETURN) keyboard key to finish. Once you have that pattern of keyboard key taps written down, you can simulate the same actions within the Macro, using the SendKeys sub.
You can reference its use from the following links:
Wesley Crihfield
(Not an Autodesk Employee)
My mistake, your code above works fine. I just had to change the "Y" (in English for "Yes") to "J" (in German for "Ja"). And thanks for your detailed answer.
My mistake, your code above works fine. I just had to change the "Y" (in English for "Yes") to "J" (in German for "Ja"). And thanks for your detailed answer.
How do I activate via iLogic = (update styles in all child documents)?
How do I activate via iLogic = (update styles in all child documents)?
What's missing there?
Imports System.Windows.Forms
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 ")
What's missing there?
Imports System.Windows.Forms
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 ")
Hello,
I use this code, but it doesn't always activate the right style for me. I have "ISO_Adept" style in my library and I want it to be activated, meanwhile the style is added to the idw file, but the active style is "ISO". Is there a way to, for example, remove the "ISO" style? Perhaps then the "ISO_Adept" style will be activated.
regards
E.
Hello,
I use this code, but it doesn't always activate the right style for me. I have "ISO_Adept" style in my library and I want it to be activated, meanwhile the style is added to the idw file, but the active style is "ISO". Is there a way to, for example, remove the "ISO" style? Perhaps then the "ISO_Adept" style will be activated.
regards
E.
Hi @dusan.naus.trz.
Sorry for the delay...I've been away for a couple days.
When you use the SendKeys method, you just need to make sure the 'focus' is on the target dialog before it 'sends'. That's what the "AppActivate" line is for. It shifts the current 'focus' to that dialog, just before sending the key strokes to it.
This is my iLogic version (much shorter):
Dim oCD As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions.Item("UpdateStylesCmd")
oCD.Execute2(False)
AppActivate(ThisApplication.Caption)
System.Windows.Forms.SendKeys.SendWait("Y ")
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield
(Not an Autodesk Employee)
Hi @dusan.naus.trz.
Sorry for the delay...I've been away for a couple days.
When you use the SendKeys method, you just need to make sure the 'focus' is on the target dialog before it 'sends'. That's what the "AppActivate" line is for. It shifts the current 'focus' to that dialog, just before sending the key strokes to it.
This is my iLogic version (much shorter):
Dim oCD As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions.Item("UpdateStylesCmd")
oCD.Execute2(False)
AppActivate(ThisApplication.Caption)
System.Windows.Forms.SendKeys.SendWait("Y ")
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield
(Not an Autodesk Employee)
Hi @idealogicERZYZ. It sounds like you are just wanting to change which 'standard' style is active in your current drawing, by code. I think I may have a different iLogic rule for your situation.
This rule will check which drawing 'standard' style is currently active, and if it isn't the one named "ISO_Adept", then it will search for one with that name, and make it the active one, if possible.
Here is the iLogic code:
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("A Drawing Document must be active for this rule to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oStMgr As DrawingStylesManager = oDDoc.StylesManager
If oStMgr.ActiveStandardStyle.Name <> "ISO_Adept" Then
'find the "ISO_Adept" standard style, so we can activate it
Dim oExists As Boolean = False
For Each oDSS As DrawingStandardStyle In oStMgr.StandardStyles
If oDSS.Name = "ISO_Adept" Then
oStMgr.ActiveStandardStyle = oDSS
oExists = True
End If
Next
If oExists = False Then
MsgBox("Couldn't find the drawing standard style named 'ISO_Adept'.", , "")
End If
End If
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
If you want and have time, I would appreciate your Vote(s) for My IDEAS :light_bulb:or you can Explore My CONTRIBUTIONS
Wesley Crihfield
(Not an Autodesk Employee)
Hi @idealogicERZYZ. It sounds like you are just wanting to change which 'standard' style is active in your current drawing, by code. I think I may have a different iLogic rule for your situation.
This rule will check which drawing 'standard' style is currently active, and if it isn't the one named "ISO_Adept", then it will search for one with that name, and make it the active one, if possible.
Here is the iLogic code:
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("A Drawing Document must be active for this rule to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oStMgr As DrawingStylesManager = oDDoc.StylesManager
If oStMgr.ActiveStandardStyle.Name <> "ISO_Adept" Then
'find the "ISO_Adept" standard style, so we can activate it
Dim oExists As Boolean = False
For Each oDSS As DrawingStandardStyle In oStMgr.StandardStyles
If oDSS.Name = "ISO_Adept" Then
oStMgr.ActiveStandardStyle = oDSS
oExists = True
End If
Next
If oExists = False Then
MsgBox("Couldn't find the drawing standard style named 'ISO_Adept'.", , "")
End If
End If
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
If you want and have time, I would appreciate your Vote(s) for My IDEAS :light_bulb:or you can Explore My CONTRIBUTIONS
Wesley Crihfield
(Not an Autodesk Employee)
Hi @WCrihfield ,
I tried your code. But the button named Update Styles in all Child Documents does not work. If you ever have some time and know, please advise me. I have to click everything manually for all assemblies and components. I would like to give this rule before saving, but I do not know access to the Update Styles button in all Child Documents.
I'm sending a video in an attachment.
Hi @WCrihfield ,
I tried your code. But the button named Update Styles in all Child Documents does not work. If you ever have some time and know, please advise me. I have to click everything manually for all assemblies and components. I would like to give this rule before saving, but I do not know access to the Update Styles button in all Child Documents.
I'm sending a video in an attachment.
I attempted to accomplish the [update all styles from global] task the normal way (without using the 'command'), to see if there was an option or property somewhere along the line that would do the same thing as that "Update Styles in all Child Documents" checkbox option does in the dialog, but I didn't find one. I'm thinking this is just another thing that Inventor hasn't exposed to the API yet. They probably just deal with that option on their dialog the long way, but in the background. I'm not quite sure what it means by "Child Documents", or how to access these so called "Child Documents", so we can update them too.
Anyways, here is the iLogic code for updating all 'local' styles to match the global source, through normal means, without executing the command and using SendKeys.
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("A Drawing Document must be active for this rule to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oStMgr As DrawingStylesManager = oDDoc.StylesManager
For Each oSt As Style In oStMgr.Styles
If oSt.StyleLocation = StyleLocationEnum.kLocalStyleLocation Or oSt.StyleLocation = StyleLocationEnum.kBothStyleLocation Then
If oSt.UpToDate = False Then
Try
oSt.UpdateFromGlobal
Catch oE As Exception
MsgBox("Failed to update the following Style:" & vbCrLf & _
"Name = '" & oSt.Name & "' Type = '" & oSt.StyleType.ToString, , "")
End Try
End If
End If
Next
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield
(Not an Autodesk Employee)
I attempted to accomplish the [update all styles from global] task the normal way (without using the 'command'), to see if there was an option or property somewhere along the line that would do the same thing as that "Update Styles in all Child Documents" checkbox option does in the dialog, but I didn't find one. I'm thinking this is just another thing that Inventor hasn't exposed to the API yet. They probably just deal with that option on their dialog the long way, but in the background. I'm not quite sure what it means by "Child Documents", or how to access these so called "Child Documents", so we can update them too.
Anyways, here is the iLogic code for updating all 'local' styles to match the global source, through normal means, without executing the command and using SendKeys.
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
MsgBox("A Drawing Document must be active for this rule to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oStMgr As DrawingStylesManager = oDDoc.StylesManager
For Each oSt As Style In oStMgr.Styles
If oSt.StyleLocation = StyleLocationEnum.kLocalStyleLocation Or oSt.StyleLocation = StyleLocationEnum.kBothStyleLocation Then
If oSt.UpToDate = False Then
Try
oSt.UpdateFromGlobal
Catch oE As Exception
MsgBox("Failed to update the following Style:" & vbCrLf & _
"Name = '" & oSt.Name & "' Type = '" & oSt.StyleType.ToString, , "")
End Try
End If
End If
Next
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield
(Not an Autodesk Employee)
Hi,
Thank you for your answer. I don't want to delay you anymore. This surprised me a little that it was necessary to do it in the drawing and not in the assembly. I showed the assembly in the video. So I get it right, you can't use this option with iLogic in assembly.
Hi,
Thank you for your answer. I don't want to delay you anymore. This surprised me a little that it was necessary to do it in the drawing and not in the assembly. I showed the assembly in the video. So I get it right, you can't use this option with iLogic in assembly.
Hi @dusan.naus.trz ,
Did you find the code to Update Styles in all Child Documents?
That would be very useful.
Thank you
Hi @dusan.naus.trz ,
Did you find the code to Update Styles in all Child Documents?
That would be very useful.
Thank you
I can set the "Update Styles in all Child Documents" setting using the SendKeys.SendWait() method, but as I said before, it's not the most universally stable way to do it. In theory, the pattern of keystrokes I need to send to that dialog on my machine might possibly be different for you on your machine. Also, how to use the SendKeys.SendWait() method isn't very well documented for use within an iLogic rule or VBA macro. The regular Send() method is more documented, but we can't use that in iLogic, we have to use the SendWait method instead. So, what we send is all in one long string, without commas, and without the "{}" brackets, so its a little odd at first and sometimes just takes some trial/error testing to get the string just right.
Manually, when your in the dialog, pressing Alt+C will move the focus to (highlight) that setting, then you can use either the space key or the + sign key to toggle it on (Minus "-" key toggles stuff off / Plus "+" key toggles stuff on). So, we know from the earlier posts how to say Yes to all and Enter to update all the local document styles, so I'll just focus on the other process here (toggling that setting, then Yes to all, then Enter).
Here's the iLogic code that is working for me:
SendKeys.SendWait(%C{ADD}Y{ENTER})
because "%C" is like pressing Alt+C, and "{ADD}", is like pressing the "+" key (but just including the "+" mark in the string won't work, because the + sign is for Shift), and as we know "Y" is like clicking the [Yes to All] button, and of course {ENTER} is like pressing the enter key.
Wesley Crihfield
(Not an Autodesk Employee)
I can set the "Update Styles in all Child Documents" setting using the SendKeys.SendWait() method, but as I said before, it's not the most universally stable way to do it. In theory, the pattern of keystrokes I need to send to that dialog on my machine might possibly be different for you on your machine. Also, how to use the SendKeys.SendWait() method isn't very well documented for use within an iLogic rule or VBA macro. The regular Send() method is more documented, but we can't use that in iLogic, we have to use the SendWait method instead. So, what we send is all in one long string, without commas, and without the "{}" brackets, so its a little odd at first and sometimes just takes some trial/error testing to get the string just right.
Manually, when your in the dialog, pressing Alt+C will move the focus to (highlight) that setting, then you can use either the space key or the + sign key to toggle it on (Minus "-" key toggles stuff off / Plus "+" key toggles stuff on). So, we know from the earlier posts how to say Yes to all and Enter to update all the local document styles, so I'll just focus on the other process here (toggling that setting, then Yes to all, then Enter).
Here's the iLogic code that is working for me:
SendKeys.SendWait(%C{ADD}Y{ENTER})
because "%C" is like pressing Alt+C, and "{ADD}", is like pressing the "+" key (but just including the "+" mark in the string won't work, because the + sign is for Shift), and as we know "Y" is like clicking the [Yes to All] button, and of course {ENTER} is like pressing the enter key.
Wesley Crihfield
(Not an Autodesk Employee)
Sorry, my mouse quit working just before I got that last post sent. That line of code in my last post didn't include the quotation marks, because I typed it directly in the post, instead of copy/paste from my rule. I was going to post the rule, like this:
Dim oCD As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions.Item("UpdateStylesCmd")
oCD.Execute2(False)
AppActivate(ThisApplication.Caption)
System.Windows.Forms.SendKeys.SendWait("%C{ADD}Y{ENTER}")
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield
(Not an Autodesk Employee)
Sorry, my mouse quit working just before I got that last post sent. That line of code in my last post didn't include the quotation marks, because I typed it directly in the post, instead of copy/paste from my rule. I was going to post the rule, like this:
Dim oCD As ControlDefinition = ThisApplication.CommandManager.ControlDefinitions.Item("UpdateStylesCmd")
oCD.Execute2(False)
AppActivate(ThisApplication.Caption)
System.Windows.Forms.SendKeys.SendWait("%C{ADD}Y{ENTER}")
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield
(Not an Autodesk Employee)
I believe the SendKeys code should work with any of the main 3 document type environments (Part, Assembly, Drawing), but PartDocument and AssemblyDocument don't have a StylesManager, like a DrawingDocument does, so I don't have a long version for those other two document types that doesn't use the SendKeys method. Parts and assemblies do have a few 'styles' in them, but just simple stuff like lighting styles, text styles, and sheet metal styles (in sheet metal parts).
I don't currently have a rule/macro for updating Assets (materials, appearances, & physical are all defined within assets) the long way. Right now I'm thinking you would likely have to use the CopyTo method, and set the ReplaceExisting Boolean variable to True to update them, which doesn't sound like a fun process to set-up.
Wesley Crihfield
(Not an Autodesk Employee)
I believe the SendKeys code should work with any of the main 3 document type environments (Part, Assembly, Drawing), but PartDocument and AssemblyDocument don't have a StylesManager, like a DrawingDocument does, so I don't have a long version for those other two document types that doesn't use the SendKeys method. Parts and assemblies do have a few 'styles' in them, but just simple stuff like lighting styles, text styles, and sheet metal styles (in sheet metal parts).
I don't currently have a rule/macro for updating Assets (materials, appearances, & physical are all defined within assets) the long way. Right now I'm thinking you would likely have to use the CopyTo method, and set the ReplaceExisting Boolean variable to True to update them, which doesn't sound like a fun process to set-up.
Wesley Crihfield
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.