AnsweredAssumed Answered

Select next item in feature tree (a cut list folder item)

Question asked by Brian Graves on Dec 11, 2019
Latest reply on Dec 15, 2019 by Brian Graves

I've used

Option Explicit
Sub main()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swSelMgr As SldWorks.SelectionMgr
    Dim swBody As SldWorks.Body2
    Dim swCutlistItem As SldWorks.Feature
    Dim swSubFeature As SldWorks.Feature
    Dim swCustPropMgr As SldWorks.CustomPropertyManager
    Dim names As Variant
    Dim name As Variant
    Dim textexp As String
    Dim evalval As String
    Dim longstatus As Long, longwarnings As Long
   
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swSelMgr = swModel.SelectionManager
    Set swCutlistItem = swSelMgr.GetSelectedObject6(1, 0)
    Set swCustPropMgr = swCutlistItem.CustomPropertyManager
    Debug.Print "Custom properties for selected weldment cut-list item"
    Debug.Print "Name", "Text Expression", "Value", "Type"
    names = swCustPropMgr.GetNames
   
    For Each name In names
        If name = "Part Number" Then
        swCustPropMgr.Get2 name, textexp, evalval
        Debug.Print name, textexp, evalval, swCustPropMgr.GetType(name)
        longstatus = swModel.SaveAs3("C:\Users\admin\Desktop\parasolid testing\" & evalval & ".x_t", 0, 2)
        End If
    Next name

   
End Sub

To create a tool that exports a parasolid of the selected cut list item folder. This exports the entire weldment as a parasolid but I am only looking to export 1 body (one of the items inside the cut list folder which I have currently selected). By selecting a single body inside of this cut list folder and running 

 

longstatus = swModel.SaveAs3("C:\Users\admin\Desktop\parasolid testing\" & evalval & ".x_t", 0, 2)

 

a single body is exported as parasolid. It works perfectly. So how do I select the very next item in the feature tree? (a single body inside of the currently selected cut list item folder) 

Outcomes