Created
August 4, 2020 01:55
-
-
Save AmenJlili/722af434c426f16378dc127587401dc1 to your computer and use it in GitHub Desktop.
Delete all properties for the active configuration – SOLIDWORKS MACRO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Delete all properties from the active configuration | |
' Conditions = None | |
' Results = all properties in the active configuration are deleted | |
' www.bluebyte.biz | |
Dim swApp As Object | |
Dim swModel As Object | |
Dim CustomPropertyManager As Object | |
Public Enum swDocumentTypes_e | |
swDocDRAWING = 3 | |
End Enum | |
Sub Main() | |
'get pointer to the solidworks application | |
Set swApp = Application.SldWorks | |
'get active document | |
Set swModel = swApp.ActiveDoc | |
If swModel Is Nothing Then | |
swApp.SendMsgToUser "There is no active document" | |
End | |
End If | |
If swModel.GetType = swDocumentTypes_e.swDocDRAWING Then | |
swApp.SendMsgToUser "Drawings do not have configurations" | |
End | |
End If | |
'get the active configuration name | |
Dim activeConfigurationName As String | |
activeConfigurationName = swModel.GetActiveConfiguration.Name | |
Set CustomPropertyManager = swModel.Extension.CustomPropertyManager(activeConfigurationName) | |
'get property names | |
Dim propertyNames As Variant | |
propertyNames = CustomPropertyManager.GetNames | |
'define dialog answer | |
Dim answer As Long | |
'exit sub if there are no properties | |
If IsEmpty(propertyNames) Then | |
swApp.SendMsgToUser "Configuration " & activeConfigurationName & " has no properties to delete!" | |
Exit Sub | |
Else | |
answer = MsgBox("You are about to delete all properties from the configuration " & ActiveConfiguration & ". Are you sure you want to proceed?", vbYesNo + vbQuestion) | |
If answer = vbNo Then | |
Exit Sub | |
End If | |
End If | |
'delete properties | |
For i = 0 To UBound(propertyNames) | |
CustomPropertyManager.Delete2 propertyNames(i) | |
Next i | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I can macro delete custom property and configuration part and assembly .
i have code:
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim sFilePath As String
Dim sFileName As String
Sub main()
code of my non delete configuration.
plese help me. thank you.