Automatic macro export when a clip is opened

This macro works for me but indeed after trying it launches the requested macro before the document is displayed in SolidWorks so the macro must be launched before the document is displayed, you have to find another macro to make this kind of request.

By the way, I don't understand what you mean by "I also replaced 'swRunMacroUnloadAfterRun' with 1 and 'runMacroError' with 0"

 

It's just to simplify the reading on the forum. But it's the same thing.

In my opinion the solution would be to open the document, the past in solved, rebuild and then run this kind of macro 

But concretely I think it would be easier to work only in excel for this kind of thing.


macrotest2.swp
1 Like

Totally agree with @mandragore this kind of macro becomes a problem very quickly because it's impossible to know if it's launched when it needs to or not, and no feedback if it runs well or if it just started and then bugged. Launching a macro from a macro to have already done it is not great.

And since a macro feature, it's even worse and may make you change your mind quickly, believe me it's experienced, I've been there before, I tested the 2 with a quick rewind due to many problems.

 

 

The goal is to generate this PDF plan automatically from a web platform. So by definition, it will be fully automatic. if an incident prevents the creation of the PDF, I think I can be alerted at a level other than SW.

It is possible to attack the API in C++. I haven't found a topic on this forum. Do you know how well it works?

I found this conversation thread that deals with a code that allows you to launch an action once the reconstruction of the plan is complete:

https://r1132100503382-eu1-3dswym.3dexperience.3ds.com/#community:yUw32GbYTEqKdgY7-jbZPg/iquestion:Fr2GDcHYThK6PjOZubrVPg

There is a declaration that is not recognized and that is displayed in red in the macro:

Dim WithEvents swDraw As SldWorks.DrawingDoc 

Do you have an explanation for that? different VB version?  missing reference?

It is possible to attack the API in C++. I haven't found a topic on this forum. Do you know how well it works?

 

Yes, it is possible. I don't know the code though but you'll find everything you're looking for here:  

http://help.solidworks.com/2022/English/api/sldworksapiprogguide/Welcome.htm

 

On the forums we almost only use the VBA, I think it's easier to familiarize yourself with the code and many people are self-taught.

Hi all

Small update of my topic:

I ended up finding what I was looking for with Batch+, a tool that allows you to run command-line macros.

I finally have a .bat that allows me to launch my "export-PDF.swp" macro without having to touch SW, exactly what I needed.

By the way, I highly recommend looking at the tools they offer. It's probably cheaper than MyCad, with some fewer features, but also some more.

Thank you