Witam.
Mam makro, które tworzy zbiory wskazań, ale chcę automatycznie zmienić ich nazwy, aby ujednolicić zawartość części.
Oto fragment makra, który podaje nazwy zbiorów wskazań, ale nie mogę napisać kodu, aby zmienić ich nazwy...
"Sub TraverseFeatureFeatures(swFeat As SldWorks.Feature, swModel As SldWorks.ModelDoc2)
Dim swSelectionSetFolder jako SldWorks.SelectionSetFolder
Dim selectionSetArray As Variant
Przyciemnij selectionSetItemArray jako wariant
Dim selectionSetItemArrayTypes As Variant
Dim swSelectionSet As SldWorks.SelectionSet
Dim swSelectionSetItem jako SldWorks.SelectionSetItem
Przyciemnij swFace jako SldWorks.Face2
Przyciemnij swEdge jako SldWorks.Edge
Dim swBody jako SldWorks.Body2
Słońce i tak długo
Słońce j tak długo
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
Koniec sub"
Z góry dziękuję