call Add-in from Macro

Programming and macros
cturner
Posts: 2
Joined: Thu Jul 27, 2023 9:10 am
Answers: 0

call Add-in from Macro

Unread post by cturner »

I am looking for a way to call an Add-in from a Macro, alternatively to launch an Add-in function from the command line. We are trying to "batch process" a large number or part files and we would like to launch SolidWorks, process a bunch of files, and then close SolidWorks without any user intervention. I know how to call a macro from the command line, but I would prefer to write all this in C#.
User avatar
gupta9665
Posts: 359
Joined: Thu Mar 11, 2021 10:20 am
Answers: 20
Location: India
x 383
x 414

Re: call Add-in from Macro

Unread post by gupta9665 »

You can look into creating a standalone tool instead of add-in.
Deepak Gupta
SOLIDWORKS Consultant/Blogger
cturner
Posts: 2
Joined: Thu Jul 27, 2023 9:10 am
Answers: 0

Re: call Add-in from Macro

Unread post by cturner »

We looked into this. Unfortunately, as far as I can tell, the functionality we want to do (generate PNG and STEP files) can't be done from a standalone tool, only an add-in or macro.
User avatar
josh
Posts: 249
Joined: Thu Mar 11, 2021 1:05 pm
Answers: 11
x 19
x 440

Re: call Add-in from Macro

Unread post by josh »

Not sure what led you to believe this. Any external program can call any SW API. Your program will still have to launch SW and tell it what to do, but there aren't any features of SW that you can do with a macro that you can't do with basically the same API calls from an external program. I've launched SW and called its API from Excel and even VBScript.

Not that I think you'd try it, but VBScript is actually quite limited in what it can do in SW due to the fact that it can't handle arrays of objects passed from external functions. It can count them but you can't get any of them.... C# would not have this limitation.
User avatar
gupta9665
Posts: 359
Joined: Thu Mar 11, 2021 10:20 am
Answers: 20
Location: India
x 383
x 414

Re: call Add-in from Macro

Unread post by gupta9665 »

cturner wrote: Wed Aug 02, 2023 9:27 am We looked into this. Unfortunately, as far as I can tell, the functionality we want to do (generate PNG and STEP files) can't be done from a standalone tool, only an add-in or macro.
I had made standalone tool to do similar tasks. The standalone tool will start the SW (if an instance is not running) and then can open the required files and export in the desired formats.

Here is an example by @artem exporting to various formats using API and eDrawings https://www.codestack.net/edrawings-api/output/export/
Deepak Gupta
SOLIDWORKS Consultant/Blogger
Post Reply