Moves the specified feature to another location in the FeatureManager design tree of this part or assembly.
'VBA
'This example demonstrates how to use this method to re-order folders in the Cut list/Solid Bodies folder.
' Preconditions:
' 1. Open Public_documents\samples\tutorial\api\weldment_box3.sldprt.
' 2. Open an Immediate window.
' 3. Run/Debug the macro.
'
'Postconditions:
' 1. When the macro pauses, inspect the Cut list folder.
' 2. Observe the order of two new sub folders in the Cut list folder: Sub-weldment2 comes before Sub-weldment3.
' 3. Press F5 to reorder these folders.
' 4. When the macro pauses, inspect the reordered folders: Sub-weldment3 moves before Sub-weldment2.
' 5. Select a body or folder in the Cut list folder.
' 6. Press F5 to locate the selection's parent folder.
' 7. Inspect the Immediate window for the parent folder type and name (Type = "SolidBodyFolder" and Name = "Solid Bodies").
'
' NOTE: Do not save the model as it is used by other examples.
'=====================================================
Dim swApp As SldWorks.SldWorks
Dim myFeature As SldWorks.Feature
Dim Part As SldWorks.ModelDoc2
Dim swFolderFeat As SldWorks.Feature
Dim swFeatureMgr As SldWorks.FeatureManager
Dim swSelectionMgr As SldWorks.SelectionMgr
Dim swSelObj As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Option Explicit
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("Structural Member1[1]", "SOLIDBODY", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Structural Member1[2]", "SOLIDBODY", 0, 0, 0, True, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Structural Member1[3]", "SOLIDBODY", 0, 0, 0, True, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Structural Member1[4]", "SOLIDBODY", 0, 0, 0, True, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Structural Member1[6]", "SOLIDBODY", 0, 0, 0, True, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Structural Member1[8]", "SOLIDBODY", 0, 0, 0, True, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Structural Member3[1]", "SOLIDBODY", 0, 0, 0, True, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Structural Member3[2]", "SOLIDBODY", 0, 0, 0, True, 0, Nothing, 0)
Set myFeature = Part.FeatureManager.InsertSubFolder()
boolstatus = Part.Extension.SelectByID2("Gusset1", "SOLIDBODY", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Gusset2", "SOLIDBODY", 0, 0, 0, True, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Gusset3", "SOLIDBODY", 0, 0, 0, True, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Gusset4", "SOLIDBODY", 0, 0, 0, True, 0, Nothing, 0)
Set myFeature = Part.FeatureManager.InsertSubFolder()
Stop '1. Inspect the order of cut list folders;
'2. Press F5 to reorder the folders
boolstatus = Part.Extension.ReorderFeature2("Sub-weldment2", "Sub-weldment3", swMoveLocation_e.swMoveAfter)
Stop '1. Inspect the new order of cut list folders;
'2. Select a body or body folder in the cut list folder;
'3. Press F5 to locate its parent folder
Set swSelectionMgr = Part.SelectionManager
Debug.Print "Selected Obj Type: " & swSelectionMgr.GetSelectedObjectType3(1, -1)
Set swSelObj = swSelectionMgr.GetSelectedObject6(1, -1)
' Locate the parent folder of the selection
Set swFeatureMgr = Part.FeatureManager
Set swFolderFeat = swFeatureMgr.CutListFolderLocation(swSelObj)
If swFolderFeat Is Nothing Then
Debug.Print "Please select a solid body/cut list item or solid body/cut list folder"
Exit Sub
End If
Debug.Print "Parent folder Type: " & swFolderFeat.GetTypeName2 & " Name: " & swFolderFeat.Name
End Sub