Hide Table of Contents

Get Custom Properties for Configuration Example (VBA)

This example shows how to get the names, types, values, and resolved values of the active configuration's custom properties. It also shows how to add a custom property to the configuration.

 

'-------------------------------------------

'

' Preconditions: Part document is open containing a

'                configuration that has custom properties.

'

' Postconditions: A new custom property is added

'                 to the configuration.

'

'--------------------------------------------

Option Explicit

 

Public Enum swCustomInfoType_e

        swCustomInfoUnknown = 0

        swCustomInfoText = 30

        swCustomInfoDate = 64

        swCustomInfoNumber = 3

        swCustomInfoDouble = 5

        swCustomInfoYesOrNo = 11

End Enum

 

    Dim swApp               As SldWorks.SldWorks

    Dim swModel             As SldWorks.ModelDoc2

    Dim swConfigMgr         As SldWorks.ConfigurationManager

    Dim swConfig            As SldWorks.Configuration

    Dim swCustPropMgr       As SldWorks.CustomPropertyManager

    Dim nNbrProps           As Long

    Dim j                   As Long

    Dim retVal              As Long

    Dim vPropNames          As Variant

    Dim valOut              As String

    Dim resolvedValOut      As String

    Dim custPropType        As Long

 

Sub main()

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swConfigMgr = swModel.ConfigurationManager

    Set swConfig = swConfigMgr.ActiveConfiguration

    Debug.Print "Name of this configuration:                             " & swConfig.Name

 

    Set swCustPropMgr = swConfig.CustomPropertyManager

    ' Get the number of custom properties for this configuration

    nNbrProps = swCustPropMgr.Count

    Debug.Print "Number of properties for this configuration:            " & nNbrProps

    ' Add custom property date to this configuration

    retVal = swCustPropMgr.Add2("Date ", swCustomInfoDate, "15-Nov-2005")

    ' Get the new number of custom properties for this configuration

    nNbrProps = swCustPropMgr.Count

    Debug.Print "New number of properties for this configuration:        " & nNbrProps

    ' Get the names of the custom properties

    vPropNames = swCustPropMgr.GetNames

   ' For each custom property, get its type, value, and resolved value

   ' Then print its name, type, and resolved value

    For j = 0 To nNbrProps - 1

        swCustPropMgr.Get2 vPropNames(j), valOut, resolvedValOut

        custPropType = swCustPropMgr.GetType2(vPropNames(j))

        Debug.Print "    Name, type, and resolved value of custom property:  " & vPropNames(j) & " - "; custPropType & " - " & resolvedValOut

    Next j

       

End Sub



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Get Custom Properties for Configuration Example (VBA)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2010 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.