0% found this document useful (0 votes)
113 views1 page

Custom Properties

This SolidWorks API example shows how to add and retrieve a custom property called "Date added" to a selected weldment feature. The example adds the custom date property, then prints the name and value of all custom properties for the weldment feature to the Immediate window for verification.

Uploaded by

ch_deepak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
113 views1 page

Custom Properties

This SolidWorks API example shows how to add and retrieve a custom property called "Date added" to a selected weldment feature. The example adds the custom date property, then prints the name and value of all custom properties for the weldment feature to the Immediate window for verification.

Uploaded by

ch_deepak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

This example shows how to add and get a custom property assigned to a weldment

feature.

'--------------------------------------------------------------
' Preconditions:
' 1. Open public_documents\samples\tutorial\api\weldment_box3.sldprt.
' 2. Select the Weldment feature in the FeatureManager design
' tree.
' 3. Open the Immediate window.
'
' Postconditions:
' 1. Adds a custom property named Date added to the selected
' weldment feature.
' 2. To verify:
' * Examine the Immediate window.
' * Right-click the Weldment feature in the FeatureManager
' design and click Properties.
'
' NOTE: Because the part is used elsewhere, do not save
' changes.
'-------------------------------------------------------------
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFeat As SldWorks.Feature
Dim swCustPropMgr As SldWorks.CustomPropertyManager
Dim nRetVal As Long
Dim vNameArr As Variant
Dim vName As Variant
Dim bRet As Boolean
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set swFeat = swSelMgr.GetSelectedObject6(1, 0)
Set swCustPropMgr = swFeat.CustomPropertyManager
Debug.Print "File = " & swModel.GetPathName
Debug.Print " " & swFeat.Name & " [" & swFeat.GetTypeName & "]"
' Add custom property
bRet = swCustPropMgr.Add3("Date added", swCustomInfoType_e.swCustomInfoDate,
"17-Apr-2005", swCustomPropertyAddOption_e.swCustomPropertyDeleteAndAdd)
' Get all custom properties
vNameArr = swCustPropMgr.GetNames: If IsEmpty(vNameArr) Then Exit Sub
For Each vName In vNameArr
Debug.Print " " & vName & " [" & swCustPropMgr.GetType(vName) & "] = " &
swCustPropMgr.Get(vName)
Next vName
End Sub

You might also like