I am looking for a macro that will call and apply a custom property template when a drawing is saved.
I am not a macro person.
Is this more of an API solution?
What do you mean with apply?
Should the specified custom properties just be added to the drawing? If so, from where should the properties be populated? Should other already existing properties be deleted?
Or should already existing properties be transferred to other properties as well?
This is something that I have not done in the past but it is possible using SolidWorks API and XML read/write. See this post from the past, not a solution but it gives some information.
thanks fro the reply and request for clarification.
Basically we do not place properties in our drawings, all the properties are in the models.
The issue is with our windchill PLM.
When we set a property requirement to "required" upon checkin, you cannot proceed without a pre-defined value in that property.
This is handled by the custom property template we have set up for parts and assemblies.
Now here is where it gets sticky. Because Windchill PLM sees EPM documents as any solidworks document, the system ids expecting the properties "required " to also exist in the drawing- they do not, nor do they belong there.
So i have created a work around- I have added a soft type in the windchill system and have set the drawing type to be ignored for the "required" property.
However it requires a different property in the properties table which tell windchill to ignore this requirement in the document.
convoluted, i know.
So here is what i need.
I have a property called "UPLOAD_SOFT_TYPE" with a value "net.smiths.slddrw"
In order to automate this, i was hoping for a macro that would place this information in the properties table when the user clicks the save button.
This automation will save on frustration and questions on the error upon check-in.
Why don't you put this property and value in the drawing template. An for older files use Task scheduler or a macro to add this property into the drawings.
Thanks for the clarification.
Deepak have good points in thinking of making a change to all documents at once and update the templates. That would be the most convenient way.
But if you do not have access to the drive where the files is stored (called file volume / vault etc). Then it might be better to go for a add-in or macro.
I have a similar experience. Once we had migrated to Teamcenter I wanted to make a batch run and change some minor changes to the properties of the files. But it is not possible (according to the Teamcenter developers we had) to access the files. So I was facing options to mass export all data, make the changes and then import it back to Teamcenter. This was a really big task with a lot of risk. So I have instead started to think of an add-in to SolidWorks that would fix it.
I would try things out as following:
1) So if possible use the Task scheduler and make changes to all drawings at once. Release new templates to the production.
2) If it is not possible, get an add-in that will do it. Macros is good for automation etc but bit trickier to implement. Add-ins could easier be distributed widely.
3) If you still want it to be macro it is possible if you could launch solidworks with arguments (basically make a new shortcut or change the batch file that is used to launch it). Here is some more information about how to execute a macro on start up of SolidWorks. I played around a bit with the FileSave Event this evening and it is possible to add custom properties to a file at that event. Attached is the macro. No worries if it not going to be used. The macro is tested at SolidWorks 2012 SP5. I know that there is some new API stuff to use if you have SolidWorks 2014. Please note that the macro should be implemented as according to the link above. It is possible to just test the macro by starting SolidWorks and then run the macro.
One more thing, what SolidWorks version are you running and what service pack do you have?
Retrieving data ...