Skip to content

Commit d38e92c

Browse files
committed
Changed the naming of the sheet view while renaming from sheet to include ()
Fixed the issue with split folders macro when folder closing tag is included into the configuration Added option to set if derived or top level configuration should be created fro the split folders to configurations macro Added option to only process selected feature folders for the split folders to configurations macro
1 parent c0f9d20 commit d38e92c

File tree

3 files changed

+61
-5
lines changed

3 files changed

+61
-5
lines changed

solidworks-api/document/drawing/rename-views-after-sheets/Macro.vba

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Sub main()
4848
nextViewIndex = nextViewIndex + 1
4949

5050
Dim newViewName As String
51-
newViewName = swSheetView.Name & nextViewIndex
51+
newViewName = swSheetView.Name & "(" & nextViewIndex & ")"
5252

5353
If False = swView.SetName2(newViewName) Then
5454
Err.Raise vbError, "", "Failed to rename " & swView.Name & " to " & ""

solidworks-api/document/features-manager/split-folders-confgurations/Macro.vba

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Const CREATE_DERIVED_CONFS As Boolean = True
2+
13
Const FOLDER_END_TAG As String = "___EndTag___"
24

35
Dim swApp As SldWorks.SldWorks
@@ -13,7 +15,18 @@ Sub main()
1315
If Not swModel Is Nothing Then
1416

1517
Dim vFeatFolders As Variant
16-
vFeatFolders = GetAllFeatureFolders(swModel)
18+
Dim vAllFeatFolders As Variant
19+
20+
Dim swSelMgr As SldWorks.SelectionMgr
21+
Set swSelMgr = swModel.SelectionManager
22+
23+
vAllFeatFolders = GetAllFeatureFolders(swModel)
24+
25+
If swSelMgr.GetSelectedObjectCount2(-1) = 0 Then
26+
vFeatFolders = vAllFeatFolders
27+
Else
28+
vFeatFolders = GetSelectedFeatureFolders(swModel)
29+
End If
1730

1831
If Not IsEmpty(vFeatFolders) Then
1932

@@ -25,7 +38,7 @@ Sub main()
2538
For i = 0 To UBound(vFeatFolders)
2639
Dim swFeatFolder As SldWorks.Feature
2740
Set swFeatFolder = vFeatFolders(i)
28-
CreateConfigurationForFolder swModel, swFeatFolder, vFeatFolders, activeConfName
41+
CreateConfigurationForFolder swModel, swFeatFolder, vAllFeatFolders, IIf(CREATE_DERIVED_CONFS, activeConfName, "")
2942
Next
3043

3144
End If
@@ -45,7 +58,7 @@ Function GetAllFeatureFolders(model As SldWorks.ModelDoc2) As Variant
4558

4659
While Not swFeat Is Nothing
4760

48-
If swFeat.GetTypeName2() = "FtrFolder" And LCase(Right(swFeat.Name, Len(FOLDER_END_TAG))) <> LCase(FOLDER_END_TAG) Then
61+
If swFeat.GetTypeName2() = "FtrFolder" And InStr(LCase(swFeat.Name), LCase(FOLDER_END_TAG)) = 0 Then
4962

5063
If (Not swFeatFolders) = -1 Then
5164
ReDim swFeatFolders(0)
@@ -70,6 +83,41 @@ Function GetAllFeatureFolders(model As SldWorks.ModelDoc2) As Variant
7083

7184
End Function
7285

86+
Function GetSelectedFeatureFolders(model As SldWorks.ModelDoc2) As Variant
87+
88+
Dim swSelMgr As SldWorks.SelectionMgr
89+
Set swSelMgr = model.SelectionManager
90+
91+
Dim swFeatFolders() As SldWorks.Feature
92+
93+
Dim i As Integer
94+
95+
For i = 1 To swSelMgr.GetSelectedObjectCount2(-1)
96+
97+
If swSelMgr.GetSelectedObjectType3(i, -1) = swSelectType_e.swSelFTRFOLDER Then
98+
99+
Dim swFeat As SldWorks.Feature
100+
Set swFeat = swSelMgr.GetSelectedObject6(i, -1)
101+
102+
If (Not swFeatFolders) = -1 Then
103+
ReDim swFeatFolders(0)
104+
Else
105+
ReDim Preserve swFeatFolders(UBound(swFeatFolders) + 1)
106+
End If
107+
108+
Set swFeatFolders(UBound(swFeatFolders)) = swFeat
109+
End If
110+
111+
Next
112+
113+
If (Not swFeatFolders) = -1 Then
114+
GetSelectedFeatureFolders = Empty
115+
Else
116+
GetSelectedFeatureFolders = swFeatFolders
117+
End If
118+
119+
End Function
120+
73121
Sub CreateConfigurationForFolder(model As SldWorks.ModelDoc2, folderFeat As SldWorks.Feature, allFeatFolders As Variant, parentConfName As String)
74122

75123
Dim swFolderConf As SldWorks.Configuration

solidworks-api/document/features-manager/split-folders-confgurations/index.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ description: VBA macro creates individual configurations for each feature folder
55
---
66
This VBA macro creates configuration for each top-level feature folder in the active SOLIDWORKS part or assembly.
77

8-
Derived configuration will be created for each feature folder and will be named after it.
8+
If no objects selected in the model then all folder features will be processed, otherwise only selected feature folders will be processed.
9+
10+
Created configuration will be named after the feature folder.
11+
12+
It is possible to specify if derived or top level configurations should be created for each feature folder.
13+
14+
~~~ vb
15+
Const CREATE_DERIVED_CONFS As Boolean = True 'True to create derived configuration, False to create top level configuration
16+
~~~
917

1018
All other folders will be suppressed for each configuration. Features outside of the folders will not be suppressed.
1119

0 commit comments

Comments
 (0)