AnsweredAssumed Answered

Run a macro when a new drawing is started

Question asked by Marc-Xavier Bilodeau on Aug 19, 2015
Latest reply on Aug 20, 2015 by Deepak Gupta

Alrigh! So I know the answer is probably somewhere here but I couldn't find it... I'll make it short and clear

 

I want to fill a custom propreties using macro. More specific, "Drawn by".

 

I went throught a lot of possibilities to come across my probleme, At first, I put the "LastSavedBy" property, but in the end, the "Drawn by" would change each time someone saved the file (when a revision is made for instance).

That didn't make it.

 

Then I try using the custom propertis tab builder! I made a wonderfull list of people drawing, with a superb drop down list, but most people wont take the 2 required seconds to fill it.

 

Now I'm heading to automate the drawing template with a macro.

 

I'm not good at API, but with some research and try I came up with this:

 

---------

Sub main()

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swCustPropMgr = swModel.Extension.CustomPropertyManager(Empty)

   

    'Auteur (Auteur)

    swCustPropMgr.Set "Auteur", Environ("USERNAME")

  

End Sub

---------

 

Wich give me the username.

 

Later on I might no a "If username is "blabla" then "give the name in the right form".

This I can do!

 

The help I'm looking for right now, is how to run this macro automatically when a new drawing is started?

 

I found some alternative on many forum like:

1- Macro button to run and auto fill ( It works, but it's not automated)

2- Macro will run when the first view is droped (But requires an addin???)

3- Macro that run from the 3D; wich will creat a new drawing an the fill my needs (But I need to set everyone computer and I probably need 1 macro for each sheet size…)

 

That’s why I’m asking here if there’s a possibilities to run a macro from a drawing template?

I saw Deepak calling the “macro drawing standard” in this forum: https://forum.solidworks.com/thread/59935

But I couldn’t get anymore informations about it.

 

Any idea? Help? Answers? Just a hint would do!

Outcomes