Hello.
I have a macro that creates selection sets but I want to rename them automatically to standardize the content of the part.
Here is a macro excerpt that gives the names of the selection sets but I can't write the code to rename them...
"Sub TraverseFeatureFeatures(swFeat As SldWorks.Feature, swModel As SldWorks.ModelDoc2)
Dim swSelectionSetFolder As SldWorks.SelectionSetFolder
Dim selectionSetArray As Variant
Dim selectionSetItemArray As Variant
Dim selectionSetItemArrayTypes As Variant
Dim swSelectionSet As SldWorks.SelectionSet
Dim swSelectionSetItem As SldWorks.SelectionSetItem
Dim swFace As SldWorks.Face2
Dim swEdge As SldWorks.Edge
Dim swBody As SldWorks.Body2
Sun i As Long
Sun j As Long
Dim ret As Boolean
While Not swFeat Is Nothing
If swFeat.Name = "Selection Sets" Then
Debug.Print " " & swFeat.Name & " [" & swFeat.GetTypeName & "]"
'Get Selection Sets folder
Set swSelectionSetFolder = swFeat.GetSpecificFeature2
'Get selection sets in Selection Sets folder
selectionSetArray = swSelectionSetFolder.GetSelectionSets
For i = 0 To UBound(selectionSetArray)
Set swSelectionSet = selectionSetArray(i)
Debug.Print " Selection set[" & i & "] name: " & swSelectionSet.GetName
'Get the items and their types in this selection set
selectionSetItemArray = swSelectionSet.GetSelectionSetItems
selectionSetItemArrayTypes = swSelectionSet.GetSelectionSetItemTypes
For j = 0 To UBound(selectionSetItemArray)
Set swSelectionSetItem = selectionSetItemArray(j)
Select Case selectionSetItemArrayTypes(j)
Case swSelectType_e.swSelFACES
'Get the Dispatch object for the selection set item
Set swFace = swSelectionSetItem.GetCorrespondingItem
'Get the name of the body for the face
Set swBody = swFace.GetBody
Debug.Print " Name of face[" & j & "]'s body: " & swBody.Name
Case swSelectType_e.swSelEDGES
'Get the Dispatch object for the selection set item
Set swEdge = swSelectionSetItem.GetCorrespondingItem
'Get the name of the body for the edge
Set swBody = swEdge.GetBody
Debug.Print " Name of edge[" & j & "]'s body: " & swBody.Name
End Select
Next
Next
End If
Set swFeat = swFeat.GetNextFeature
Wend
End Sub"
Thanks in advance