solidworks-mcp-server 3.0.9 → 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 -131
- package/LICENSE +20 -20
- package/README.md +195 -444
- 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 -3
- package/dist/solidworks/api.d.ts.map +1 -1
- package/dist/solidworks/api.js +599 -134
- 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
|
@@ -9,9 +9,22 @@ export const assemblyVBATools = [
|
|
|
9
9
|
description: 'Generate VBA for creating assembly mates',
|
|
10
10
|
inputSchema: z.object({
|
|
11
11
|
mateType: z.enum([
|
|
12
|
-
'coincident',
|
|
13
|
-
'
|
|
14
|
-
'
|
|
12
|
+
'coincident',
|
|
13
|
+
'parallel',
|
|
14
|
+
'perpendicular',
|
|
15
|
+
'tangent',
|
|
16
|
+
'concentric',
|
|
17
|
+
'distance',
|
|
18
|
+
'angle',
|
|
19
|
+
'symmetric',
|
|
20
|
+
'width',
|
|
21
|
+
'path',
|
|
22
|
+
'linear_coupler',
|
|
23
|
+
'cam',
|
|
24
|
+
'gear',
|
|
25
|
+
'rack_pinion',
|
|
26
|
+
'screw',
|
|
27
|
+
'universal_joint',
|
|
15
28
|
]),
|
|
16
29
|
component1: z.string().describe('First component name'),
|
|
17
30
|
face1: z.string().describe('Face/edge/vertex on first component'),
|
|
@@ -20,7 +33,7 @@ export const assemblyVBATools = [
|
|
|
20
33
|
distance: z.number().optional().describe('Distance in mm for distance mate'),
|
|
21
34
|
angle: z.number().optional().describe('Angle in degrees for angle mate'),
|
|
22
35
|
flip: z.boolean().optional(),
|
|
23
|
-
alignmentType: z.enum(['aligned', 'anti_aligned', 'closest']).optional()
|
|
36
|
+
alignmentType: z.enum(['aligned', 'anti_aligned', 'closest']).optional(),
|
|
24
37
|
}),
|
|
25
38
|
handler: (args) => {
|
|
26
39
|
const mateConstants = {
|
|
@@ -35,70 +48,76 @@ export const assemblyVBATools = [
|
|
|
35
48
|
cam: 'swMateCAMFOLLOWER',
|
|
36
49
|
gear: 'swMateGEAR',
|
|
37
50
|
rack_pinion: 'swMateRACKPINION',
|
|
38
|
-
screw: 'swMateSCREW'
|
|
51
|
+
screw: 'swMateSCREW',
|
|
39
52
|
};
|
|
40
|
-
return `
|
|
41
|
-
Sub CreateAssemblyMate_${args.mateType}()
|
|
42
|
-
Dim swApp As SldWorks.SldWorks
|
|
43
|
-
Dim swAssy As SldWorks.AssemblyDoc
|
|
44
|
-
Dim swMate As SldWorks.Mate2
|
|
45
|
-
Dim swSelMgr As SldWorks.SelectionMgr
|
|
46
|
-
Dim mateError As Long
|
|
47
|
-
|
|
48
|
-
Set swApp = Application.SldWorks
|
|
49
|
-
Set swAssy = swApp.ActiveDoc
|
|
50
|
-
|
|
51
|
-
If swAssy Is Nothing Then
|
|
52
|
-
MsgBox "Please open an assembly document"
|
|
53
|
-
Exit Sub
|
|
54
|
-
End If
|
|
55
|
-
|
|
56
|
-
Set swSelMgr = swAssy.SelectionManager
|
|
57
|
-
|
|
58
|
-
' Clear selections
|
|
59
|
-
swAssy.ClearSelection2 True
|
|
60
|
-
|
|
61
|
-
' Select first entity
|
|
62
|
-
swAssy.Extension.SelectByID2 "${args.face1}@${args.component1}", "FACE", 0, 0, 0, False, 1, Nothing, 0
|
|
63
|
-
|
|
64
|
-
' Select second entity
|
|
65
|
-
swAssy.Extension.SelectByID2 "${args.face2}@${args.component2}", "FACE", 0, 0, 0, True, 1, Nothing, 0
|
|
66
|
-
|
|
67
|
-
' Create mate
|
|
68
|
-
${args.mateType === 'distance'
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
${args.
|
|
72
|
-
${args.
|
|
73
|
-
${args.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
53
|
+
return `
|
|
54
|
+
Sub CreateAssemblyMate_${args.mateType}()
|
|
55
|
+
Dim swApp As SldWorks.SldWorks
|
|
56
|
+
Dim swAssy As SldWorks.AssemblyDoc
|
|
57
|
+
Dim swMate As SldWorks.Mate2
|
|
58
|
+
Dim swSelMgr As SldWorks.SelectionMgr
|
|
59
|
+
Dim mateError As Long
|
|
60
|
+
|
|
61
|
+
Set swApp = Application.SldWorks
|
|
62
|
+
Set swAssy = swApp.ActiveDoc
|
|
63
|
+
|
|
64
|
+
If swAssy Is Nothing Then
|
|
65
|
+
MsgBox "Please open an assembly document"
|
|
66
|
+
Exit Sub
|
|
67
|
+
End If
|
|
68
|
+
|
|
69
|
+
Set swSelMgr = swAssy.SelectionManager
|
|
70
|
+
|
|
71
|
+
' Clear selections
|
|
72
|
+
swAssy.ClearSelection2 True
|
|
73
|
+
|
|
74
|
+
' Select first entity
|
|
75
|
+
swAssy.Extension.SelectByID2 "${args.face1}@${args.component1}", "FACE", 0, 0, 0, False, 1, Nothing, 0
|
|
76
|
+
|
|
77
|
+
' Select second entity
|
|
78
|
+
swAssy.Extension.SelectByID2 "${args.face2}@${args.component2}", "FACE", 0, 0, 0, True, 1, Nothing, 0
|
|
79
|
+
|
|
80
|
+
' Create mate
|
|
81
|
+
${args.mateType === 'distance'
|
|
82
|
+
? `
|
|
83
|
+
Set swMate = swAssy.AddMate5( _
|
|
84
|
+
${mateConstants[args.mateType]}, _
|
|
85
|
+
${args.alignmentType === 'anti_aligned' ? 'swMateAlignANTI_ALIGNED' : 'swMateAlignALIGNED'}, _
|
|
86
|
+
${args.flip ? 'True' : 'False'}, _
|
|
87
|
+
${args.distance / 1000}, 0, 0, 0, 0, 0, 0, 0, _
|
|
88
|
+
False, False, 0, mateError)`
|
|
89
|
+
: ''}
|
|
90
|
+
|
|
91
|
+
${args.mateType === 'angle'
|
|
92
|
+
? `
|
|
93
|
+
Set swMate = swAssy.AddMate5( _
|
|
94
|
+
${mateConstants[args.mateType]}, _
|
|
95
|
+
${args.alignmentType === 'anti_aligned' ? 'swMateAlignANTI_ALIGNED' : 'swMateAlignALIGNED'}, _
|
|
96
|
+
${args.flip ? 'True' : 'False'}, _
|
|
97
|
+
0, ${(args.angle * Math.PI) / 180}, 0, 0, 0, 0, 0, 0, _
|
|
98
|
+
False, False, 0, mateError)`
|
|
99
|
+
: ''}
|
|
100
|
+
|
|
101
|
+
${!['distance', 'angle'].includes(args.mateType)
|
|
102
|
+
? `
|
|
103
|
+
Set swMate = swAssy.AddMate5( _
|
|
104
|
+
${mateConstants[args.mateType]}, _
|
|
105
|
+
${args.alignmentType === 'anti_aligned' ? 'swMateAlignANTI_ALIGNED' : 'swMateAlignALIGNED'}, _
|
|
106
|
+
${args.flip ? 'True' : 'False'}, _
|
|
107
|
+
0, 0, 0, 0, 0, 0, 0, 0, _
|
|
108
|
+
False, False, 0, mateError)`
|
|
109
|
+
: ''}
|
|
110
|
+
|
|
111
|
+
If Not swMate Is Nothing Then
|
|
112
|
+
MsgBox "${args.mateType} mate created successfully"
|
|
113
|
+
swAssy.EditRebuild3
|
|
114
|
+
Else
|
|
115
|
+
MsgBox "Failed to create mate. Error code: " & mateError
|
|
116
|
+
End If
|
|
117
|
+
|
|
118
|
+
swAssy.ClearSelection2 True
|
|
100
119
|
End Sub`;
|
|
101
|
-
}
|
|
120
|
+
},
|
|
102
121
|
},
|
|
103
122
|
{
|
|
104
123
|
name: 'vba_assembly_components',
|
|
@@ -108,389 +127,414 @@ End Sub`;
|
|
|
108
127
|
componentPath: z.string().optional().describe('Path to component file'),
|
|
109
128
|
componentName: z.string().optional().describe('Component name in assembly'),
|
|
110
129
|
configurationName: z.string().optional(),
|
|
111
|
-
position: z
|
|
130
|
+
position: z
|
|
131
|
+
.object({
|
|
112
132
|
x: z.number(),
|
|
113
133
|
y: z.number(),
|
|
114
|
-
z: z.number()
|
|
115
|
-
})
|
|
134
|
+
z: z.number(),
|
|
135
|
+
})
|
|
136
|
+
.optional(),
|
|
116
137
|
quantity: z.number().optional(),
|
|
117
138
|
patternType: z.enum(['linear', 'circular']).optional(),
|
|
118
|
-
spacing: z.number().optional().describe('Spacing in mm')
|
|
139
|
+
spacing: z.number().optional().describe('Spacing in mm'),
|
|
119
140
|
}),
|
|
120
141
|
handler: (args) => {
|
|
121
142
|
const operations = {
|
|
122
|
-
insert: `
|
|
123
|
-
Sub InsertComponent()
|
|
124
|
-
Dim swApp As SldWorks.SldWorks
|
|
125
|
-
Dim swAssy As SldWorks.AssemblyDoc
|
|
126
|
-
Dim swComp As SldWorks.Component2
|
|
127
|
-
Dim swMathUtil As SldWorks.MathUtility
|
|
128
|
-
Dim swTransform As SldWorks.MathTransform
|
|
129
|
-
Dim transformData(15) As Double
|
|
130
|
-
|
|
131
|
-
Set swApp = Application.SldWorks
|
|
132
|
-
Set swAssy = swApp.ActiveDoc
|
|
133
|
-
|
|
134
|
-
If swAssy Is Nothing Then
|
|
135
|
-
MsgBox "Please open an assembly document"
|
|
136
|
-
Exit Sub
|
|
137
|
-
End If
|
|
138
|
-
|
|
139
|
-
Set swMathUtil = swApp.GetMathUtility
|
|
140
|
-
|
|
141
|
-
' Set transform matrix for position
|
|
142
|
-
transformData(0) = 1: transformData(1) = 0: transformData(2) = 0
|
|
143
|
-
transformData(3) = 0: transformData(4) = 1: transformData(5) = 0
|
|
144
|
-
transformData(6) = 0: transformData(7) = 0: transformData(8) = 1
|
|
145
|
-
transformData(9) = ${args.position?.x || 0} / 1000
|
|
146
|
-
transformData(10) = ${args.position?.y || 0} / 1000
|
|
147
|
-
transformData(11) = ${args.position?.z || 0} / 1000
|
|
148
|
-
transformData(12) = 1
|
|
149
|
-
|
|
150
|
-
Set swTransform = swMathUtil.CreateTransform(transformData)
|
|
151
|
-
|
|
152
|
-
' Insert component
|
|
153
|
-
Set swComp = swAssy.AddComponent5( _
|
|
154
|
-
"${args.componentPath}", _
|
|
155
|
-
swAddComponentConfigOptions_e.swAddComponentConfigOptions_CurrentSelectedConfig, _
|
|
156
|
-
"${args.configurationName || ''}", _
|
|
157
|
-
False, "", _
|
|
158
|
-
${args.position?.x || 0} / 1000, _
|
|
159
|
-
${args.position?.y || 0} / 1000, _
|
|
160
|
-
${args.position?.z || 0} / 1000)
|
|
161
|
-
|
|
162
|
-
If Not swComp Is Nothing Then
|
|
163
|
-
MsgBox "Component inserted: " & swComp.Name2
|
|
164
|
-
swAssy.EditRebuild3
|
|
165
|
-
Else
|
|
166
|
-
MsgBox "Failed to insert component"
|
|
167
|
-
End If
|
|
143
|
+
insert: `
|
|
144
|
+
Sub InsertComponent()
|
|
145
|
+
Dim swApp As SldWorks.SldWorks
|
|
146
|
+
Dim swAssy As SldWorks.AssemblyDoc
|
|
147
|
+
Dim swComp As SldWorks.Component2
|
|
148
|
+
Dim swMathUtil As SldWorks.MathUtility
|
|
149
|
+
Dim swTransform As SldWorks.MathTransform
|
|
150
|
+
Dim transformData(15) As Double
|
|
151
|
+
|
|
152
|
+
Set swApp = Application.SldWorks
|
|
153
|
+
Set swAssy = swApp.ActiveDoc
|
|
154
|
+
|
|
155
|
+
If swAssy Is Nothing Then
|
|
156
|
+
MsgBox "Please open an assembly document"
|
|
157
|
+
Exit Sub
|
|
158
|
+
End If
|
|
159
|
+
|
|
160
|
+
Set swMathUtil = swApp.GetMathUtility
|
|
161
|
+
|
|
162
|
+
' Set transform matrix for position
|
|
163
|
+
transformData(0) = 1: transformData(1) = 0: transformData(2) = 0
|
|
164
|
+
transformData(3) = 0: transformData(4) = 1: transformData(5) = 0
|
|
165
|
+
transformData(6) = 0: transformData(7) = 0: transformData(8) = 1
|
|
166
|
+
transformData(9) = ${args.position?.x || 0} / 1000
|
|
167
|
+
transformData(10) = ${args.position?.y || 0} / 1000
|
|
168
|
+
transformData(11) = ${args.position?.z || 0} / 1000
|
|
169
|
+
transformData(12) = 1
|
|
170
|
+
|
|
171
|
+
Set swTransform = swMathUtil.CreateTransform(transformData)
|
|
172
|
+
|
|
173
|
+
' Insert component
|
|
174
|
+
Set swComp = swAssy.AddComponent5( _
|
|
175
|
+
"${args.componentPath}", _
|
|
176
|
+
swAddComponentConfigOptions_e.swAddComponentConfigOptions_CurrentSelectedConfig, _
|
|
177
|
+
"${args.configurationName || ''}", _
|
|
178
|
+
False, "", _
|
|
179
|
+
${args.position?.x || 0} / 1000, _
|
|
180
|
+
${args.position?.y || 0} / 1000, _
|
|
181
|
+
${args.position?.z || 0} / 1000)
|
|
182
|
+
|
|
183
|
+
If Not swComp Is Nothing Then
|
|
184
|
+
MsgBox "Component inserted: " & swComp.Name2
|
|
185
|
+
swAssy.EditRebuild3
|
|
186
|
+
Else
|
|
187
|
+
MsgBox "Failed to insert component"
|
|
188
|
+
End If
|
|
168
189
|
End Sub`,
|
|
169
|
-
replace: `
|
|
170
|
-
Sub ReplaceComponent()
|
|
171
|
-
Dim swApp As SldWorks.SldWorks
|
|
172
|
-
Dim swAssy As SldWorks.AssemblyDoc
|
|
173
|
-
Dim swComp As SldWorks.Component2
|
|
174
|
-
Dim bRet As Boolean
|
|
175
|
-
|
|
176
|
-
Set swApp = Application.SldWorks
|
|
177
|
-
Set swAssy = swApp.ActiveDoc
|
|
178
|
-
|
|
179
|
-
If swAssy Is Nothing Then Exit Sub
|
|
180
|
-
|
|
181
|
-
' Select component to replace
|
|
182
|
-
swAssy.Extension.SelectByID2 "${args.componentName}", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0
|
|
183
|
-
Set swComp = swAssy.SelectionManager.GetSelectedObject6(1, -1)
|
|
184
|
-
|
|
185
|
-
If Not swComp Is Nothing Then
|
|
186
|
-
' Replace component
|
|
187
|
-
bRet = swComp.Replace2("${args.componentPath}", "${args.configurationName || ''}", False, True)
|
|
188
|
-
|
|
189
|
-
If bRet Then
|
|
190
|
-
MsgBox "Component replaced successfully"
|
|
191
|
-
swAssy.EditRebuild3
|
|
192
|
-
Else
|
|
193
|
-
MsgBox "Failed to replace component"
|
|
194
|
-
End If
|
|
195
|
-
End If
|
|
190
|
+
replace: `
|
|
191
|
+
Sub ReplaceComponent()
|
|
192
|
+
Dim swApp As SldWorks.SldWorks
|
|
193
|
+
Dim swAssy As SldWorks.AssemblyDoc
|
|
194
|
+
Dim swComp As SldWorks.Component2
|
|
195
|
+
Dim bRet As Boolean
|
|
196
|
+
|
|
197
|
+
Set swApp = Application.SldWorks
|
|
198
|
+
Set swAssy = swApp.ActiveDoc
|
|
199
|
+
|
|
200
|
+
If swAssy Is Nothing Then Exit Sub
|
|
201
|
+
|
|
202
|
+
' Select component to replace
|
|
203
|
+
swAssy.Extension.SelectByID2 "${args.componentName}", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0
|
|
204
|
+
Set swComp = swAssy.SelectionManager.GetSelectedObject6(1, -1)
|
|
205
|
+
|
|
206
|
+
If Not swComp Is Nothing Then
|
|
207
|
+
' Replace component
|
|
208
|
+
bRet = swComp.Replace2("${args.componentPath}", "${args.configurationName || ''}", False, True)
|
|
209
|
+
|
|
210
|
+
If bRet Then
|
|
211
|
+
MsgBox "Component replaced successfully"
|
|
212
|
+
swAssy.EditRebuild3
|
|
213
|
+
Else
|
|
214
|
+
MsgBox "Failed to replace component"
|
|
215
|
+
End If
|
|
216
|
+
End If
|
|
196
217
|
End Sub`,
|
|
197
|
-
pattern: `
|
|
198
|
-
Sub CreateComponentPattern()
|
|
199
|
-
Dim swApp As SldWorks.SldWorks
|
|
200
|
-
Dim swAssy As SldWorks.AssemblyDoc
|
|
201
|
-
Dim swFeat As SldWorks.Feature
|
|
202
|
-
Dim swLocalPattern As SldWorks.LocalLinearPatternFeatureData
|
|
203
|
-
|
|
204
|
-
Set swApp = Application.SldWorks
|
|
205
|
-
Set swAssy = swApp.ActiveDoc
|
|
206
|
-
|
|
207
|
-
If swAssy Is Nothing Then Exit Sub
|
|
208
|
-
|
|
209
|
-
' Select component(s) to pattern
|
|
210
|
-
swAssy.Extension.SelectByID2 "${args.componentName}", "COMPONENT", 0, 0, 0, False, 1, Nothing, 0
|
|
211
|
-
|
|
212
|
-
${args.patternType === 'linear'
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
False, False, False, False,
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
'
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
218
|
+
pattern: `
|
|
219
|
+
Sub CreateComponentPattern()
|
|
220
|
+
Dim swApp As SldWorks.SldWorks
|
|
221
|
+
Dim swAssy As SldWorks.AssemblyDoc
|
|
222
|
+
Dim swFeat As SldWorks.Feature
|
|
223
|
+
Dim swLocalPattern As SldWorks.LocalLinearPatternFeatureData
|
|
224
|
+
|
|
225
|
+
Set swApp = Application.SldWorks
|
|
226
|
+
Set swAssy = swApp.ActiveDoc
|
|
227
|
+
|
|
228
|
+
If swAssy Is Nothing Then Exit Sub
|
|
229
|
+
|
|
230
|
+
' Select component(s) to pattern
|
|
231
|
+
swAssy.Extension.SelectByID2 "${args.componentName}", "COMPONENT", 0, 0, 0, False, 1, Nothing, 0
|
|
232
|
+
|
|
233
|
+
${args.patternType === 'linear'
|
|
234
|
+
? `
|
|
235
|
+
' Select direction references
|
|
236
|
+
swAssy.Extension.SelectByID2 "Right Plane", "PLANE", 0, 0, 0, True, 2, Nothing, 0
|
|
237
|
+
|
|
238
|
+
' Create linear pattern
|
|
239
|
+
Set swFeat = swAssy.FeatureManager.FeatureLinearPattern4( _
|
|
240
|
+
${args.quantity || 3}, ${(args.spacing || 50) / 1000}, _
|
|
241
|
+
1, 0, False, False, "NULL", "NULL", _
|
|
242
|
+
False, False, False, False, False, False, _
|
|
243
|
+
False, False, False, False, 0, 0)`
|
|
244
|
+
: ''}
|
|
245
|
+
|
|
246
|
+
${args.patternType === 'circular'
|
|
247
|
+
? `
|
|
248
|
+
' Select axis
|
|
249
|
+
swAssy.Extension.SelectByID2 "Axis1", "AXIS", 0, 0, 0, True, 2, Nothing, 0
|
|
250
|
+
|
|
251
|
+
' Create circular pattern
|
|
252
|
+
Set swFeat = swAssy.FeatureManager.FeatureCircularPattern5( _
|
|
253
|
+
${args.quantity || 6}, ${(2 * Math.PI) / (args.quantity || 6)}, _
|
|
254
|
+
False, "NULL", False, True, False, False)`
|
|
255
|
+
: ''}
|
|
256
|
+
|
|
257
|
+
If Not swFeat Is Nothing Then
|
|
258
|
+
MsgBox "Component pattern created: " & swFeat.Name
|
|
259
|
+
swAssy.EditRebuild3
|
|
260
|
+
End If
|
|
261
|
+
End Sub`,
|
|
262
|
+
explode: `
|
|
263
|
+
Sub CreateExplodedView()
|
|
264
|
+
Dim swApp As SldWorks.SldWorks
|
|
265
|
+
Dim swAssy As SldWorks.AssemblyDoc
|
|
266
|
+
Dim swConfig As SldWorks.Configuration
|
|
267
|
+
Dim swExplodeView As SldWorks.ExplodedView
|
|
268
|
+
|
|
269
|
+
Set swApp = Application.SldWorks
|
|
270
|
+
Set swAssy = swApp.ActiveDoc
|
|
271
|
+
|
|
272
|
+
If swAssy Is Nothing Then Exit Sub
|
|
273
|
+
|
|
274
|
+
Set swConfig = swAssy.GetActiveConfiguration
|
|
275
|
+
|
|
276
|
+
' Create new exploded view
|
|
277
|
+
Set swExplodeView = swConfig.CreateExplodedView2("ExplodedView_${Date.now()}")
|
|
278
|
+
|
|
279
|
+
If Not swExplodeView Is Nothing Then
|
|
280
|
+
' Select components to explode
|
|
281
|
+
swAssy.Extension.SelectByID2 "${args.componentName}", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0
|
|
282
|
+
|
|
283
|
+
' Add explode step
|
|
284
|
+
swExplodeView.AddExplodeStep _
|
|
285
|
+
${(args.position?.x || 100) / 1000}, _
|
|
286
|
+
${(args.position?.y || 0) / 1000}, _
|
|
287
|
+
${(args.position?.z || 0) / 1000}
|
|
288
|
+
|
|
289
|
+
MsgBox "Exploded view created"
|
|
290
|
+
swAssy.ShowExploded2 True
|
|
291
|
+
End If
|
|
236
292
|
End Sub`,
|
|
237
|
-
explode: `
|
|
238
|
-
Sub CreateExplodedView()
|
|
239
|
-
Dim swApp As SldWorks.SldWorks
|
|
240
|
-
Dim swAssy As SldWorks.AssemblyDoc
|
|
241
|
-
Dim swConfig As SldWorks.Configuration
|
|
242
|
-
Dim swExplodeView As SldWorks.ExplodedView
|
|
243
|
-
|
|
244
|
-
Set swApp = Application.SldWorks
|
|
245
|
-
Set swAssy = swApp.ActiveDoc
|
|
246
|
-
|
|
247
|
-
If swAssy Is Nothing Then Exit Sub
|
|
248
|
-
|
|
249
|
-
Set swConfig = swAssy.GetActiveConfiguration
|
|
250
|
-
|
|
251
|
-
' Create new exploded view
|
|
252
|
-
Set swExplodeView = swConfig.CreateExplodedView2("ExplodedView_${Date.now()}")
|
|
253
|
-
|
|
254
|
-
If Not swExplodeView Is Nothing Then
|
|
255
|
-
' Select components to explode
|
|
256
|
-
swAssy.Extension.SelectByID2 "${args.componentName}", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0
|
|
257
|
-
|
|
258
|
-
' Add explode step
|
|
259
|
-
swExplodeView.AddExplodeStep _
|
|
260
|
-
${(args.position?.x || 100) / 1000}, _
|
|
261
|
-
${(args.position?.y || 0) / 1000}, _
|
|
262
|
-
${(args.position?.z || 0) / 1000}
|
|
263
|
-
|
|
264
|
-
MsgBox "Exploded view created"
|
|
265
|
-
swAssy.ShowExploded2 True
|
|
266
|
-
End If
|
|
267
|
-
End Sub`
|
|
268
293
|
};
|
|
269
294
|
return operations[args.operation] || 'Operation not supported';
|
|
270
|
-
}
|
|
295
|
+
},
|
|
271
296
|
},
|
|
272
297
|
{
|
|
273
298
|
name: 'vba_assembly_analysis',
|
|
274
299
|
description: 'Generate VBA for assembly analysis',
|
|
275
300
|
inputSchema: z.object({
|
|
276
301
|
analysisType: z.enum([
|
|
277
|
-
'interference',
|
|
278
|
-
'
|
|
302
|
+
'interference',
|
|
303
|
+
'clearance',
|
|
304
|
+
'collision',
|
|
305
|
+
'mass_properties',
|
|
306
|
+
'hole_alignment',
|
|
307
|
+
'assembly_statistics',
|
|
308
|
+
'bom_export',
|
|
279
309
|
]),
|
|
280
310
|
components: z.array(z.string()).optional().describe('Components to analyze'),
|
|
281
311
|
outputPath: z.string().optional().describe('Path for results export'),
|
|
282
312
|
includeSubassemblies: z.boolean().optional().default(true),
|
|
283
|
-
treatCoincidentAsInterference: z.boolean().optional().default(false)
|
|
313
|
+
treatCoincidentAsInterference: z.boolean().optional().default(false),
|
|
284
314
|
}),
|
|
285
315
|
handler: (args) => {
|
|
286
316
|
const analyses = {
|
|
287
|
-
interference: `
|
|
288
|
-
Sub CheckInterference()
|
|
289
|
-
Dim swApp As SldWorks.SldWorks
|
|
290
|
-
Dim swAssy As SldWorks.AssemblyDoc
|
|
291
|
-
Dim swIntMgr As SldWorks.InterferenceDetectionMgr
|
|
292
|
-
Dim vInts As Variant
|
|
293
|
-
Dim i As Integer
|
|
294
|
-
Dim swInt As SldWorks.Interference
|
|
295
|
-
Dim vol As Double
|
|
296
|
-
|
|
297
|
-
Set swApp = Application.SldWorks
|
|
298
|
-
Set swAssy = swApp.ActiveDoc
|
|
299
|
-
|
|
300
|
-
If swAssy Is Nothing Then
|
|
301
|
-
MsgBox "Please open an assembly"
|
|
302
|
-
Exit Sub
|
|
303
|
-
End If
|
|
304
|
-
|
|
305
|
-
Set swIntMgr = swAssy.InterferenceDetectionManager
|
|
306
|
-
|
|
307
|
-
' Configure interference detection
|
|
308
|
-
swIntMgr.TreatCoincidenceAsInterference = ${args.treatCoincidentAsInterference ? 'True' : 'False'}
|
|
309
|
-
swIntMgr.TreatSubAssembliesAsComponents = ${args.includeSubassemblies ? 'False' : 'True'}
|
|
310
|
-
swIntMgr.IncludeMultibodyPartInterferences = True
|
|
311
|
-
swIntMgr.MakeInterferingPartsTransparent = True
|
|
312
|
-
|
|
313
|
-
${args.components && args.components.length > 0
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
file
|
|
344
|
-
|
|
345
|
-
file.
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
317
|
+
interference: `
|
|
318
|
+
Sub CheckInterference()
|
|
319
|
+
Dim swApp As SldWorks.SldWorks
|
|
320
|
+
Dim swAssy As SldWorks.AssemblyDoc
|
|
321
|
+
Dim swIntMgr As SldWorks.InterferenceDetectionMgr
|
|
322
|
+
Dim vInts As Variant
|
|
323
|
+
Dim i As Integer
|
|
324
|
+
Dim swInt As SldWorks.Interference
|
|
325
|
+
Dim vol As Double
|
|
326
|
+
|
|
327
|
+
Set swApp = Application.SldWorks
|
|
328
|
+
Set swAssy = swApp.ActiveDoc
|
|
329
|
+
|
|
330
|
+
If swAssy Is Nothing Then
|
|
331
|
+
MsgBox "Please open an assembly"
|
|
332
|
+
Exit Sub
|
|
333
|
+
End If
|
|
334
|
+
|
|
335
|
+
Set swIntMgr = swAssy.InterferenceDetectionManager
|
|
336
|
+
|
|
337
|
+
' Configure interference detection
|
|
338
|
+
swIntMgr.TreatCoincidenceAsInterference = ${args.treatCoincidentAsInterference ? 'True' : 'False'}
|
|
339
|
+
swIntMgr.TreatSubAssembliesAsComponents = ${args.includeSubassemblies ? 'False' : 'True'}
|
|
340
|
+
swIntMgr.IncludeMultibodyPartInterferences = True
|
|
341
|
+
swIntMgr.MakeInterferingPartsTransparent = True
|
|
342
|
+
|
|
343
|
+
${args.components && args.components.length > 0
|
|
344
|
+
? `
|
|
345
|
+
' Select specific components
|
|
346
|
+
${args.components
|
|
347
|
+
.map((comp) => `
|
|
348
|
+
swAssy.Extension.SelectByID2 "${comp}", "COMPONENT", 0, 0, 0, True, 0, Nothing, 0`)
|
|
349
|
+
.join('')}`
|
|
350
|
+
: ''}
|
|
351
|
+
|
|
352
|
+
' Run interference detection
|
|
353
|
+
vInts = swIntMgr.GetInterferences
|
|
354
|
+
swIntMgr.Done
|
|
355
|
+
|
|
356
|
+
If Not IsEmpty(vInts) Then
|
|
357
|
+
MsgBox "Found " & UBound(vInts) + 1 & " interference(s)"
|
|
358
|
+
|
|
359
|
+
' Process each interference
|
|
360
|
+
For i = 0 To UBound(vInts)
|
|
361
|
+
Set swInt = vInts(i)
|
|
362
|
+
vol = swInt.Volume * 1000000000 ' Convert to mm³
|
|
363
|
+
|
|
364
|
+
Debug.Print "Interference " & i + 1 & ":"
|
|
365
|
+
Debug.Print " Component 1: " & swInt.Component1.Name2
|
|
366
|
+
Debug.Print " Component 2: " & swInt.Component2.Name2
|
|
367
|
+
Debug.Print " Volume: " & Format(vol, "0.00") & " mm³"
|
|
368
|
+
Next i
|
|
369
|
+
|
|
370
|
+
${args.outputPath
|
|
371
|
+
? `
|
|
372
|
+
' Export results
|
|
373
|
+
Dim fso As Object, file As Object
|
|
374
|
+
Set fso = CreateObject("Scripting.FileSystemObject")
|
|
375
|
+
Set file = fso.CreateTextFile("${args.outputPath}", True)
|
|
376
|
+
|
|
377
|
+
file.WriteLine "Interference Detection Report"
|
|
378
|
+
file.WriteLine "============================="
|
|
379
|
+
file.WriteLine "Total Interferences: " & UBound(vInts) + 1
|
|
380
|
+
file.WriteLine ""
|
|
381
|
+
|
|
382
|
+
For i = 0 To UBound(vInts)
|
|
383
|
+
Set swInt = vInts(i)
|
|
384
|
+
file.WriteLine "Interference " & i + 1 & ":"
|
|
385
|
+
file.WriteLine " Component 1: " & swInt.Component1.Name2
|
|
386
|
+
file.WriteLine " Component 2: " & swInt.Component2.Name2
|
|
387
|
+
file.WriteLine " Volume: " & Format(swInt.Volume * 1000000000, "0.00") & " mm³"
|
|
388
|
+
file.WriteLine ""
|
|
389
|
+
Next i
|
|
390
|
+
|
|
391
|
+
file.Close
|
|
392
|
+
MsgBox "Report exported to: " & "${args.outputPath}"`
|
|
393
|
+
: ''}
|
|
394
|
+
Else
|
|
395
|
+
MsgBox "No interferences found"
|
|
396
|
+
End If
|
|
397
|
+
End Sub`,
|
|
398
|
+
mass_properties: `
|
|
399
|
+
Sub CalculateMassProperties()
|
|
400
|
+
Dim swApp As SldWorks.SldWorks
|
|
401
|
+
Dim swAssy As SldWorks.AssemblyDoc
|
|
402
|
+
Dim swMass As SldWorks.MassProperty
|
|
403
|
+
Dim vCOG As Variant
|
|
404
|
+
Dim vMOI As Variant
|
|
405
|
+
Dim mass As Double
|
|
406
|
+
|
|
407
|
+
Set swApp = Application.SldWorks
|
|
408
|
+
Set swAssy = swApp.ActiveDoc
|
|
409
|
+
|
|
410
|
+
If swAssy Is Nothing Then Exit Sub
|
|
411
|
+
|
|
412
|
+
Set swMass = swAssy.Extension.CreateMassProperty
|
|
413
|
+
|
|
414
|
+
${args.components && args.components.length > 0
|
|
415
|
+
? `
|
|
416
|
+
' Select specific components
|
|
417
|
+
swAssy.ClearSelection2 True
|
|
418
|
+
${args.components
|
|
419
|
+
.map((comp) => `
|
|
420
|
+
swAssy.Extension.SelectByID2 "${comp}", "COMPONENT", 0, 0, 0, True, 0, Nothing, 0`)
|
|
421
|
+
.join('')}
|
|
422
|
+
|
|
423
|
+
' Calculate for selected components
|
|
424
|
+
swMass.UseSelectedOnly = True`
|
|
425
|
+
: ''}
|
|
426
|
+
|
|
427
|
+
mass = swMass.Mass * 1000 ' Convert to grams
|
|
428
|
+
vCOG = swMass.CenterOfMass
|
|
429
|
+
vMOI = swMass.GetMomentOfInertia(0) ' At COG
|
|
430
|
+
|
|
431
|
+
' Display results
|
|
432
|
+
MsgBox "Mass Properties:" & vbCrLf & _
|
|
433
|
+
"Mass: " & Format(mass, "0.00") & " g" & vbCrLf & _
|
|
434
|
+
"Volume: " & Format(swMass.Volume * 1000000000, "0.00") & " mm³" & vbCrLf & _
|
|
435
|
+
"Density: " & Format(swMass.Density, "0.00") & " kg/m³" & vbCrLf & _
|
|
436
|
+
"Surface Area: " & Format(swMass.SurfaceArea * 1000000, "0.00") & " mm²" & vbCrLf & vbCrLf & _
|
|
437
|
+
"Center of Gravity:" & vbCrLf & _
|
|
438
|
+
"X: " & Format(vCOG(0) * 1000, "0.00") & " mm" & vbCrLf & _
|
|
439
|
+
"Y: " & Format(vCOG(1) * 1000, "0.00") & " mm" & vbCrLf & _
|
|
440
|
+
"Z: " & Format(vCOG(2) * 1000, "0.00") & " mm"
|
|
441
|
+
|
|
442
|
+
${args.outputPath
|
|
443
|
+
? `
|
|
444
|
+
' Export to file
|
|
445
|
+
Dim fso As Object, file As Object
|
|
446
|
+
Set fso = CreateObject("Scripting.FileSystemObject")
|
|
447
|
+
Set file = fso.CreateTextFile("${args.outputPath}", True)
|
|
448
|
+
|
|
449
|
+
file.WriteLine "Mass Properties Report"
|
|
450
|
+
file.WriteLine "====================="
|
|
451
|
+
file.WriteLine "Mass: " & Format(mass, "0.00") & " g"
|
|
452
|
+
file.WriteLine "Volume: " & Format(swMass.Volume * 1000000000, "0.00") & " mm³"
|
|
453
|
+
file.WriteLine "Density: " & Format(swMass.Density, "0.00") & " kg/m³"
|
|
454
|
+
file.WriteLine "Surface Area: " & Format(swMass.SurfaceArea * 1000000, "0.00") & " mm²"
|
|
455
|
+
file.WriteLine ""
|
|
456
|
+
file.WriteLine "Center of Gravity:"
|
|
457
|
+
file.WriteLine " X: " & Format(vCOG(0) * 1000, "0.00") & " mm"
|
|
458
|
+
file.WriteLine " Y: " & Format(vCOG(1) * 1000, "0.00") & " mm"
|
|
459
|
+
file.WriteLine " Z: " & Format(vCOG(2) * 1000, "0.00") & " mm"
|
|
460
|
+
file.WriteLine ""
|
|
461
|
+
file.WriteLine "Moments of Inertia (at COG):"
|
|
462
|
+
file.WriteLine " Ixx: " & Format(vMOI(0), "0.0000") & " kg·m²"
|
|
463
|
+
file.WriteLine " Iyy: " & Format(vMOI(1), "0.0000") & " kg·m²"
|
|
464
|
+
file.WriteLine " Izz: " & Format(vMOI(2), "0.0000") & " kg·m²"
|
|
465
|
+
|
|
466
|
+
file.Close
|
|
467
|
+
MsgBox "Report saved to: " & "${args.outputPath}"`
|
|
468
|
+
: ''}
|
|
361
469
|
End Sub`,
|
|
362
|
-
|
|
363
|
-
Sub
|
|
364
|
-
Dim swApp As SldWorks.SldWorks
|
|
365
|
-
Dim swAssy As SldWorks.AssemblyDoc
|
|
366
|
-
Dim
|
|
367
|
-
Dim
|
|
368
|
-
Dim
|
|
369
|
-
Dim
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
Set
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
MsgBox "Report saved to: " & "${args.outputPath}"` : ''}
|
|
470
|
+
bom_export: `
|
|
471
|
+
Sub ExportBOM()
|
|
472
|
+
Dim swApp As SldWorks.SldWorks
|
|
473
|
+
Dim swAssy As SldWorks.AssemblyDoc
|
|
474
|
+
Dim swBOMAnnotation As SldWorks.BomTableAnnotation
|
|
475
|
+
Dim swBOMFeature As SldWorks.BomFeature
|
|
476
|
+
Dim swTable As SldWorks.TableAnnotation
|
|
477
|
+
Dim i As Integer, j As Integer
|
|
478
|
+
Dim rowCount As Long, colCount As Long
|
|
479
|
+
|
|
480
|
+
Set swApp = Application.SldWorks
|
|
481
|
+
Set swAssy = swApp.ActiveDoc
|
|
482
|
+
|
|
483
|
+
If swAssy Is Nothing Then Exit Sub
|
|
484
|
+
|
|
485
|
+
' Create BOM
|
|
486
|
+
Set swBOMFeature = swAssy.FeatureManager.InsertBomTable3( _
|
|
487
|
+
"", "${args.outputPath || 'C:\\Temp\\BOM.xlsx'}", _
|
|
488
|
+
swBomType_e.swBomType_PartsOnly, _
|
|
489
|
+
"", _
|
|
490
|
+
swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_ActiveConfiguration, _
|
|
491
|
+
swBomStandard_e.swBomStandard_BomTable, _
|
|
492
|
+
False)
|
|
493
|
+
|
|
494
|
+
If Not swBOMFeature Is Nothing Then
|
|
495
|
+
Set swBOMAnnotation = swBOMFeature.GetTableAnnotations(0)
|
|
496
|
+
Set swTable = swBOMAnnotation
|
|
497
|
+
|
|
498
|
+
rowCount = swTable.RowCount
|
|
499
|
+
colCount = swTable.ColumnCount
|
|
500
|
+
|
|
501
|
+
' Export to Excel
|
|
502
|
+
Dim xlApp As Object
|
|
503
|
+
Dim xlBook As Object
|
|
504
|
+
Dim xlSheet As Object
|
|
505
|
+
|
|
506
|
+
Set xlApp = CreateObject("Excel.Application")
|
|
507
|
+
Set xlBook = xlApp.Workbooks.Add
|
|
508
|
+
Set xlSheet = xlBook.Sheets(1)
|
|
509
|
+
|
|
510
|
+
xlApp.Visible = True
|
|
511
|
+
|
|
512
|
+
' Write headers
|
|
513
|
+
For j = 0 To colCount - 1
|
|
514
|
+
xlSheet.Cells(1, j + 1).Value = swTable.GetColumnTitle(j)
|
|
515
|
+
Next j
|
|
516
|
+
|
|
517
|
+
' Write data
|
|
518
|
+
For i = 1 To rowCount - 1
|
|
519
|
+
For j = 0 To colCount - 1
|
|
520
|
+
xlSheet.Cells(i + 1, j + 1).Value = swTable.Text(i, j)
|
|
521
|
+
Next j
|
|
522
|
+
Next i
|
|
523
|
+
|
|
524
|
+
' Format
|
|
525
|
+
xlSheet.Range("A1").CurrentRegion.Columns.AutoFit
|
|
526
|
+
xlSheet.Range("A1").CurrentRegion.Borders.LineStyle = 1
|
|
527
|
+
|
|
528
|
+
${args.outputPath
|
|
529
|
+
? `
|
|
530
|
+
xlBook.SaveAs "${args.outputPath}"
|
|
531
|
+
MsgBox "BOM exported to: ${args.outputPath}"`
|
|
532
|
+
: ''}
|
|
533
|
+
End If
|
|
427
534
|
End Sub`,
|
|
428
|
-
bom_export: `
|
|
429
|
-
Sub ExportBOM()
|
|
430
|
-
Dim swApp As SldWorks.SldWorks
|
|
431
|
-
Dim swAssy As SldWorks.AssemblyDoc
|
|
432
|
-
Dim swBOMAnnotation As SldWorks.BomTableAnnotation
|
|
433
|
-
Dim swBOMFeature As SldWorks.BomFeature
|
|
434
|
-
Dim swTable As SldWorks.TableAnnotation
|
|
435
|
-
Dim i As Integer, j As Integer
|
|
436
|
-
Dim rowCount As Long, colCount As Long
|
|
437
|
-
|
|
438
|
-
Set swApp = Application.SldWorks
|
|
439
|
-
Set swAssy = swApp.ActiveDoc
|
|
440
|
-
|
|
441
|
-
If swAssy Is Nothing Then Exit Sub
|
|
442
|
-
|
|
443
|
-
' Create BOM
|
|
444
|
-
Set swBOMFeature = swAssy.FeatureManager.InsertBomTable3( _
|
|
445
|
-
"", "${args.outputPath || 'C:\\Temp\\BOM.xlsx'}", _
|
|
446
|
-
swBomType_e.swBomType_PartsOnly, _
|
|
447
|
-
"", _
|
|
448
|
-
swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_ActiveConfiguration, _
|
|
449
|
-
swBomStandard_e.swBomStandard_BomTable, _
|
|
450
|
-
False)
|
|
451
|
-
|
|
452
|
-
If Not swBOMFeature Is Nothing Then
|
|
453
|
-
Set swBOMAnnotation = swBOMFeature.GetTableAnnotations(0)
|
|
454
|
-
Set swTable = swBOMAnnotation
|
|
455
|
-
|
|
456
|
-
rowCount = swTable.RowCount
|
|
457
|
-
colCount = swTable.ColumnCount
|
|
458
|
-
|
|
459
|
-
' Export to Excel
|
|
460
|
-
Dim xlApp As Object
|
|
461
|
-
Dim xlBook As Object
|
|
462
|
-
Dim xlSheet As Object
|
|
463
|
-
|
|
464
|
-
Set xlApp = CreateObject("Excel.Application")
|
|
465
|
-
Set xlBook = xlApp.Workbooks.Add
|
|
466
|
-
Set xlSheet = xlBook.Sheets(1)
|
|
467
|
-
|
|
468
|
-
xlApp.Visible = True
|
|
469
|
-
|
|
470
|
-
' Write headers
|
|
471
|
-
For j = 0 To colCount - 1
|
|
472
|
-
xlSheet.Cells(1, j + 1).Value = swTable.GetColumnTitle(j)
|
|
473
|
-
Next j
|
|
474
|
-
|
|
475
|
-
' Write data
|
|
476
|
-
For i = 1 To rowCount - 1
|
|
477
|
-
For j = 0 To colCount - 1
|
|
478
|
-
xlSheet.Cells(i + 1, j + 1).Value = swTable.Text(i, j)
|
|
479
|
-
Next j
|
|
480
|
-
Next i
|
|
481
|
-
|
|
482
|
-
' Format
|
|
483
|
-
xlSheet.Range("A1").CurrentRegion.Columns.AutoFit
|
|
484
|
-
xlSheet.Range("A1").CurrentRegion.Borders.LineStyle = 1
|
|
485
|
-
|
|
486
|
-
${args.outputPath ? `
|
|
487
|
-
xlBook.SaveAs "${args.outputPath}"
|
|
488
|
-
MsgBox "BOM exported to: ${args.outputPath}"` : ''}
|
|
489
|
-
End If
|
|
490
|
-
End Sub`
|
|
491
535
|
};
|
|
492
536
|
return analyses[args.analysisType] || 'Analysis type not supported';
|
|
493
|
-
}
|
|
537
|
+
},
|
|
494
538
|
},
|
|
495
539
|
{
|
|
496
540
|
name: 'vba_assembly_configurations',
|
|
@@ -501,88 +545,106 @@ End Sub`
|
|
|
501
545
|
parentConfig: z.string().optional(),
|
|
502
546
|
componentsToSuppress: z.array(z.string()).optional(),
|
|
503
547
|
properties: z.record(z.string()).optional(),
|
|
504
|
-
displayStates: z.array(z.string()).optional()
|
|
548
|
+
displayStates: z.array(z.string()).optional(),
|
|
505
549
|
}),
|
|
506
550
|
handler: (args) => {
|
|
507
|
-
return `
|
|
508
|
-
Sub ManageConfiguration_${args.operation}()
|
|
509
|
-
Dim swApp As SldWorks.SldWorks
|
|
510
|
-
Dim swAssy As SldWorks.AssemblyDoc
|
|
511
|
-
Dim swConfig As SldWorks.Configuration
|
|
512
|
-
Dim swConfigMgr As SldWorks.ConfigurationManager
|
|
513
|
-
Dim bRet As Boolean
|
|
514
|
-
|
|
515
|
-
Set swApp = Application.SldWorks
|
|
516
|
-
Set swAssy = swApp.ActiveDoc
|
|
517
|
-
|
|
518
|
-
If swAssy Is Nothing Then
|
|
519
|
-
MsgBox "Please open an assembly"
|
|
520
|
-
Exit Sub
|
|
521
|
-
End If
|
|
522
|
-
|
|
523
|
-
Set swConfigMgr = swAssy.ConfigurationManager
|
|
524
|
-
|
|
525
|
-
${args.operation === 'create'
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
"
|
|
530
|
-
"", _
|
|
531
|
-
|
|
532
|
-
swConfigurationOptions2_e.
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
${
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
551
|
+
return `
|
|
552
|
+
Sub ManageConfiguration_${args.operation}()
|
|
553
|
+
Dim swApp As SldWorks.SldWorks
|
|
554
|
+
Dim swAssy As SldWorks.AssemblyDoc
|
|
555
|
+
Dim swConfig As SldWorks.Configuration
|
|
556
|
+
Dim swConfigMgr As SldWorks.ConfigurationManager
|
|
557
|
+
Dim bRet As Boolean
|
|
558
|
+
|
|
559
|
+
Set swApp = Application.SldWorks
|
|
560
|
+
Set swAssy = swApp.ActiveDoc
|
|
561
|
+
|
|
562
|
+
If swAssy Is Nothing Then
|
|
563
|
+
MsgBox "Please open an assembly"
|
|
564
|
+
Exit Sub
|
|
565
|
+
End If
|
|
566
|
+
|
|
567
|
+
Set swConfigMgr = swAssy.ConfigurationManager
|
|
568
|
+
|
|
569
|
+
${args.operation === 'create'
|
|
570
|
+
? `
|
|
571
|
+
' Create new configuration
|
|
572
|
+
Set swConfig = swAssy.AddConfiguration3( _
|
|
573
|
+
"${args.configName}", _
|
|
574
|
+
"Configuration created by VBA", _
|
|
575
|
+
"", _
|
|
576
|
+
swConfigurationOptions2_e.swConfigOption_LinkToParent + _
|
|
577
|
+
swConfigurationOptions2_e.swConfigOption_InheritProperties, _
|
|
578
|
+
"${args.parentConfig || ''}")
|
|
579
|
+
|
|
580
|
+
If Not swConfig Is Nothing Then
|
|
581
|
+
' Activate new configuration
|
|
582
|
+
swAssy.ShowConfiguration2 "${args.configName}"
|
|
583
|
+
|
|
584
|
+
${args.componentsToSuppress && args.componentsToSuppress.length > 0
|
|
585
|
+
? `
|
|
586
|
+
' Suppress components
|
|
587
|
+
${args.componentsToSuppress
|
|
588
|
+
.map((comp) => `
|
|
589
|
+
swAssy.Extension.SelectByID2 "${comp}", "COMPONENT", 0, 0, 0, True, 0, Nothing, 0`)
|
|
590
|
+
.join('')}
|
|
591
|
+
swAssy.EditSuppress2`
|
|
592
|
+
: ''}
|
|
593
|
+
|
|
594
|
+
${args.properties
|
|
595
|
+
? `
|
|
596
|
+
' Set custom properties
|
|
597
|
+
${Object.entries(args.properties || {})
|
|
598
|
+
.map(([key, value]) => `
|
|
599
|
+
swConfig.CustomPropertyManager.Add3 "${key}", swCustomInfoType_e.swCustomInfoText, "${value}", _
|
|
600
|
+
swCustomPropertyAddOption_e.swCustomPropertyReplaceValue`)
|
|
601
|
+
.join('')}`
|
|
602
|
+
: ''}
|
|
603
|
+
|
|
604
|
+
MsgBox "Configuration '${args.configName}' created"
|
|
605
|
+
End If`
|
|
606
|
+
: ''}
|
|
607
|
+
|
|
608
|
+
${args.operation === 'modify'
|
|
609
|
+
? `
|
|
610
|
+
' Get configuration
|
|
611
|
+
Set swConfig = swAssy.GetConfigurationByName("${args.configName}")
|
|
612
|
+
|
|
613
|
+
If Not swConfig Is Nothing Then
|
|
614
|
+
' Activate configuration
|
|
615
|
+
swAssy.ShowConfiguration2 "${args.configName}"
|
|
616
|
+
|
|
617
|
+
${args.componentsToSuppress && args.componentsToSuppress.length > 0
|
|
618
|
+
? `
|
|
619
|
+
' Modify suppression state
|
|
620
|
+
${args.componentsToSuppress
|
|
621
|
+
.map((comp) => `
|
|
622
|
+
swAssy.Extension.SelectByID2 "${comp}", "COMPONENT", 0, 0, 0, True, 0, Nothing, 0`)
|
|
623
|
+
.join('')}
|
|
624
|
+
swAssy.EditSuppress2`
|
|
625
|
+
: ''}
|
|
626
|
+
|
|
627
|
+
MsgBox "Configuration '${args.configName}' modified"
|
|
628
|
+
Else
|
|
629
|
+
MsgBox "Configuration not found"
|
|
630
|
+
End If`
|
|
631
|
+
: ''}
|
|
632
|
+
|
|
633
|
+
${args.operation === 'delete'
|
|
634
|
+
? `
|
|
635
|
+
' Delete configuration
|
|
636
|
+
bRet = swAssy.DeleteConfiguration2("${args.configName}")
|
|
637
|
+
|
|
638
|
+
If bRet Then
|
|
639
|
+
MsgBox "Configuration '${args.configName}' deleted"
|
|
640
|
+
Else
|
|
641
|
+
MsgBox "Failed to delete configuration"
|
|
642
|
+
End If`
|
|
643
|
+
: ''}
|
|
644
|
+
|
|
645
|
+
swAssy.EditRebuild3
|
|
584
646
|
End Sub`;
|
|
585
|
-
}
|
|
586
|
-
}
|
|
647
|
+
},
|
|
648
|
+
},
|
|
587
649
|
];
|
|
588
650
|
//# sourceMappingURL=vba-assembly.js.map
|