Can someone help me with a macro to add the following custom properties
Drawnby Property - Text -"MDJ"
Drawndate - Date - The current day
Thanks
SolidworksApi macros
Can someone help me with a macro to add the following custom properties
Drawnby Property - Text -"MDJ"
Drawndate - Date - The current day
Thanks
SolidworksApi macros
Matt, if you have searched on the forum, you would have got many of those macro which can be used directly or with some modification.
I was playing with another macro so quickly created the attached one. This macro will add custom properties "Drawn By" and "Drawn Date" to any active document.
Also read this post for your future reference: Forum Posting
Whenever I try to run one of your macros, I normally receive a Libray Not Found error which I have to go to refrences in VB and uncheck Solidworks Utilities 2010 Type Library . Then everything is OK.
At first I just thought it's just because of the different versions of solidworks we use, but going through the existing references, I'm not able to find something like Utilities 2011 in my references.
May I ask what this library is?
thank you.
Yes it is because of the two different version. I have both SW2010 and SW2011 on my machine and had SW2010 open while I made that macro.
Utilities are the SolidWorks Utilities. Any chance you running standard version then utilities will not be there under Tools > Add In
Yes, solidwork utilities was unchecked in add-ins manager.
thank you.
Thanks for the help. I ended up combining your tDate = DateValue, into a macro I had to add other custom properties. I changed the property names to match what I needed, and it works so far.
Here is the what it looks like
Dim swApp As Object
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swCustPropMgr As SldWorks.CustomPropertyManager
Dim retVal As Boolean
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swCustPropMgr = swModel.Extension.CustomPropertyManager("")
tDate = DateValue(Date)
retVal = swCustPropMgr.Delete("DrawnBy")
retVal = swCustPropMgr.Delete("DrawnDate")
retVal = swCustPropMgr.Add2("DrawnBy", swCustomInfoText, "MDJ")
retVal = swCustPropMgr.Add2("DrawnDate", swCustomInfoText, tDate)
End Sub
Good to hear that codes were of some use to you