Launch a macro when opening SolidWorks

Hello hello,

I hope you're doing well!

I have one question, actually two but to start:

- I would have liked to know if it was possible to set a macro so that it launches when opening SW please?

- And is it possible to have a macro "running in the background"? By this I mean, a macro that launches as soon as the condition is met. For example, as soon as a specific file is opened, a macro window asks which configuration should be activated? Please

Thank you for your help & have a great day.

 

This is no longer a macro but more than one Add-In has been developed.

Hello

Indeed, I think that if you really want to do this you have to look at the AddIn.

All information for an AddIn VB.Net here. From then on, we no longer talk about VBA. We might as well say it right away, the magnitude of the task is not at all the same.

It's up to you...

Hello

Attached is an explanation of how to use event triggers in VBA. 

In addition, you can use equations to start a macro ("Trigged macro")


using_notifications_events_in_solidworks_macros.pdf
3 Likes

Thank you all, I'll look at all your sources!

@ joel.condevaux :

Thank you for this complete pdf. I had seen the solution to modify the shortcut. For me, this is still a DIY since with each update of SW the shortcut will be replaced. I'm not even talking about the location of the macro.

You can choose to place the macro wherever you want it and not necessarily in a folder in the Solidworks installation.

As for the shortcut, you can use a macro that is started by an equation. That is to say that the macro will be started the first time you rebuild any part (Save, rebuild, load).

 

1 Like

@Joel.condevaux

Can you explain how to launch a macr from an equation that could interest me too.

1 Like

Good evening

Macros can be launched in a variety of ways:

  • User action (button, ....)
  • By an equation (except that after testing 15 days ago, the equation manager doesn't like the equation to write to launch the macro, so, I forget)
  • By Feature Macro (The macro is a feature like an extrusion or a sweep, it is executed at each reconstruction) really very practical to make very advanced parameterization.
  • By a macro (you can run a macro from another macro)
  • Running solidworks (which for me, is strictly useless, you might as well make an addin in c# or .net)

The two I remember are the execution by user action and Feature Macro.

FYI, for macros that depend on a part, I put the macro in the design folder of the part. It avoids losing it and using it for another room.

Allow me to react to the PDF using_notifications_events_in_solidworks_macros did you manage to make the example under SW2016? for my part nothing happens it's embarrassing

For my part, I did not use the PDF. In addition, I'm on SW2015 so I wouldn't be of much help to you.