Does anyone know how to create a customize macro button programatically using C#?
Thanks in advance
Honestly I haven't done this for myself before. As far as I know it is possible to deploy the macro buttons by copying the settings (if I'm not mistaken through the SolidWorks RX). So I assume all this information is stored in the registry.
Yes, as I have replied to Jela, this registry branch is not enough because it doesn't contain the information of toolbar where this button is placed.
What I can propose you to make a snapshot of your registry, add the button manually, close SolidWorks, make snapshot again and see the difference (use text diff tools like Beyond Compare or SVN diff) so you have an idea what keys should be added. Note, I think you have to restart SolidWorks when you add these registry keys to see the changes.
This is very pain I think. You may also refer to this solution I have posted many years ago: http://eng-tips.com/viewthread.cfm?qid=246216. The idea to create an add-in which allows to place the custom toolbar. You may extend this to place the custom buttons on it (for example reading the xml) and this button could just run the SldWorks::RunMacro2 method thus executing the macros. May be very useful but requires a custom programming.
Merry Christmas and Happy New Year!
Application Engineer at Intercad
Tel: +61 2 9454 4444
It seems to be no APIs for this.
The only you can do is drag the buttons:
And manipulate the registry to create macro button.
This is the reg-branch which stores this information:
HKEY_CURRENT_USER\Software\SolidWorks\SolidWorks 2012\User Defined Macros
It should be some other registry entries in toolbars for placing this button. You can research.
I have the same problem with Ms. Jela, I tried to manipulate the registry key HKEY_CURRENT_USER\Software\SolidWorks\SolidWorks 2012\User Defined Macros but the macro button does not load in the solidworks it only stores the registry that I made. but when I tried to add macro button manually in the solidworks it adds the data in the registry in the User Defined Macros...
(In the registry )
01- Macro Folder (I made it manualy in the registry)
-After creating another macro button in the solidworks it became like this
01- Macro Folder (created by the solidworks)
02- Macro Folder (I made it manualy in the registry)
My question is what do you think i have been missing or my problem to load the macro button? I tried to research for the other registry that may be useful in creating the macro button but nothing found...
Thanks in advance Mr. artem
Merry Christmas and Happy New year!!!
Thank you very much for the answer after many tries edtting the registry key of the solidworks it really works now but yes it is very hard because you need to compare the registry one by one and if you forgot one registry the program will not work. thanks again for your help Mr. Artem.
try what mr artem said try editting the registry of the solidworks it really works but it is so hard because you need to check each registry of the solidworks one by one
Happy New Year...
I would recommend to use the text Compare tools, like Beyond Compare (commercial) or any other tools. This would simplify this process. Furthermore once you find these keys you may reuse them for future reference.
Happy New Year!
Yes I use text compare tools beyond compare to compare each registry thanks to that it lessen my work in comparing each registry key.
I have a follow up question Sir Artem, is there a way to reset the registry of solidworks on a selected part of the registry only? Because when I try to do the manual edtting of the registry the toolbar exist and it works in the solidworks but when i delete it using the solidworks and try to do it again manually using registry it doest not work already and before that all the registry has changed...
(previous edting that I made)
(without macro button)
Key Name: HKEY_CURRENT_USER\Software\SolidWorks\SolidWorks 2010\User Interface\CommandManager\AssyContext\Tab8\TabContext7
Class Name: <NO CLASS>
Last Write Time: 2012/12/27 - 14:16
Data: 7 ----> take note of this
(with macro button)
Last Write Time: 2012/12/28 - 10:52
Data: 6 ----> take note of this
After deleting and make another one
Data: 8 ----> take note of this
I do not know why it become 8 maybe because i created it manually in the registry that is why it increment the data of the contextId (I am not sure if I am correct) that is why i am thinking a way how to reset the registry of the selected part of the solidworks only. Any suggestion or advice would be appreciated.
Thanks again in advance
Happy New Year
Retrieving data ...