API: Delete all custom properties

  • Follow


I have found several examples of how to do this but none seem to work,
I need a macro that I can run that will delete all custom properties
regardless of property name.

I have a macro that will add custom properties and it is written so
that it does not require solidworks, it uses windows to create the
custom property. I would like to do the same for deleting the custom
properties.

Can someone please provide some sample code showing how to delete all
custom properties?

Thanks,

Sam
0
Reply Sam 5/13/2008 5:44:39 PM

This function works inside a SolidWorks VBA Macro :

'**
'Delete all file of configuration properties
'@param        doc Required. SldWorks.ModelDoc2 object.
'@param        conf Optional. String. Default value is "".
'@param        emptyonly Optional. Boolean. Default value is False. if
True, deletes only the properties without any value
'@return       Boolean . true if all were deleted
Public Function DeleteAllProps( _
    doc As SldWorks.ModelDoc2, _
    Optional ByVal conf As String = "", _
    Optional emptyonly As Boolean = False _
) As Boolean
    DeleteAllProps = True
    Dim names As Variant
    names = doc.GetCustomInfoNames2(conf)
    Dim name As Variant
    For Each name In names
        If emptyonly And doc.GetCustomInfoValue(conf, name) <> "" Then
GoTo continue ' don't delete
        DeleteAllProps = DeleteAllProps And
doc.DeleteCustomInfo2(conf, name)
continue:
    Next name
End Function

To delete properties outside of SolidWorks, you'll need to create an
application, not a macro, and link to a .dll (which I don't recall the
name at the moment) to access standard Windows properties. I'm not
even sure you can delete them this way, but I'm absolutely sure you
can't delete configuration specific properties this way.
0
Reply Philippe 5/13/2008 6:49:24 PM


1 Replies
540 Views

(page loaded in 0.032 seconds)

Similiar Articles:













7/22/2012 7:09:24 AM


Reply: