solidworks-mcp-server 3.0.8 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +175 -98
- package/LICENSE +20 -20
- package/README.md +195 -423
- package/dist/adapters/circuit-breaker.d.ts +84 -0
- package/dist/adapters/circuit-breaker.d.ts.map +1 -0
- package/dist/adapters/circuit-breaker.js +228 -0
- package/dist/adapters/circuit-breaker.js.map +1 -0
- package/dist/adapters/connection-pool.d.ts +83 -0
- package/dist/adapters/connection-pool.d.ts.map +1 -0
- package/dist/adapters/connection-pool.js +282 -0
- package/dist/adapters/connection-pool.js.map +1 -0
- package/dist/adapters/edge-adapter.d.ts +43 -0
- package/dist/adapters/edge-adapter.d.ts.map +1 -0
- package/dist/adapters/edge-adapter.js +417 -0
- package/dist/adapters/edge-adapter.js.map +1 -0
- package/dist/adapters/factory.d.ts +60 -0
- package/dist/adapters/factory.d.ts.map +1 -0
- package/dist/adapters/factory.js +212 -0
- package/dist/adapters/factory.js.map +1 -0
- package/dist/adapters/feature-complexity-analyzer.d.ts +102 -0
- package/dist/adapters/feature-complexity-analyzer.d.ts.map +1 -0
- package/dist/adapters/feature-complexity-analyzer.js +322 -0
- package/dist/adapters/feature-complexity-analyzer.js.map +1 -0
- package/dist/adapters/macro-generator.d.ts +30 -0
- package/dist/adapters/macro-generator.d.ts.map +1 -0
- package/dist/adapters/macro-generator.js +524 -0
- package/dist/adapters/macro-generator.js.map +1 -0
- package/dist/adapters/mock-solidworks-adapter.d.ts +92 -0
- package/dist/adapters/mock-solidworks-adapter.d.ts.map +1 -0
- package/dist/adapters/mock-solidworks-adapter.js +367 -0
- package/dist/adapters/mock-solidworks-adapter.js.map +1 -0
- package/dist/adapters/types.d.ts +376 -0
- package/dist/adapters/types.d.ts.map +1 -0
- package/dist/adapters/types.js +261 -0
- package/dist/adapters/types.js.map +1 -0
- package/dist/adapters/winax-adapter-enhanced.d.ts +55 -0
- package/dist/adapters/winax-adapter-enhanced.d.ts.map +1 -0
- package/dist/adapters/winax-adapter-enhanced.js +601 -0
- package/dist/adapters/winax-adapter-enhanced.js.map +1 -0
- package/dist/adapters/winax-adapter.d.ts +55 -0
- package/dist/adapters/winax-adapter.d.ts.map +1 -0
- package/dist/adapters/winax-adapter.js +667 -0
- package/dist/adapters/winax-adapter.js.map +1 -0
- package/dist/api/stainless-api.d.ts +29 -0
- package/dist/api/stainless-api.d.ts.map +1 -0
- package/dist/api/stainless-api.js +408 -0
- package/dist/api/stainless-api.js.map +1 -0
- package/dist/cache/manager.d.ts.map +1 -1
- package/dist/cache/manager.js +4 -3
- package/dist/cache/manager.js.map +1 -1
- package/dist/core/interfaces/core-abstractions.d.ts.map +1 -1
- package/dist/core/interfaces/core-abstractions.js.map +1 -1
- package/dist/db/connection.js +4 -4
- package/dist/db/connection.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +86 -79
- package/dist/index.js.map +1 -1
- package/dist/knowledge/chromadb.d.ts.map +1 -1
- package/dist/knowledge/chromadb.js +5 -3
- package/dist/knowledge/chromadb.js.map +1 -1
- package/dist/macro/recorder.d.ts +1 -1
- package/dist/macro/recorder.d.ts.map +1 -1
- package/dist/macro/recorder.js +10 -10
- package/dist/macro/recorder.js.map +1 -1
- package/dist/resources/base.js +10 -10
- package/dist/resources/base.js.map +1 -1
- package/dist/resources/design-table.d.ts +10 -12
- package/dist/resources/design-table.d.ts.map +1 -1
- package/dist/resources/design-table.js +42 -39
- package/dist/resources/design-table.js.map +1 -1
- package/dist/resources/pdm.d.ts +44 -45
- package/dist/resources/pdm.d.ts.map +1 -1
- package/dist/resources/pdm.js +118 -79
- package/dist/resources/pdm.js.map +1 -1
- package/dist/resources/registry.d.ts +1 -1
- package/dist/resources/registry.d.ts.map +1 -1
- package/dist/resources/registry.js +1 -1
- package/dist/shared/constants/solidworks-constants.d.ts.map +1 -1
- package/dist/shared/constants/solidworks-constants.js +9 -9
- package/dist/shared/constants/solidworks-constants.js.map +1 -1
- package/dist/solidworks/api.d.ts +8 -6
- package/dist/solidworks/api.d.ts.map +1 -1
- package/dist/solidworks/api.js +614 -188
- package/dist/solidworks/api.js.map +1 -1
- package/dist/state/store.d.ts +1 -1
- package/dist/state/store.d.ts.map +1 -1
- package/dist/state/store.js +14 -14
- package/dist/state/store.js.map +1 -1
- package/dist/tools/analysis.d.ts +12 -2
- package/dist/tools/analysis.d.ts.map +1 -1
- package/dist/tools/analysis.js +141 -31
- package/dist/tools/analysis.js.map +1 -1
- package/dist/tools/diagnostics.d.ts +1 -1
- package/dist/tools/diagnostics.d.ts.map +1 -1
- package/dist/tools/diagnostics.js +2 -2
- package/dist/tools/diagnostics.js.map +1 -1
- package/dist/tools/drawing.d.ts +2 -2
- package/dist/tools/drawing.d.ts.map +1 -1
- package/dist/tools/drawing.js +94 -10
- package/dist/tools/drawing.js.map +1 -1
- package/dist/tools/enhanced-drawing.d.ts +1 -1
- package/dist/tools/enhanced-drawing.d.ts.map +1 -1
- package/dist/tools/enhanced-drawing.js +10 -13
- package/dist/tools/enhanced-drawing.js.map +1 -1
- package/dist/tools/export.d.ts +1 -1
- package/dist/tools/export.d.ts.map +1 -1
- package/dist/tools/export.js +88 -14
- package/dist/tools/export.js.map +1 -1
- package/dist/tools/extrusion-helper.d.ts +15 -0
- package/dist/tools/extrusion-helper.d.ts.map +1 -0
- package/dist/tools/extrusion-helper.js +61 -0
- package/dist/tools/extrusion-helper.js.map +1 -0
- package/dist/tools/macro-security.d.ts +2 -2
- package/dist/tools/macro-security.d.ts.map +1 -1
- package/dist/tools/macro-security.js +2 -2
- package/dist/tools/macro-security.js.map +1 -1
- package/dist/tools/modeling.d.ts +2 -2
- package/dist/tools/modeling.d.ts.map +1 -1
- package/dist/tools/modeling.js +6 -6
- package/dist/tools/modeling.js.map +1 -1
- package/dist/tools/native-macro.d.ts +1 -1
- package/dist/tools/native-macro.d.ts.map +1 -1
- package/dist/tools/native-macro.js +246 -239
- package/dist/tools/native-macro.js.map +1 -1
- package/dist/tools/sketch.d.ts +28 -28
- package/dist/tools/sketch.d.ts.map +1 -1
- package/dist/tools/sketch.js +202 -136
- package/dist/tools/sketch.js.map +1 -1
- package/dist/tools/template-manager.d.ts +5 -5
- package/dist/tools/template-manager.d.ts.map +1 -1
- package/dist/tools/template-manager.js +66 -65
- package/dist/tools/template-manager.js.map +1 -1
- package/dist/tools/vba-advanced.d.ts +10 -10
- package/dist/tools/vba-advanced.d.ts.map +1 -1
- package/dist/tools/vba-advanced.js +791 -708
- package/dist/tools/vba-advanced.js.map +1 -1
- package/dist/tools/vba-assembly.d.ts +10 -10
- package/dist/tools/vba-assembly.d.ts.map +1 -1
- package/dist/tools/vba-assembly.js +562 -500
- package/dist/tools/vba-assembly.js.map +1 -1
- package/dist/tools/vba-drawing.d.ts +12 -12
- package/dist/tools/vba-drawing.d.ts.map +1 -1
- package/dist/tools/vba-drawing.js +681 -572
- package/dist/tools/vba-drawing.js.map +1 -1
- package/dist/tools/vba-file-management.d.ts +12 -12
- package/dist/tools/vba-file-management.d.ts.map +1 -1
- package/dist/tools/vba-file-management.js +662 -589
- package/dist/tools/vba-file-management.js.map +1 -1
- package/dist/tools/vba-part.d.ts +10 -10
- package/dist/tools/vba-part.d.ts.map +1 -1
- package/dist/tools/vba-part.js +484 -426
- package/dist/tools/vba-part.js.map +1 -1
- package/dist/tools/vba.d.ts +361 -361
- package/dist/tools/vba.d.ts.map +1 -1
- package/dist/tools/vba.js +67 -81
- package/dist/tools/vba.js.map +1 -1
- package/dist/utils/config.js +2 -2
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/environment.d.ts +243 -0
- package/dist/utils/environment.d.ts.map +1 -0
- package/dist/utils/environment.js +207 -0
- package/dist/utils/environment.js.map +1 -0
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +6 -6
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/solidworks-config.d.ts +39 -0
- package/dist/utils/solidworks-config.d.ts.map +1 -0
- package/dist/utils/solidworks-config.js +156 -0
- package/dist/utils/solidworks-config.js.map +1 -0
- package/package.json +84 -84
- package/scripts/setup.js +70 -70
- package/dist/application/services/command-bus.d.ts +0 -39
- package/dist/application/services/command-bus.d.ts.map +0 -1
- package/dist/application/services/command-bus.js +0 -88
- package/dist/application/services/command-bus.js.map +0 -1
- package/dist/application/services/event-bus.d.ts +0 -31
- package/dist/application/services/event-bus.d.ts.map +0 -1
- package/dist/application/services/event-bus.js +0 -83
- package/dist/application/services/event-bus.js.map +0 -1
- package/dist/application/services/query-bus.d.ts +0 -30
- package/dist/application/services/query-bus.d.ts.map +0 -1
- package/dist/application/services/query-bus.js +0 -59
- package/dist/application/services/query-bus.js.map +0 -1
- package/dist/application/services/tool-registry.d.ts +0 -53
- package/dist/application/services/tool-registry.d.ts.map +0 -1
- package/dist/application/services/tool-registry.js +0 -81
- package/dist/application/services/tool-registry.js.map +0 -1
- package/dist/application/use-cases/analysis/index.d.ts +0 -13
- package/dist/application/use-cases/analysis/index.d.ts.map +0 -1
- package/dist/application/use-cases/analysis/index.js +0 -17
- package/dist/application/use-cases/analysis/index.js.map +0 -1
- package/dist/application/use-cases/drawing/index.d.ts +0 -13
- package/dist/application/use-cases/drawing/index.d.ts.map +0 -1
- package/dist/application/use-cases/drawing/index.js +0 -17
- package/dist/application/use-cases/drawing/index.js.map +0 -1
- package/dist/application/use-cases/export/index.d.ts +0 -13
- package/dist/application/use-cases/export/index.d.ts.map +0 -1
- package/dist/application/use-cases/export/index.js +0 -17
- package/dist/application/use-cases/export/index.js.map +0 -1
- package/dist/application/use-cases/macro/index.d.ts +0 -13
- package/dist/application/use-cases/macro/index.d.ts.map +0 -1
- package/dist/application/use-cases/macro/index.js +0 -17
- package/dist/application/use-cases/macro/index.js.map +0 -1
- package/dist/application/use-cases/modeling/index.d.ts +0 -56
- package/dist/application/use-cases/modeling/index.d.ts.map +0 -1
- package/dist/application/use-cases/modeling/index.js +0 -385
- package/dist/application/use-cases/modeling/index.js.map +0 -1
- package/dist/index.refactored.d.ts +0 -7
- package/dist/index.refactored.d.ts.map +0 -1
- package/dist/index.refactored.js +0 -254
- package/dist/index.refactored.js.map +0 -1
- package/dist/infrastructure/config/configuration-manager.d.ts +0 -381
- package/dist/infrastructure/config/configuration-manager.d.ts.map +0 -1
- package/dist/infrastructure/config/configuration-manager.js +0 -566
- package/dist/infrastructure/config/configuration-manager.js.map +0 -1
- package/dist/infrastructure/container/service-locator.d.ts +0 -14
- package/dist/infrastructure/container/service-locator.d.ts.map +0 -1
- package/dist/infrastructure/container/service-locator.js +0 -38
- package/dist/infrastructure/container/service-locator.js.map +0 -1
- package/dist/infrastructure/logging/logger.d.ts +0 -24
- package/dist/infrastructure/logging/logger.d.ts.map +0 -1
- package/dist/infrastructure/logging/logger.js +0 -65
- package/dist/infrastructure/logging/logger.js.map +0 -1
- package/dist/infrastructure/solidworks/solidworks-adapter.d.ts +0 -43
- package/dist/infrastructure/solidworks/solidworks-adapter.d.ts.map +0 -1
- package/dist/infrastructure/solidworks/solidworks-adapter.js +0 -527
- package/dist/infrastructure/solidworks/solidworks-adapter.js.map +0 -1
- package/dist/presentation/mcp/request-handler.d.ts +0 -41
- package/dist/presentation/mcp/request-handler.d.ts.map +0 -1
- package/dist/presentation/mcp/request-handler.js +0 -100
- package/dist/presentation/mcp/request-handler.js.map +0 -1
- package/dist/presentation/transformers/error-transformer.d.ts +0 -16
- package/dist/presentation/transformers/error-transformer.d.ts.map +0 -1
- package/dist/presentation/transformers/error-transformer.js +0 -44
- package/dist/presentation/transformers/error-transformer.js.map +0 -1
- package/dist/presentation/transformers/response-transformer.d.ts +0 -24
- package/dist/presentation/transformers/response-transformer.d.ts.map +0 -1
- package/dist/presentation/transformers/response-transformer.js +0 -102
- package/dist/presentation/transformers/response-transformer.js.map +0 -1
- package/dist/tools/drawing-analysis.d.ts +0 -9
- package/dist/tools/drawing-analysis.d.ts.map +0 -1
- package/dist/tools/drawing-analysis.js +0 -239
- package/dist/tools/drawing-analysis.js.map +0 -1
package/dist/tools/vba-part.js
CHANGED
|
@@ -13,109 +13,121 @@ export const partModelingVBATools = [
|
|
|
13
13
|
references: z.array(z.string()).describe('Names of reference entities'),
|
|
14
14
|
offset: z.number().optional().describe('Offset distance in mm'),
|
|
15
15
|
angle: z.number().optional().describe('Angle in degrees'),
|
|
16
|
-
flipDirection: z.boolean().optional()
|
|
16
|
+
flipDirection: z.boolean().optional(),
|
|
17
17
|
}),
|
|
18
|
-
handler: (args,
|
|
18
|
+
handler: (args, _swApi) => {
|
|
19
19
|
const templates = {
|
|
20
|
-
plane: `
|
|
21
|
-
Sub CreateReferencePlane()
|
|
22
|
-
Dim swApp As SldWorks.SldWorks
|
|
23
|
-
Dim swModel As SldWorks.ModelDoc2
|
|
24
|
-
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
25
|
-
Dim swRefPlane As SldWorks.RefPlane
|
|
26
|
-
Dim swFeature As SldWorks.Feature
|
|
27
|
-
|
|
28
|
-
Set swApp = Application.SldWorks
|
|
29
|
-
Set swModel = swApp.ActiveDoc
|
|
30
|
-
|
|
31
|
-
If swModel Is Nothing Then
|
|
32
|
-
MsgBox "No active document found"
|
|
33
|
-
Exit Sub
|
|
34
|
-
End If
|
|
35
|
-
|
|
36
|
-
Set swFeatureMgr = swModel.FeatureManager
|
|
37
|
-
|
|
38
|
-
' Select reference entities
|
|
39
|
-
${args.references
|
|
40
|
-
|
|
41
|
-
swModel.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
${args.referenceType === '
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
20
|
+
plane: `
|
|
21
|
+
Sub CreateReferencePlane()
|
|
22
|
+
Dim swApp As SldWorks.SldWorks
|
|
23
|
+
Dim swModel As SldWorks.ModelDoc2
|
|
24
|
+
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
25
|
+
Dim swRefPlane As SldWorks.RefPlane
|
|
26
|
+
Dim swFeature As SldWorks.Feature
|
|
27
|
+
|
|
28
|
+
Set swApp = Application.SldWorks
|
|
29
|
+
Set swModel = swApp.ActiveDoc
|
|
30
|
+
|
|
31
|
+
If swModel Is Nothing Then
|
|
32
|
+
MsgBox "No active document found"
|
|
33
|
+
Exit Sub
|
|
34
|
+
End If
|
|
35
|
+
|
|
36
|
+
Set swFeatureMgr = swModel.FeatureManager
|
|
37
|
+
|
|
38
|
+
' Select reference entities
|
|
39
|
+
${args.references
|
|
40
|
+
.map((ref, i) => `
|
|
41
|
+
swModel.ClearSelection2 True
|
|
42
|
+
swModel.Extension.SelectByID2 "${ref}", "PLANE", 0, 0, 0, ${i === 0 ? 'False' : 'True'}, 0, Nothing, 0`)
|
|
43
|
+
.join('')}
|
|
44
|
+
|
|
45
|
+
' Create reference plane
|
|
46
|
+
${args.referenceType === 'offset'
|
|
47
|
+
? `
|
|
48
|
+
Set swRefPlane = swFeatureMgr.InsertRefPlane( _
|
|
49
|
+
swRefPlaneReferenceConstraint_Distance, ${args.offset || 10} / 1000, _
|
|
50
|
+
0, 0, 0, 0)`
|
|
51
|
+
: ''}
|
|
52
|
+
${args.referenceType === 'angle'
|
|
53
|
+
? `
|
|
54
|
+
Set swRefPlane = swFeatureMgr.InsertRefPlane( _
|
|
55
|
+
swRefPlaneReferenceConstraint_Angle, ${args.angle || 45} * 3.14159 / 180, _
|
|
56
|
+
0, 0, 0, 0)`
|
|
57
|
+
: ''}
|
|
58
|
+
${args.referenceType === 'parallel'
|
|
59
|
+
? `
|
|
60
|
+
Set swRefPlane = swFeatureMgr.InsertRefPlane( _
|
|
61
|
+
swRefPlaneReferenceConstraint_Parallel, 0, _
|
|
62
|
+
0, 0, 0, 0)`
|
|
63
|
+
: ''}
|
|
64
|
+
|
|
65
|
+
If Not swRefPlane Is Nothing Then
|
|
66
|
+
MsgBox "Reference plane created successfully"
|
|
67
|
+
Else
|
|
68
|
+
MsgBox "Failed to create reference plane"
|
|
69
|
+
End If
|
|
70
|
+
|
|
71
|
+
swModel.ClearSelection2 True
|
|
64
72
|
End Sub`,
|
|
65
|
-
axis: `
|
|
66
|
-
Sub CreateReferenceAxis()
|
|
67
|
-
Dim swApp As SldWorks.SldWorks
|
|
68
|
-
Dim swModel As SldWorks.ModelDoc2
|
|
69
|
-
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
70
|
-
Dim swFeature As SldWorks.Feature
|
|
71
|
-
|
|
72
|
-
Set swApp = Application.SldWorks
|
|
73
|
-
Set swModel = swApp.ActiveDoc
|
|
74
|
-
|
|
75
|
-
If swModel Is Nothing Then Exit Sub
|
|
76
|
-
|
|
77
|
-
Set swFeatureMgr = swModel.FeatureManager
|
|
78
|
-
|
|
79
|
-
' Select reference entities for axis
|
|
80
|
-
${args.references
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
73
|
+
axis: `
|
|
74
|
+
Sub CreateReferenceAxis()
|
|
75
|
+
Dim swApp As SldWorks.SldWorks
|
|
76
|
+
Dim swModel As SldWorks.ModelDoc2
|
|
77
|
+
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
78
|
+
Dim swFeature As SldWorks.Feature
|
|
79
|
+
|
|
80
|
+
Set swApp = Application.SldWorks
|
|
81
|
+
Set swModel = swApp.ActiveDoc
|
|
82
|
+
|
|
83
|
+
If swModel Is Nothing Then Exit Sub
|
|
84
|
+
|
|
85
|
+
Set swFeatureMgr = swModel.FeatureManager
|
|
86
|
+
|
|
87
|
+
' Select reference entities for axis
|
|
88
|
+
${args.references
|
|
89
|
+
.map((ref, i) => `
|
|
90
|
+
swModel.Extension.SelectByID2 "${ref}", "PLANE", 0, 0, 0, ${i === 0 ? 'False' : 'True'}, 0, Nothing, 0`)
|
|
91
|
+
.join('')}
|
|
92
|
+
|
|
93
|
+
' Create axis
|
|
94
|
+
Set swFeature = swFeatureMgr.InsertAxis2(True)
|
|
95
|
+
|
|
96
|
+
If Not swFeature Is Nothing Then
|
|
97
|
+
swFeature.Name = "Reference Axis"
|
|
98
|
+
MsgBox "Reference axis created: " & swFeature.Name
|
|
99
|
+
End If
|
|
100
|
+
End Sub`,
|
|
101
|
+
point: `
|
|
102
|
+
Sub CreateReferencePoint()
|
|
103
|
+
Dim swApp As SldWorks.SldWorks
|
|
104
|
+
Dim swModel As SldWorks.ModelDoc2
|
|
105
|
+
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
106
|
+
Dim swRefPoint As SldWorks.RefPoint
|
|
107
|
+
|
|
108
|
+
Set swApp = Application.SldWorks
|
|
109
|
+
Set swModel = swApp.ActiveDoc
|
|
110
|
+
|
|
111
|
+
If swModel Is Nothing Then Exit Sub
|
|
112
|
+
|
|
113
|
+
Set swFeatureMgr = swModel.FeatureManager
|
|
114
|
+
|
|
115
|
+
' Select reference for point
|
|
116
|
+
${args.references
|
|
117
|
+
.map((ref) => `
|
|
118
|
+
swModel.Extension.SelectByID2 "${ref}", "", 0, 0, 0, False, 0, Nothing, 0`)
|
|
119
|
+
.join('')}
|
|
120
|
+
|
|
121
|
+
' Create reference point
|
|
122
|
+
Set swRefPoint = swFeatureMgr.InsertReferencePoint(4, 0, ${args.offset || 0} / 1000, 1)
|
|
123
|
+
|
|
124
|
+
If Not swRefPoint Is Nothing Then
|
|
125
|
+
MsgBox "Reference point created"
|
|
126
|
+
End If
|
|
90
127
|
End Sub`,
|
|
91
|
-
point: `
|
|
92
|
-
Sub CreateReferencePoint()
|
|
93
|
-
Dim swApp As SldWorks.SldWorks
|
|
94
|
-
Dim swModel As SldWorks.ModelDoc2
|
|
95
|
-
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
96
|
-
Dim swRefPoint As SldWorks.RefPoint
|
|
97
|
-
|
|
98
|
-
Set swApp = Application.SldWorks
|
|
99
|
-
Set swModel = swApp.ActiveDoc
|
|
100
|
-
|
|
101
|
-
If swModel Is Nothing Then Exit Sub
|
|
102
|
-
|
|
103
|
-
Set swFeatureMgr = swModel.FeatureManager
|
|
104
|
-
|
|
105
|
-
' Select reference for point
|
|
106
|
-
${args.references.map((ref) => `
|
|
107
|
-
swModel.Extension.SelectByID2 "${ref}", "", 0, 0, 0, False, 0, Nothing, 0`).join('')}
|
|
108
|
-
|
|
109
|
-
' Create reference point
|
|
110
|
-
Set swRefPoint = swFeatureMgr.InsertReferencePoint(4, 0, ${args.offset || 0} / 1000, 1)
|
|
111
|
-
|
|
112
|
-
If Not swRefPoint Is Nothing Then
|
|
113
|
-
MsgBox "Reference point created"
|
|
114
|
-
End If
|
|
115
|
-
End Sub`
|
|
116
128
|
};
|
|
117
129
|
return templates[args.geometryType] || 'Geometry type not supported';
|
|
118
|
-
}
|
|
130
|
+
},
|
|
119
131
|
},
|
|
120
132
|
{
|
|
121
133
|
name: 'vba_advanced_features',
|
|
@@ -127,129 +139,149 @@ End Sub`
|
|
|
127
139
|
path: z.string().optional().describe('Path for sweep'),
|
|
128
140
|
twistAngle: z.number().optional(),
|
|
129
141
|
thinFeature: z.boolean().optional(),
|
|
130
|
-
thickness: z.number().optional().describe('Thickness in mm for thin features')
|
|
142
|
+
thickness: z.number().optional().describe('Thickness in mm for thin features'),
|
|
131
143
|
}),
|
|
132
144
|
handler: (args) => {
|
|
133
145
|
const templates = {
|
|
134
|
-
sweep: `
|
|
135
|
-
Sub CreateSweepFeature()
|
|
136
|
-
Dim swApp As SldWorks.SldWorks
|
|
137
|
-
Dim swModel As SldWorks.ModelDoc2
|
|
138
|
-
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
139
|
-
Dim swFeature As SldWorks.Feature
|
|
140
|
-
Dim swSweep As SldWorks.SweepFeatureData
|
|
141
|
-
|
|
142
|
-
Set swApp = Application.SldWorks
|
|
143
|
-
Set swModel = swApp.ActiveDoc
|
|
144
|
-
|
|
145
|
-
If swModel Is Nothing Then Exit Sub
|
|
146
|
-
|
|
147
|
-
Set swFeatureMgr = swModel.FeatureManager
|
|
148
|
-
|
|
149
|
-
' Select profile
|
|
150
|
-
swModel.Extension.SelectByID2 "${args.profiles[0] || 'Sketch1'}", "SKETCH", 0, 0, 0, False, 1, Nothing, 0
|
|
151
|
-
|
|
152
|
-
' Select path
|
|
153
|
-
swModel.Extension.SelectByID2 "${args.path || 'Sketch2'}", "SKETCH", 0, 0, 0, True, 4, Nothing, 0
|
|
154
|
-
|
|
155
|
-
${args.guideCurves && args.guideCurves.length > 0
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
swSweep
|
|
166
|
-
|
|
167
|
-
swSweep.
|
|
168
|
-
swSweep.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
146
|
+
sweep: `
|
|
147
|
+
Sub CreateSweepFeature()
|
|
148
|
+
Dim swApp As SldWorks.SldWorks
|
|
149
|
+
Dim swModel As SldWorks.ModelDoc2
|
|
150
|
+
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
151
|
+
Dim swFeature As SldWorks.Feature
|
|
152
|
+
Dim swSweep As SldWorks.SweepFeatureData
|
|
153
|
+
|
|
154
|
+
Set swApp = Application.SldWorks
|
|
155
|
+
Set swModel = swApp.ActiveDoc
|
|
156
|
+
|
|
157
|
+
If swModel Is Nothing Then Exit Sub
|
|
158
|
+
|
|
159
|
+
Set swFeatureMgr = swModel.FeatureManager
|
|
160
|
+
|
|
161
|
+
' Select profile
|
|
162
|
+
swModel.Extension.SelectByID2 "${args.profiles[0] || 'Sketch1'}", "SKETCH", 0, 0, 0, False, 1, Nothing, 0
|
|
163
|
+
|
|
164
|
+
' Select path
|
|
165
|
+
swModel.Extension.SelectByID2 "${args.path || 'Sketch2'}", "SKETCH", 0, 0, 0, True, 4, Nothing, 0
|
|
166
|
+
|
|
167
|
+
${args.guideCurves && args.guideCurves.length > 0
|
|
168
|
+
? `
|
|
169
|
+
' Select guide curves
|
|
170
|
+
${args.guideCurves
|
|
171
|
+
.map((guide, _i) => `
|
|
172
|
+
swModel.Extension.SelectByID2 "${guide}", "SKETCH", 0, 0, 0, True, 2, Nothing, 0`)
|
|
173
|
+
.join('')}`
|
|
174
|
+
: ''}
|
|
175
|
+
|
|
176
|
+
' Create sweep
|
|
177
|
+
Set swSweep = swFeatureMgr.CreateDefinition(swFeatureNameID_e.swFmSweep)
|
|
178
|
+
|
|
179
|
+
swSweep.TwistAngle = ${args.twistAngle || 0} * 3.14159 / 180
|
|
180
|
+
swSweep.MaintainTangency = True
|
|
181
|
+
swSweep.AdvancedSmoothing = True
|
|
182
|
+
${args.thinFeature
|
|
183
|
+
? `
|
|
184
|
+
swSweep.ThinFeature = True
|
|
185
|
+
swSweep.ThinWallThickness = ${args.thickness || 1} / 1000`
|
|
186
|
+
: ''}
|
|
187
|
+
|
|
188
|
+
Set swFeature = swFeatureMgr.CreateFeature(swSweep)
|
|
189
|
+
|
|
190
|
+
If Not swFeature Is Nothing Then
|
|
191
|
+
swFeature.Name = "Sweep_${Date.now()}"
|
|
192
|
+
MsgBox "Sweep feature created: " & swFeature.Name
|
|
193
|
+
End If
|
|
194
|
+
End Sub`,
|
|
195
|
+
loft: `
|
|
196
|
+
Sub CreateLoftFeature()
|
|
197
|
+
Dim swApp As SldWorks.SldWorks
|
|
198
|
+
Dim swModel As SldWorks.ModelDoc2
|
|
199
|
+
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
200
|
+
Dim swFeature As SldWorks.Feature
|
|
201
|
+
Dim swLoft As SldWorks.LoftFeatureData
|
|
202
|
+
|
|
203
|
+
Set swApp = Application.SldWorks
|
|
204
|
+
Set swModel = swApp.ActiveDoc
|
|
205
|
+
|
|
206
|
+
If swModel Is Nothing Then Exit Sub
|
|
207
|
+
|
|
208
|
+
Set swFeatureMgr = swModel.FeatureManager
|
|
209
|
+
|
|
210
|
+
' Select profiles
|
|
211
|
+
${args.profiles
|
|
212
|
+
.map((profile, i) => `
|
|
213
|
+
swModel.Extension.SelectByID2 "${profile}", "SKETCH", 0, 0, 0, ${i === 0 ? 'False' : 'True'}, 1, Nothing, 0`)
|
|
214
|
+
.join('')}
|
|
215
|
+
|
|
216
|
+
${args.guideCurves && args.guideCurves.length > 0
|
|
217
|
+
? `
|
|
218
|
+
' Select guide curves
|
|
219
|
+
${args.guideCurves
|
|
220
|
+
.map((guide) => `
|
|
221
|
+
swModel.Extension.SelectByID2 "${guide}", "SKETCH", 0, 0, 0, True, 2, Nothing, 0`)
|
|
222
|
+
.join('')}`
|
|
223
|
+
: ''}
|
|
224
|
+
|
|
225
|
+
' Create loft
|
|
226
|
+
Set swLoft = swFeatureMgr.CreateDefinition(swFeatureNameID_e.swFmLoft)
|
|
227
|
+
|
|
228
|
+
swLoft.Merge = True
|
|
229
|
+
swLoft.Close = False
|
|
230
|
+
swLoft.PreserveTangency = True
|
|
231
|
+
${args.thinFeature
|
|
232
|
+
? `
|
|
233
|
+
swLoft.ThinFeature = True
|
|
234
|
+
swLoft.Thickness = ${args.thickness || 1} / 1000`
|
|
235
|
+
: ''}
|
|
236
|
+
|
|
237
|
+
Set swFeature = swFeatureMgr.CreateFeature(swLoft)
|
|
238
|
+
|
|
239
|
+
If Not swFeature Is Nothing Then
|
|
240
|
+
swFeature.Name = "Loft_${Date.now()}"
|
|
241
|
+
MsgBox "Loft feature created: " & swFeature.Name
|
|
242
|
+
End If
|
|
176
243
|
End Sub`,
|
|
177
|
-
|
|
178
|
-
Sub
|
|
179
|
-
Dim swApp As SldWorks.SldWorks
|
|
180
|
-
Dim swModel As SldWorks.ModelDoc2
|
|
181
|
-
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
182
|
-
Dim swFeature As SldWorks.Feature
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
Set
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
If
|
|
214
|
-
swFeature.Name = "Loft_${Date.now()}"
|
|
215
|
-
MsgBox "Loft feature created: " & swFeature.Name
|
|
216
|
-
End If
|
|
244
|
+
boundary: `
|
|
245
|
+
Sub CreateBoundaryFeature()
|
|
246
|
+
Dim swApp As SldWorks.SldWorks
|
|
247
|
+
Dim swModel As SldWorks.ModelDoc2
|
|
248
|
+
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
249
|
+
Dim swFeature As SldWorks.Feature
|
|
250
|
+
|
|
251
|
+
Set swApp = Application.SldWorks
|
|
252
|
+
Set swModel = swApp.ActiveDoc
|
|
253
|
+
|
|
254
|
+
If swModel Is Nothing Then Exit Sub
|
|
255
|
+
|
|
256
|
+
Set swFeatureMgr = swModel.FeatureManager
|
|
257
|
+
|
|
258
|
+
' Select boundary curves in Direction 1
|
|
259
|
+
${args.profiles
|
|
260
|
+
.slice(0, Math.ceil(args.profiles.length / 2))
|
|
261
|
+
.map((profile, i) => `
|
|
262
|
+
swModel.Extension.SelectByID2 "${profile}", "SKETCH", 0, 0, 0, ${i === 0 ? 'False' : 'True'}, 1, Nothing, 0`)
|
|
263
|
+
.join('')}
|
|
264
|
+
|
|
265
|
+
' Select boundary curves in Direction 2
|
|
266
|
+
${args.profiles
|
|
267
|
+
.slice(Math.ceil(args.profiles.length / 2))
|
|
268
|
+
.map((profile) => `
|
|
269
|
+
swModel.Extension.SelectByID2 "${profile}", "SKETCH", 0, 0, 0, True, 2, Nothing, 0`)
|
|
270
|
+
.join('')}
|
|
271
|
+
|
|
272
|
+
' Create boundary surface/boss
|
|
273
|
+
Set swFeature = swFeatureMgr.InsertBoundaryBoss2( _
|
|
274
|
+
${args.profiles.length}, 0, 0, 1, 1, _
|
|
275
|
+
${args.thinFeature ? 'True' : 'False'}, ${args.thinFeature ? (args.thickness || 1) / 1000 : 0})
|
|
276
|
+
|
|
277
|
+
If Not swFeature Is Nothing Then
|
|
278
|
+
swFeature.Name = "Boundary_${Date.now()}"
|
|
279
|
+
MsgBox "Boundary feature created: " & swFeature.Name
|
|
280
|
+
End If
|
|
217
281
|
End Sub`,
|
|
218
|
-
boundary: `
|
|
219
|
-
Sub CreateBoundaryFeature()
|
|
220
|
-
Dim swApp As SldWorks.SldWorks
|
|
221
|
-
Dim swModel As SldWorks.ModelDoc2
|
|
222
|
-
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
223
|
-
Dim swFeature As SldWorks.Feature
|
|
224
|
-
|
|
225
|
-
Set swApp = Application.SldWorks
|
|
226
|
-
Set swModel = swApp.ActiveDoc
|
|
227
|
-
|
|
228
|
-
If swModel Is Nothing Then Exit Sub
|
|
229
|
-
|
|
230
|
-
Set swFeatureMgr = swModel.FeatureManager
|
|
231
|
-
|
|
232
|
-
' Select boundary curves in Direction 1
|
|
233
|
-
${args.profiles.slice(0, Math.ceil(args.profiles.length / 2)).map((profile, i) => `
|
|
234
|
-
swModel.Extension.SelectByID2 "${profile}", "SKETCH", 0, 0, 0, ${i === 0 ? 'False' : 'True'}, 1, Nothing, 0`).join('')}
|
|
235
|
-
|
|
236
|
-
' Select boundary curves in Direction 2
|
|
237
|
-
${args.profiles.slice(Math.ceil(args.profiles.length / 2)).map((profile) => `
|
|
238
|
-
swModel.Extension.SelectByID2 "${profile}", "SKETCH", 0, 0, 0, True, 2, Nothing, 0`).join('')}
|
|
239
|
-
|
|
240
|
-
' Create boundary surface/boss
|
|
241
|
-
Set swFeature = swFeatureMgr.InsertBoundaryBoss2( _
|
|
242
|
-
${args.profiles.length}, 0, 0, 1, 1, _
|
|
243
|
-
${args.thinFeature ? 'True' : 'False'}, ${args.thinFeature ? (args.thickness || 1) / 1000 : 0})
|
|
244
|
-
|
|
245
|
-
If Not swFeature Is Nothing Then
|
|
246
|
-
swFeature.Name = "Boundary_${Date.now()}"
|
|
247
|
-
MsgBox "Boundary feature created: " & swFeature.Name
|
|
248
|
-
End If
|
|
249
|
-
End Sub`
|
|
250
282
|
};
|
|
251
283
|
return templates[args.featureType] || 'Feature type not supported';
|
|
252
|
-
}
|
|
284
|
+
},
|
|
253
285
|
},
|
|
254
286
|
{
|
|
255
287
|
name: 'vba_pattern_features',
|
|
@@ -260,120 +292,128 @@ End Sub`
|
|
|
260
292
|
direction1: z.object({
|
|
261
293
|
spacing: z.number().describe('Spacing in mm'),
|
|
262
294
|
instances: z.number(),
|
|
263
|
-
reverseDirection: z.boolean().optional()
|
|
295
|
+
reverseDirection: z.boolean().optional(),
|
|
264
296
|
}),
|
|
265
|
-
direction2: z
|
|
297
|
+
direction2: z
|
|
298
|
+
.object({
|
|
266
299
|
spacing: z.number().describe('Spacing in mm'),
|
|
267
300
|
instances: z.number(),
|
|
268
|
-
reverseDirection: z.boolean().optional()
|
|
269
|
-
})
|
|
301
|
+
reverseDirection: z.boolean().optional(),
|
|
302
|
+
})
|
|
303
|
+
.optional(),
|
|
270
304
|
axis: z.string().optional().describe('Axis for circular pattern'),
|
|
271
305
|
angle: z.number().optional().describe('Total angle for circular pattern'),
|
|
272
|
-
seedPoint: z.array(z.number()).optional().describe('[x, y, z] for fill pattern')
|
|
306
|
+
seedPoint: z.array(z.number()).optional().describe('[x, y, z] for fill pattern'),
|
|
273
307
|
}),
|
|
274
308
|
handler: (args) => {
|
|
275
309
|
const templates = {
|
|
276
|
-
linear: `
|
|
277
|
-
Sub CreateLinearPattern()
|
|
278
|
-
Dim swApp As SldWorks.SldWorks
|
|
279
|
-
Dim swModel As SldWorks.ModelDoc2
|
|
280
|
-
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
281
|
-
Dim swFeature As SldWorks.Feature
|
|
282
|
-
|
|
283
|
-
Set swApp = Application.SldWorks
|
|
284
|
-
Set swModel = swApp.ActiveDoc
|
|
285
|
-
|
|
286
|
-
If swModel Is Nothing Then Exit Sub
|
|
287
|
-
|
|
288
|
-
Set swFeatureMgr = swModel.FeatureManager
|
|
289
|
-
|
|
290
|
-
' Select features to pattern
|
|
291
|
-
${args.featureNames
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
+
linear: `
|
|
311
|
+
Sub CreateLinearPattern()
|
|
312
|
+
Dim swApp As SldWorks.SldWorks
|
|
313
|
+
Dim swModel As SldWorks.ModelDoc2
|
|
314
|
+
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
315
|
+
Dim swFeature As SldWorks.Feature
|
|
316
|
+
|
|
317
|
+
Set swApp = Application.SldWorks
|
|
318
|
+
Set swModel = swApp.ActiveDoc
|
|
319
|
+
|
|
320
|
+
If swModel Is Nothing Then Exit Sub
|
|
321
|
+
|
|
322
|
+
Set swFeatureMgr = swModel.FeatureManager
|
|
323
|
+
|
|
324
|
+
' Select features to pattern
|
|
325
|
+
${args.featureNames
|
|
326
|
+
.map((name, i) => `
|
|
327
|
+
swModel.Extension.SelectByID2 "${name}", "BODYFEATURE", 0, 0, 0, ${i === 0 ? 'False' : 'True'}, 0, Nothing, 0`)
|
|
328
|
+
.join('')}
|
|
329
|
+
|
|
330
|
+
' Select direction references
|
|
331
|
+
swModel.Extension.SelectByID2 "Right Plane", "PLANE", 0, 0, 0, True, 1, Nothing, 0
|
|
332
|
+
${args.direction2 ? `swModel.Extension.SelectByID2 "Top Plane", "PLANE", 0, 0, 0, True, 2, Nothing, 0` : ''}
|
|
333
|
+
|
|
334
|
+
' Create linear pattern
|
|
335
|
+
Set swFeature = swFeatureMgr.FeatureLinearPattern4( _
|
|
336
|
+
${args.direction1.instances}, ${args.direction1.spacing / 1000}, _
|
|
337
|
+
${args.direction2 ? args.direction2.instances : 1}, ${args.direction2 ? args.direction2.spacing / 1000 : 0}, _
|
|
338
|
+
False, ${args.direction1.reverseDirection ? 'True' : 'False'}, _
|
|
339
|
+
"NULL", "NULL", False, False, False, False, False, False, _
|
|
340
|
+
True, True, False, False, 0, 0)
|
|
341
|
+
|
|
342
|
+
If Not swFeature Is Nothing Then
|
|
343
|
+
swFeature.Name = "LinearPattern_${Date.now()}"
|
|
344
|
+
MsgBox "Linear pattern created: " & swFeature.Name
|
|
345
|
+
End If
|
|
310
346
|
End Sub`,
|
|
311
|
-
circular: `
|
|
312
|
-
Sub CreateCircularPattern()
|
|
313
|
-
Dim swApp As SldWorks.SldWorks
|
|
314
|
-
Dim swModel As SldWorks.ModelDoc2
|
|
315
|
-
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
316
|
-
Dim swFeature As SldWorks.Feature
|
|
317
|
-
|
|
318
|
-
Set swApp = Application.SldWorks
|
|
319
|
-
Set swModel = swApp.ActiveDoc
|
|
320
|
-
|
|
321
|
-
If swModel Is Nothing Then Exit Sub
|
|
322
|
-
|
|
323
|
-
Set swFeatureMgr = swModel.FeatureManager
|
|
324
|
-
|
|
325
|
-
' Select features to pattern
|
|
326
|
-
${args.featureNames
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
'
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
347
|
+
circular: `
|
|
348
|
+
Sub CreateCircularPattern()
|
|
349
|
+
Dim swApp As SldWorks.SldWorks
|
|
350
|
+
Dim swModel As SldWorks.ModelDoc2
|
|
351
|
+
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
352
|
+
Dim swFeature As SldWorks.Feature
|
|
353
|
+
|
|
354
|
+
Set swApp = Application.SldWorks
|
|
355
|
+
Set swModel = swApp.ActiveDoc
|
|
356
|
+
|
|
357
|
+
If swModel Is Nothing Then Exit Sub
|
|
358
|
+
|
|
359
|
+
Set swFeatureMgr = swModel.FeatureManager
|
|
360
|
+
|
|
361
|
+
' Select features to pattern
|
|
362
|
+
${args.featureNames
|
|
363
|
+
.map((name, i) => `
|
|
364
|
+
swModel.Extension.SelectByID2 "${name}", "BODYFEATURE", 0, 0, 0, ${i === 0 ? 'False' : 'True'}, 0, Nothing, 0`)
|
|
365
|
+
.join('')}
|
|
366
|
+
|
|
367
|
+
' Select axis
|
|
368
|
+
swModel.Extension.SelectByID2 "${args.axis || 'Axis1'}", "AXIS", 0, 0, 0, True, 1, Nothing, 0
|
|
369
|
+
|
|
370
|
+
' Create circular pattern
|
|
371
|
+
Set swFeature = swFeatureMgr.FeatureCircularPattern5( _
|
|
372
|
+
${args.direction1.instances}, ${((args.angle || 360) * Math.PI) / 180}, _
|
|
373
|
+
False, "NULL", False, True, False, False)
|
|
374
|
+
|
|
375
|
+
If Not swFeature Is Nothing Then
|
|
376
|
+
swFeature.Name = "CircularPattern_${Date.now()}"
|
|
377
|
+
MsgBox "Circular pattern created: " & swFeature.Name
|
|
378
|
+
End If
|
|
379
|
+
End Sub`,
|
|
380
|
+
curve: `
|
|
381
|
+
Sub CreateCurveDrivenPattern()
|
|
382
|
+
Dim swApp As SldWorks.SldWorks
|
|
383
|
+
Dim swModel As SldWorks.ModelDoc2
|
|
384
|
+
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
385
|
+
Dim swFeature As SldWorks.Feature
|
|
386
|
+
|
|
387
|
+
Set swApp = Application.SldWorks
|
|
388
|
+
Set swModel = swApp.ActiveDoc
|
|
389
|
+
|
|
390
|
+
If swModel Is Nothing Then Exit Sub
|
|
391
|
+
|
|
392
|
+
Set swFeatureMgr = swModel.FeatureManager
|
|
393
|
+
|
|
394
|
+
' Select features to pattern
|
|
395
|
+
${args.featureNames
|
|
396
|
+
.map((name, i) => `
|
|
397
|
+
swModel.Extension.SelectByID2 "${name}", "BODYFEATURE", 0, 0, 0, ${i === 0 ? 'False' : 'True'}, 0, Nothing, 0`)
|
|
398
|
+
.join('')}
|
|
399
|
+
|
|
400
|
+
' Select curve
|
|
401
|
+
swModel.Extension.SelectByID2 "Sketch_Curve", "SKETCH", 0, 0, 0, True, 1, Nothing, 0
|
|
402
|
+
|
|
403
|
+
' Create curve driven pattern
|
|
404
|
+
Set swFeature = swFeatureMgr.InsertCurveDrivenPattern( _
|
|
405
|
+
False, ${args.direction1.instances}, ${args.direction1.spacing / 1000}, _
|
|
406
|
+
True, False, False, 0, True, True, _
|
|
407
|
+
False, 0, 0, False, False)
|
|
408
|
+
|
|
409
|
+
If Not swFeature Is Nothing Then
|
|
410
|
+
swFeature.Name = "CurvePattern_${Date.now()}"
|
|
411
|
+
MsgBox "Curve driven pattern created: " & swFeature.Name
|
|
412
|
+
End If
|
|
341
413
|
End Sub`,
|
|
342
|
-
curve: `
|
|
343
|
-
Sub CreateCurveDrivenPattern()
|
|
344
|
-
Dim swApp As SldWorks.SldWorks
|
|
345
|
-
Dim swModel As SldWorks.ModelDoc2
|
|
346
|
-
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
347
|
-
Dim swFeature As SldWorks.Feature
|
|
348
|
-
|
|
349
|
-
Set swApp = Application.SldWorks
|
|
350
|
-
Set swModel = swApp.ActiveDoc
|
|
351
|
-
|
|
352
|
-
If swModel Is Nothing Then Exit Sub
|
|
353
|
-
|
|
354
|
-
Set swFeatureMgr = swModel.FeatureManager
|
|
355
|
-
|
|
356
|
-
' Select features to pattern
|
|
357
|
-
${args.featureNames.map((name, i) => `
|
|
358
|
-
swModel.Extension.SelectByID2 "${name}", "BODYFEATURE", 0, 0, 0, ${i === 0 ? 'False' : 'True'}, 0, Nothing, 0`).join('')}
|
|
359
|
-
|
|
360
|
-
' Select curve
|
|
361
|
-
swModel.Extension.SelectByID2 "Sketch_Curve", "SKETCH", 0, 0, 0, True, 1, Nothing, 0
|
|
362
|
-
|
|
363
|
-
' Create curve driven pattern
|
|
364
|
-
Set swFeature = swFeatureMgr.InsertCurveDrivenPattern( _
|
|
365
|
-
False, ${args.direction1.instances}, ${args.direction1.spacing / 1000}, _
|
|
366
|
-
True, False, False, 0, True, True, _
|
|
367
|
-
False, 0, 0, False, False)
|
|
368
|
-
|
|
369
|
-
If Not swFeature Is Nothing Then
|
|
370
|
-
swFeature.Name = "CurvePattern_${Date.now()}"
|
|
371
|
-
MsgBox "Curve driven pattern created: " & swFeature.Name
|
|
372
|
-
End If
|
|
373
|
-
End Sub`
|
|
374
414
|
};
|
|
375
415
|
return templates[args.patternType] || 'Pattern type not supported';
|
|
376
|
-
}
|
|
416
|
+
},
|
|
377
417
|
},
|
|
378
418
|
{
|
|
379
419
|
name: 'vba_sheet_metal',
|
|
@@ -385,66 +425,72 @@ End Sub`
|
|
|
385
425
|
bendAngle: z.number().optional().describe('Bend angle in degrees'),
|
|
386
426
|
kFactor: z.number().optional().default(0.5),
|
|
387
427
|
reliefType: z.enum(['rectangular', 'obround', 'tear']).optional(),
|
|
388
|
-
reliefRatio: z.number().optional().default(0.5)
|
|
428
|
+
reliefRatio: z.number().optional().default(0.5),
|
|
389
429
|
}),
|
|
390
430
|
handler: (args) => {
|
|
391
|
-
return `
|
|
392
|
-
Sub CreateSheetMetalFeature_${args.operation}()
|
|
393
|
-
Dim swApp As SldWorks.SldWorks
|
|
394
|
-
Dim swModel As SldWorks.ModelDoc2
|
|
395
|
-
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
396
|
-
Dim swFeature As SldWorks.Feature
|
|
397
|
-
Dim swSheetMetal As SldWorks.SheetMetalFeatureData
|
|
398
|
-
|
|
399
|
-
Set swApp = Application.SldWorks
|
|
400
|
-
Set swModel = swApp.ActiveDoc
|
|
401
|
-
|
|
402
|
-
If swModel Is Nothing Then
|
|
403
|
-
MsgBox "No active document"
|
|
404
|
-
Exit Sub
|
|
405
|
-
End If
|
|
406
|
-
|
|
407
|
-
Set swFeatureMgr = swModel.FeatureManager
|
|
408
|
-
|
|
409
|
-
' Initialize sheet metal parameters
|
|
410
|
-
swModel.SetSheetMetalDefaultParameters _
|
|
411
|
-
${args.thickness / 1000}, ${(args.bendRadius || args.thickness) / 1000}, _
|
|
412
|
-
${args.kFactor}, ${args.reliefRatio}, _
|
|
413
|
-
${args.reliefType === 'rectangular' ? '0' : args.reliefType === 'obround' ? '1' : '2'}
|
|
414
|
-
|
|
415
|
-
${args.operation === 'base_flange'
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
0,
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
0,
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
431
|
+
return `
|
|
432
|
+
Sub CreateSheetMetalFeature_${args.operation}()
|
|
433
|
+
Dim swApp As SldWorks.SldWorks
|
|
434
|
+
Dim swModel As SldWorks.ModelDoc2
|
|
435
|
+
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
436
|
+
Dim swFeature As SldWorks.Feature
|
|
437
|
+
Dim swSheetMetal As SldWorks.SheetMetalFeatureData
|
|
438
|
+
|
|
439
|
+
Set swApp = Application.SldWorks
|
|
440
|
+
Set swModel = swApp.ActiveDoc
|
|
441
|
+
|
|
442
|
+
If swModel Is Nothing Then
|
|
443
|
+
MsgBox "No active document"
|
|
444
|
+
Exit Sub
|
|
445
|
+
End If
|
|
446
|
+
|
|
447
|
+
Set swFeatureMgr = swModel.FeatureManager
|
|
448
|
+
|
|
449
|
+
' Initialize sheet metal parameters
|
|
450
|
+
swModel.SetSheetMetalDefaultParameters _
|
|
451
|
+
${args.thickness / 1000}, ${(args.bendRadius || args.thickness) / 1000}, _
|
|
452
|
+
${args.kFactor}, ${args.reliefRatio}, _
|
|
453
|
+
${args.reliefType === 'rectangular' ? '0' : args.reliefType === 'obround' ? '1' : '2'}
|
|
454
|
+
|
|
455
|
+
${args.operation === 'base_flange'
|
|
456
|
+
? `
|
|
457
|
+
' Create base flange
|
|
458
|
+
swModel.Extension.SelectByID2 "Sketch1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0
|
|
459
|
+
Set swFeature = swFeatureMgr.InsertSheetMetalBaseFlange2( _
|
|
460
|
+
${args.thickness / 1000}, False, ${(args.bendRadius || args.thickness) / 1000}, _
|
|
461
|
+
0, ${args.kFactor}, True, False, True, _
|
|
462
|
+
0, 0, 0, False, 0, 0, 0, 0)`
|
|
463
|
+
: ''}
|
|
464
|
+
|
|
465
|
+
${args.operation === 'edge_flange'
|
|
466
|
+
? `
|
|
467
|
+
' Create edge flange
|
|
468
|
+
swModel.Extension.SelectByID2 "Edge1", "EDGE", 0, 0, 0, False, 0, Nothing, 0
|
|
469
|
+
Set swFeature = swFeatureMgr.InsertSheetMetalEdgeFlange2( _
|
|
470
|
+
0, False, ${((args.bendAngle || 90) * Math.PI) / 180}, _
|
|
471
|
+
50 / 1000, 0, 0, ${(args.bendRadius || args.thickness) / 1000}, _
|
|
472
|
+
0, 0, False, False, False, False, True, _
|
|
473
|
+
0, 0, 0, 0, 0)`
|
|
474
|
+
: ''}
|
|
475
|
+
|
|
476
|
+
${args.operation === 'hem'
|
|
477
|
+
? `
|
|
478
|
+
' Create hem
|
|
479
|
+
swModel.Extension.SelectByID2 "Edge1", "EDGE", 0, 0, 0, False, 0, Nothing, 0
|
|
480
|
+
Set swFeature = swFeatureMgr.InsertSheetMetalHem2( _
|
|
481
|
+
1, 1, False, ${(args.thickness * 2) / 1000}, _
|
|
482
|
+
${(args.bendRadius || args.thickness) / 1000}, 0, 0, _
|
|
483
|
+
0, 0, False, False, 0)`
|
|
484
|
+
: ''}
|
|
485
|
+
|
|
486
|
+
If Not swFeature Is Nothing Then
|
|
487
|
+
swFeature.Name = "SheetMetal_${args.operation}_${Date.now()}"
|
|
488
|
+
MsgBox "Sheet metal feature created: " & swFeature.Name
|
|
489
|
+
Else
|
|
490
|
+
MsgBox "Failed to create sheet metal feature"
|
|
491
|
+
End If
|
|
446
492
|
End Sub`;
|
|
447
|
-
}
|
|
493
|
+
},
|
|
448
494
|
},
|
|
449
495
|
{
|
|
450
496
|
name: 'vba_surface_modeling',
|
|
@@ -455,62 +501,74 @@ End Sub`;
|
|
|
455
501
|
distance: z.number().optional().describe('Distance in mm'),
|
|
456
502
|
angle: z.number().optional().describe('Angle in degrees'),
|
|
457
503
|
offsetDistance: z.number().optional().describe('Offset distance in mm'),
|
|
458
|
-
thickenDepth: z.number().optional().describe('Thicken depth in mm')
|
|
504
|
+
thickenDepth: z.number().optional().describe('Thicken depth in mm'),
|
|
459
505
|
}),
|
|
460
506
|
handler: (args) => {
|
|
461
|
-
return `
|
|
462
|
-
Sub CreateSurfaceFeature_${args.surfaceType}()
|
|
463
|
-
Dim swApp As SldWorks.SldWorks
|
|
464
|
-
Dim swModel As SldWorks.ModelDoc2
|
|
465
|
-
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
466
|
-
Dim swFeature As SldWorks.Feature
|
|
467
|
-
|
|
468
|
-
Set swApp = Application.SldWorks
|
|
469
|
-
Set swModel = swApp.ActiveDoc
|
|
470
|
-
|
|
471
|
-
If swModel Is Nothing Then Exit Sub
|
|
472
|
-
|
|
473
|
-
Set swFeatureMgr = swModel.FeatureManager
|
|
474
|
-
|
|
475
|
-
${args.surfaceType === 'extrude'
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
${args.surfaceType === '
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
swModel.Extension.SelectByID2 "
|
|
506
|
-
Set swFeature = swFeatureMgr.
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
507
|
+
return `
|
|
508
|
+
Sub CreateSurfaceFeature_${args.surfaceType}()
|
|
509
|
+
Dim swApp As SldWorks.SldWorks
|
|
510
|
+
Dim swModel As SldWorks.ModelDoc2
|
|
511
|
+
Dim swFeatureMgr As SldWorks.FeatureManager
|
|
512
|
+
Dim swFeature As SldWorks.Feature
|
|
513
|
+
|
|
514
|
+
Set swApp = Application.SldWorks
|
|
515
|
+
Set swModel = swApp.ActiveDoc
|
|
516
|
+
|
|
517
|
+
If swModel Is Nothing Then Exit Sub
|
|
518
|
+
|
|
519
|
+
Set swFeatureMgr = swModel.FeatureManager
|
|
520
|
+
|
|
521
|
+
${args.surfaceType === 'extrude'
|
|
522
|
+
? `
|
|
523
|
+
' Surface extrude
|
|
524
|
+
swModel.Extension.SelectByID2 "${args.sketches[0]}", "SKETCH", 0, 0, 0, False, 0, Nothing, 0
|
|
525
|
+
Set swFeature = swFeatureMgr.FeatureExtruRefSurface2( _
|
|
526
|
+
True, False, False, 0, 0, ${(args.distance || 10) / 1000}, 0, _
|
|
527
|
+
False, False, False, False, 0, 0, False, False, False, False, False)`
|
|
528
|
+
: ''}
|
|
529
|
+
|
|
530
|
+
${args.surfaceType === 'revolve'
|
|
531
|
+
? `
|
|
532
|
+
' Surface revolve
|
|
533
|
+
swModel.Extension.SelectByID2 "${args.sketches[0]}", "SKETCH", 0, 0, 0, False, 0, Nothing, 0
|
|
534
|
+
swModel.Extension.SelectByID2 "Axis1", "AXIS", 0, 0, 0, True, 1, Nothing, 0
|
|
535
|
+
Set swFeature = swFeatureMgr.FeatureRevolve2( _
|
|
536
|
+
True, True, False, False, False, False, 0, 0, _
|
|
537
|
+
${((args.angle || 360) * Math.PI) / 180}, 0, False, False, 0, 0, 0, 0, 0, True, True, True)`
|
|
538
|
+
: ''}
|
|
539
|
+
|
|
540
|
+
${args.surfaceType === 'offset'
|
|
541
|
+
? `
|
|
542
|
+
' Offset surface
|
|
543
|
+
swModel.Extension.SelectByID2 "Surface1", "SURFACE", 0, 0, 0, False, 0, Nothing, 0
|
|
544
|
+
Set swFeature = swFeatureMgr.InsertOffsetSurface( _
|
|
545
|
+
${(args.offsetDistance || 5) / 1000}, False)`
|
|
546
|
+
: ''}
|
|
547
|
+
|
|
548
|
+
${args.surfaceType === 'thicken'
|
|
549
|
+
? `
|
|
550
|
+
' Thicken surface
|
|
551
|
+
swModel.Extension.SelectByID2 "Surface1", "SURFACE", 0, 0, 0, False, 0, Nothing, 0
|
|
552
|
+
Set swFeature = swFeatureMgr.FeatureThicken( _
|
|
553
|
+
${(args.thickenDepth || 2) / 1000}, 0, 0, False, True, True, True)`
|
|
554
|
+
: ''}
|
|
555
|
+
|
|
556
|
+
${args.surfaceType === 'knit'
|
|
557
|
+
? `
|
|
558
|
+
' Knit surfaces
|
|
559
|
+
${args.sketches
|
|
560
|
+
.map((sketch, i) => `
|
|
561
|
+
swModel.Extension.SelectByID2 "${sketch}", "SURFACE", 0, 0, 0, ${i === 0 ? 'False' : 'True'}, 0, Nothing, 0`)
|
|
562
|
+
.join('')}
|
|
563
|
+
Set swFeature = swFeatureMgr.InsertKnitSurface2(0.0001, True, False, True)`
|
|
564
|
+
: ''}
|
|
565
|
+
|
|
566
|
+
If Not swFeature Is Nothing Then
|
|
567
|
+
swFeature.Name = "Surface_${args.surfaceType}_${Date.now()}"
|
|
568
|
+
MsgBox "Surface created: " & swFeature.Name
|
|
569
|
+
End If
|
|
512
570
|
End Sub`;
|
|
513
|
-
}
|
|
514
|
-
}
|
|
571
|
+
},
|
|
572
|
+
},
|
|
515
573
|
];
|
|
516
574
|
//# sourceMappingURL=vba-part.js.map
|