Run Solidworks Macro in C#

Hi everyone.
I am trying to develop addin via C# for Solidworks. The command in add in will run macro which is recorded via solidworks or typed by me. Is the macro must be .csproj format or can ı use .swp format. Solidworks cant record macro .csproj format and also ı cant implement my macro to C#
I am using Visual studio 2022. Here is the some source but ı didnt understand.

https://help.solidworks.com/2020/english/api/sldworksapiprogguide/gettingstarted/vsta_2015.htm

1 Like

Can you please reformulate your post?

I’m not sure I understand what you need help with. Thank you :slight_smile:

Sorry ı i’m so confused. Basically ı mean ı can’t record csproj format macro in solidworks eventhough ı installed Microsoft Visual Studio 2015

Can you post your code?

hey buddy , i have the same problem as you now.
Were you able to solve your problem?

1 Like

I presume you have checked the help

https://help.solidworks.com/2021/English/api/sldworksapi/SOLIDWORKS.Interop.sldworks~SOLIDWORKS.Interop.sldworks.ISldWorks~RunMacro2.html

I remember Artem saying you can run the old type of VBA macros (*.swb) which are plain text and not compiled if you wish to dynamically create them

2 Likes

actually,the problem is that i cant save my macro as csproj ,.
(im using solidworks 2022 and i recently installed the visual studio 2022)

As @rob said, I use RunMacro2 to run a swp macro from within an add-in…

In this way I can use the macros I already written in a brand new add-in without the need to re-write them in C# or VB.NET.

2 Likes

thank you for your comment.
but that doesn’t help me.