Hide Table of Contents

Get Custom Property Values on Weldment Cut-list Folders Example (VBA)

This example shows how to get all of the custom property values on the weldment cut-list folders of a part in an assembly.

 

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

' Preconditions:

' 1. Assembly is open.

' 2. At least one part in the assembly

'    has a weldment cut-list folder

'    that has custom properties.

'

' Postconditions: None

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

Option Explicit

 

Dim swApp As SldWorks.SldWorks

Dim Part As SldWorks.ModelDoc2

Dim SelMgr As SldWorks.SelectionMgr

Dim boolstatus As Boolean

Dim longstatus As Long, longwarnings As Long

 

Sub VisitFeatureCustomProperties(docFeat As SldWorks.Feature)

    Dim custPropMgr As SldWorks.CustomPropertyManager

    Dim propNames As Variant

    Dim vName As Variant

    Dim propName As String

    Dim Value As String

    Dim resolvedValue As String

    

    Set custPropMgr = docFeat.CustomPropertyManager

    If Not custPropMgr Is Nothing Then

        propNames = custPropMgr.GetNames

        If Not IsEmpty(propNames) Then

            Debug.Print docFeat.Name, docFeat.GetTypeName

            For Each vName In propNames

                propName = vName

                Call custPropMgr.Get2(propName, Value, resolvedValue)

                Debug.Print "", "", propName, Value, resolvedValue

            Next vName

        End If

    End If

End Sub

 

Sub VisitDocWeldmentProperties(compDoc As SldWorks.ModelDoc2)

    Dim thisFeat As SldWorks.Feature

    Dim thisSubFeat As SldWorks.Feature

    Dim cutFolder As SldWorks.BodyFolder

    

    Set thisFeat = compDoc.FirstFeature

    Do While Not thisFeat Is Nothing

       

        Set thisSubFeat = thisFeat.GetFirstSubFeature

        Do While Not thisSubFeat Is Nothing

          

            If thisSubFeat.GetTypeName = "CutListFolder" Then

                Set cutFolder = thisSubFeat.GetSpecificFeature2

            End If

            If Not cutFolder Is Nothing Then

                If cutFolder.GetBodyCount > 0 Then

                    Call VisitFeatureCustomProperties(thisSubFeat)

                End If

            End If

            

            Set thisSubFeat = thisSubFeat.GetNextSubFeature

        Loop

        Set thisFeat = thisFeat.GetNextFeature

    Loop

End Sub

 

Sub main()

Set swApp = Application.SldWorks

    

    Set Part = swApp.ActiveDoc

    Set SelMgr = Part.SelectionManager

    boolstatus = Part.Extension.SelectByID2("1-1@Assemblage", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0)

    

    Dim selComp As SldWorks.Component2

    Dim refConfig As String

    Dim compDoc As SldWorks.ModelDoc2

    

    Set selComp = SelMgr.GetSelectedObject6(1, -1)

    Set compDoc = selComp.GetModelDoc

    

    Dim configNames As Variant

    Dim vName As Variant

    Dim configName As String

    configNames = compDoc.GetConfigurationNames()

    For Each vName In configNames

        configName = vName

        Debug.Print "-----------------------------------------------"

        Debug.Print "Configuration: " + configName

        boolstatus = compDoc.ShowConfiguration2(configName)

        Call VisitDocWeldmentProperties(compDoc)

    Next vName

    

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 Property Values On Weldment Cut-list Folders 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) 2012 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.