I have 2 custom properties that I would like to delete using API (PartNo and Description1).
It is easy to do from the Custom tab but I cannot seem to figure it out for the Configuration specific tab. I know that I want to delete them from the Default configuration.
To delete from the custom tab I use: swModelDoc.DeleteCustomInfo "PartNo" and this works great. I just wish I could figure out how to delete the same custom property name from the configuation specific tab as well.
Any thoughts would be appreciated.
Thanks and happy holidays,
Tom
SolidworksApi macros
Hi Tom,
Please see this API help file
http://help.solidworks.com/2013/English/api/sldworksapi/get_custom_properties_for_configuration_example_vb.htm
This example shows how to get property and add new one.
You can try "delete" in place
Tom,
The custom property-related methods in the IModelDoc2 interface are actually obsolete and I highly recommend not using them. You should be using the ICustomPropertyManager interface. Using this interface you can easily add, delete, modify, and read custom properties at the document and configuration specific level.
The following code will delete the Description custom property from the document level and configuration specific level for a configuration called "test":
========
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swCustPropMgr As SldWorks.CustomPropertyManager
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
'document level
Set swCustPropMgr = swModel.Extension.CustomPropertyManager(Empty)
swCustPropMgr.Delete "Description"
'config specific level
Set swCustPropMgr = swModel.Extension.CustomPropertyManager("test")
swCustPropMgr.Delete "Description"
End Sub
========
Notice that you specify the configuration you desire to access using the sole argument in the accessor IModelDocExtension::CustomPropertyManager.
Good luck as you prepare for SWW.
Keith
Video Tutorials for the SolidWorks API
Thanks Keith, that worked great.
Hopefully see you at SWW!
Hey Keith,
That is very useful, thanks! I'm very unfamiliar with this whole API thing. My problem is that I have a macro assigning custom properties, and it works fine, but when I go to a drawing, the configuration specific properties take over even though I have specified all the correct properties. Here is an example of what I mean:
Here are the custom properties I want:
Here are the configuration specific properties that I want to delete automatically (it would be important to say that I'm not even using configurations for this part).
These properties are not valid. I simply want a macro that can delete all of these. Once these are deleted, the other specified properties appear and all is well.
Thanks in advance...
Try the macro posted here: Re: Macro to open all SolidWorks files in a location and delete configuration custom propertiesMacro to open all SolidWorks files in a location and delete configuration custom properties