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.
Files changed (243) hide show
  1. package/CHANGELOG.md +175 -98
  2. package/LICENSE +20 -20
  3. package/README.md +195 -423
  4. package/dist/adapters/circuit-breaker.d.ts +84 -0
  5. package/dist/adapters/circuit-breaker.d.ts.map +1 -0
  6. package/dist/adapters/circuit-breaker.js +228 -0
  7. package/dist/adapters/circuit-breaker.js.map +1 -0
  8. package/dist/adapters/connection-pool.d.ts +83 -0
  9. package/dist/adapters/connection-pool.d.ts.map +1 -0
  10. package/dist/adapters/connection-pool.js +282 -0
  11. package/dist/adapters/connection-pool.js.map +1 -0
  12. package/dist/adapters/edge-adapter.d.ts +43 -0
  13. package/dist/adapters/edge-adapter.d.ts.map +1 -0
  14. package/dist/adapters/edge-adapter.js +417 -0
  15. package/dist/adapters/edge-adapter.js.map +1 -0
  16. package/dist/adapters/factory.d.ts +60 -0
  17. package/dist/adapters/factory.d.ts.map +1 -0
  18. package/dist/adapters/factory.js +212 -0
  19. package/dist/adapters/factory.js.map +1 -0
  20. package/dist/adapters/feature-complexity-analyzer.d.ts +102 -0
  21. package/dist/adapters/feature-complexity-analyzer.d.ts.map +1 -0
  22. package/dist/adapters/feature-complexity-analyzer.js +322 -0
  23. package/dist/adapters/feature-complexity-analyzer.js.map +1 -0
  24. package/dist/adapters/macro-generator.d.ts +30 -0
  25. package/dist/adapters/macro-generator.d.ts.map +1 -0
  26. package/dist/adapters/macro-generator.js +524 -0
  27. package/dist/adapters/macro-generator.js.map +1 -0
  28. package/dist/adapters/mock-solidworks-adapter.d.ts +92 -0
  29. package/dist/adapters/mock-solidworks-adapter.d.ts.map +1 -0
  30. package/dist/adapters/mock-solidworks-adapter.js +367 -0
  31. package/dist/adapters/mock-solidworks-adapter.js.map +1 -0
  32. package/dist/adapters/types.d.ts +376 -0
  33. package/dist/adapters/types.d.ts.map +1 -0
  34. package/dist/adapters/types.js +261 -0
  35. package/dist/adapters/types.js.map +1 -0
  36. package/dist/adapters/winax-adapter-enhanced.d.ts +55 -0
  37. package/dist/adapters/winax-adapter-enhanced.d.ts.map +1 -0
  38. package/dist/adapters/winax-adapter-enhanced.js +601 -0
  39. package/dist/adapters/winax-adapter-enhanced.js.map +1 -0
  40. package/dist/adapters/winax-adapter.d.ts +55 -0
  41. package/dist/adapters/winax-adapter.d.ts.map +1 -0
  42. package/dist/adapters/winax-adapter.js +667 -0
  43. package/dist/adapters/winax-adapter.js.map +1 -0
  44. package/dist/api/stainless-api.d.ts +29 -0
  45. package/dist/api/stainless-api.d.ts.map +1 -0
  46. package/dist/api/stainless-api.js +408 -0
  47. package/dist/api/stainless-api.js.map +1 -0
  48. package/dist/cache/manager.d.ts.map +1 -1
  49. package/dist/cache/manager.js +4 -3
  50. package/dist/cache/manager.js.map +1 -1
  51. package/dist/core/interfaces/core-abstractions.d.ts.map +1 -1
  52. package/dist/core/interfaces/core-abstractions.js.map +1 -1
  53. package/dist/db/connection.js +4 -4
  54. package/dist/db/connection.js.map +1 -1
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +86 -79
  57. package/dist/index.js.map +1 -1
  58. package/dist/knowledge/chromadb.d.ts.map +1 -1
  59. package/dist/knowledge/chromadb.js +5 -3
  60. package/dist/knowledge/chromadb.js.map +1 -1
  61. package/dist/macro/recorder.d.ts +1 -1
  62. package/dist/macro/recorder.d.ts.map +1 -1
  63. package/dist/macro/recorder.js +10 -10
  64. package/dist/macro/recorder.js.map +1 -1
  65. package/dist/resources/base.js +10 -10
  66. package/dist/resources/base.js.map +1 -1
  67. package/dist/resources/design-table.d.ts +10 -12
  68. package/dist/resources/design-table.d.ts.map +1 -1
  69. package/dist/resources/design-table.js +42 -39
  70. package/dist/resources/design-table.js.map +1 -1
  71. package/dist/resources/pdm.d.ts +44 -45
  72. package/dist/resources/pdm.d.ts.map +1 -1
  73. package/dist/resources/pdm.js +118 -79
  74. package/dist/resources/pdm.js.map +1 -1
  75. package/dist/resources/registry.d.ts +1 -1
  76. package/dist/resources/registry.d.ts.map +1 -1
  77. package/dist/resources/registry.js +1 -1
  78. package/dist/shared/constants/solidworks-constants.d.ts.map +1 -1
  79. package/dist/shared/constants/solidworks-constants.js +9 -9
  80. package/dist/shared/constants/solidworks-constants.js.map +1 -1
  81. package/dist/solidworks/api.d.ts +8 -6
  82. package/dist/solidworks/api.d.ts.map +1 -1
  83. package/dist/solidworks/api.js +614 -188
  84. package/dist/solidworks/api.js.map +1 -1
  85. package/dist/state/store.d.ts +1 -1
  86. package/dist/state/store.d.ts.map +1 -1
  87. package/dist/state/store.js +14 -14
  88. package/dist/state/store.js.map +1 -1
  89. package/dist/tools/analysis.d.ts +12 -2
  90. package/dist/tools/analysis.d.ts.map +1 -1
  91. package/dist/tools/analysis.js +141 -31
  92. package/dist/tools/analysis.js.map +1 -1
  93. package/dist/tools/diagnostics.d.ts +1 -1
  94. package/dist/tools/diagnostics.d.ts.map +1 -1
  95. package/dist/tools/diagnostics.js +2 -2
  96. package/dist/tools/diagnostics.js.map +1 -1
  97. package/dist/tools/drawing.d.ts +2 -2
  98. package/dist/tools/drawing.d.ts.map +1 -1
  99. package/dist/tools/drawing.js +94 -10
  100. package/dist/tools/drawing.js.map +1 -1
  101. package/dist/tools/enhanced-drawing.d.ts +1 -1
  102. package/dist/tools/enhanced-drawing.d.ts.map +1 -1
  103. package/dist/tools/enhanced-drawing.js +10 -13
  104. package/dist/tools/enhanced-drawing.js.map +1 -1
  105. package/dist/tools/export.d.ts +1 -1
  106. package/dist/tools/export.d.ts.map +1 -1
  107. package/dist/tools/export.js +88 -14
  108. package/dist/tools/export.js.map +1 -1
  109. package/dist/tools/extrusion-helper.d.ts +15 -0
  110. package/dist/tools/extrusion-helper.d.ts.map +1 -0
  111. package/dist/tools/extrusion-helper.js +61 -0
  112. package/dist/tools/extrusion-helper.js.map +1 -0
  113. package/dist/tools/macro-security.d.ts +2 -2
  114. package/dist/tools/macro-security.d.ts.map +1 -1
  115. package/dist/tools/macro-security.js +2 -2
  116. package/dist/tools/macro-security.js.map +1 -1
  117. package/dist/tools/modeling.d.ts +2 -2
  118. package/dist/tools/modeling.d.ts.map +1 -1
  119. package/dist/tools/modeling.js +6 -6
  120. package/dist/tools/modeling.js.map +1 -1
  121. package/dist/tools/native-macro.d.ts +1 -1
  122. package/dist/tools/native-macro.d.ts.map +1 -1
  123. package/dist/tools/native-macro.js +246 -239
  124. package/dist/tools/native-macro.js.map +1 -1
  125. package/dist/tools/sketch.d.ts +28 -28
  126. package/dist/tools/sketch.d.ts.map +1 -1
  127. package/dist/tools/sketch.js +202 -136
  128. package/dist/tools/sketch.js.map +1 -1
  129. package/dist/tools/template-manager.d.ts +5 -5
  130. package/dist/tools/template-manager.d.ts.map +1 -1
  131. package/dist/tools/template-manager.js +66 -65
  132. package/dist/tools/template-manager.js.map +1 -1
  133. package/dist/tools/vba-advanced.d.ts +10 -10
  134. package/dist/tools/vba-advanced.d.ts.map +1 -1
  135. package/dist/tools/vba-advanced.js +791 -708
  136. package/dist/tools/vba-advanced.js.map +1 -1
  137. package/dist/tools/vba-assembly.d.ts +10 -10
  138. package/dist/tools/vba-assembly.d.ts.map +1 -1
  139. package/dist/tools/vba-assembly.js +562 -500
  140. package/dist/tools/vba-assembly.js.map +1 -1
  141. package/dist/tools/vba-drawing.d.ts +12 -12
  142. package/dist/tools/vba-drawing.d.ts.map +1 -1
  143. package/dist/tools/vba-drawing.js +681 -572
  144. package/dist/tools/vba-drawing.js.map +1 -1
  145. package/dist/tools/vba-file-management.d.ts +12 -12
  146. package/dist/tools/vba-file-management.d.ts.map +1 -1
  147. package/dist/tools/vba-file-management.js +662 -589
  148. package/dist/tools/vba-file-management.js.map +1 -1
  149. package/dist/tools/vba-part.d.ts +10 -10
  150. package/dist/tools/vba-part.d.ts.map +1 -1
  151. package/dist/tools/vba-part.js +484 -426
  152. package/dist/tools/vba-part.js.map +1 -1
  153. package/dist/tools/vba.d.ts +361 -361
  154. package/dist/tools/vba.d.ts.map +1 -1
  155. package/dist/tools/vba.js +67 -81
  156. package/dist/tools/vba.js.map +1 -1
  157. package/dist/utils/config.js +2 -2
  158. package/dist/utils/config.js.map +1 -1
  159. package/dist/utils/environment.d.ts +243 -0
  160. package/dist/utils/environment.d.ts.map +1 -0
  161. package/dist/utils/environment.js +207 -0
  162. package/dist/utils/environment.js.map +1 -0
  163. package/dist/utils/logger.d.ts.map +1 -1
  164. package/dist/utils/logger.js +6 -6
  165. package/dist/utils/logger.js.map +1 -1
  166. package/dist/utils/solidworks-config.d.ts +39 -0
  167. package/dist/utils/solidworks-config.d.ts.map +1 -0
  168. package/dist/utils/solidworks-config.js +156 -0
  169. package/dist/utils/solidworks-config.js.map +1 -0
  170. package/package.json +84 -84
  171. package/scripts/setup.js +70 -70
  172. package/dist/application/services/command-bus.d.ts +0 -39
  173. package/dist/application/services/command-bus.d.ts.map +0 -1
  174. package/dist/application/services/command-bus.js +0 -88
  175. package/dist/application/services/command-bus.js.map +0 -1
  176. package/dist/application/services/event-bus.d.ts +0 -31
  177. package/dist/application/services/event-bus.d.ts.map +0 -1
  178. package/dist/application/services/event-bus.js +0 -83
  179. package/dist/application/services/event-bus.js.map +0 -1
  180. package/dist/application/services/query-bus.d.ts +0 -30
  181. package/dist/application/services/query-bus.d.ts.map +0 -1
  182. package/dist/application/services/query-bus.js +0 -59
  183. package/dist/application/services/query-bus.js.map +0 -1
  184. package/dist/application/services/tool-registry.d.ts +0 -53
  185. package/dist/application/services/tool-registry.d.ts.map +0 -1
  186. package/dist/application/services/tool-registry.js +0 -81
  187. package/dist/application/services/tool-registry.js.map +0 -1
  188. package/dist/application/use-cases/analysis/index.d.ts +0 -13
  189. package/dist/application/use-cases/analysis/index.d.ts.map +0 -1
  190. package/dist/application/use-cases/analysis/index.js +0 -17
  191. package/dist/application/use-cases/analysis/index.js.map +0 -1
  192. package/dist/application/use-cases/drawing/index.d.ts +0 -13
  193. package/dist/application/use-cases/drawing/index.d.ts.map +0 -1
  194. package/dist/application/use-cases/drawing/index.js +0 -17
  195. package/dist/application/use-cases/drawing/index.js.map +0 -1
  196. package/dist/application/use-cases/export/index.d.ts +0 -13
  197. package/dist/application/use-cases/export/index.d.ts.map +0 -1
  198. package/dist/application/use-cases/export/index.js +0 -17
  199. package/dist/application/use-cases/export/index.js.map +0 -1
  200. package/dist/application/use-cases/macro/index.d.ts +0 -13
  201. package/dist/application/use-cases/macro/index.d.ts.map +0 -1
  202. package/dist/application/use-cases/macro/index.js +0 -17
  203. package/dist/application/use-cases/macro/index.js.map +0 -1
  204. package/dist/application/use-cases/modeling/index.d.ts +0 -56
  205. package/dist/application/use-cases/modeling/index.d.ts.map +0 -1
  206. package/dist/application/use-cases/modeling/index.js +0 -385
  207. package/dist/application/use-cases/modeling/index.js.map +0 -1
  208. package/dist/index.refactored.d.ts +0 -7
  209. package/dist/index.refactored.d.ts.map +0 -1
  210. package/dist/index.refactored.js +0 -254
  211. package/dist/index.refactored.js.map +0 -1
  212. package/dist/infrastructure/config/configuration-manager.d.ts +0 -381
  213. package/dist/infrastructure/config/configuration-manager.d.ts.map +0 -1
  214. package/dist/infrastructure/config/configuration-manager.js +0 -566
  215. package/dist/infrastructure/config/configuration-manager.js.map +0 -1
  216. package/dist/infrastructure/container/service-locator.d.ts +0 -14
  217. package/dist/infrastructure/container/service-locator.d.ts.map +0 -1
  218. package/dist/infrastructure/container/service-locator.js +0 -38
  219. package/dist/infrastructure/container/service-locator.js.map +0 -1
  220. package/dist/infrastructure/logging/logger.d.ts +0 -24
  221. package/dist/infrastructure/logging/logger.d.ts.map +0 -1
  222. package/dist/infrastructure/logging/logger.js +0 -65
  223. package/dist/infrastructure/logging/logger.js.map +0 -1
  224. package/dist/infrastructure/solidworks/solidworks-adapter.d.ts +0 -43
  225. package/dist/infrastructure/solidworks/solidworks-adapter.d.ts.map +0 -1
  226. package/dist/infrastructure/solidworks/solidworks-adapter.js +0 -527
  227. package/dist/infrastructure/solidworks/solidworks-adapter.js.map +0 -1
  228. package/dist/presentation/mcp/request-handler.d.ts +0 -41
  229. package/dist/presentation/mcp/request-handler.d.ts.map +0 -1
  230. package/dist/presentation/mcp/request-handler.js +0 -100
  231. package/dist/presentation/mcp/request-handler.js.map +0 -1
  232. package/dist/presentation/transformers/error-transformer.d.ts +0 -16
  233. package/dist/presentation/transformers/error-transformer.d.ts.map +0 -1
  234. package/dist/presentation/transformers/error-transformer.js +0 -44
  235. package/dist/presentation/transformers/error-transformer.js.map +0 -1
  236. package/dist/presentation/transformers/response-transformer.d.ts +0 -24
  237. package/dist/presentation/transformers/response-transformer.d.ts.map +0 -1
  238. package/dist/presentation/transformers/response-transformer.js +0 -102
  239. package/dist/presentation/transformers/response-transformer.js.map +0 -1
  240. package/dist/tools/drawing-analysis.d.ts +0 -9
  241. package/dist/tools/drawing-analysis.d.ts.map +0 -1
  242. package/dist/tools/drawing-analysis.js +0 -239
  243. package/dist/tools/drawing-analysis.js.map +0 -1
@@ -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, swApi) => {
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.map((ref, i) => `
40
- swModel.ClearSelection2 True
41
- swModel.Extension.SelectByID2 "${ref}", "PLANE", 0, 0, 0, ${i === 0 ? 'False' : 'True'}, 0, Nothing, 0`).join('')}
42
-
43
- ' Create reference plane
44
- ${args.referenceType === 'offset' ? `
45
- Set swRefPlane = swFeatureMgr.InsertRefPlane( _
46
- swRefPlaneReferenceConstraint_Distance, ${args.offset || 10} / 1000, _
47
- 0, 0, 0, 0)` : ''}
48
- ${args.referenceType === 'angle' ? `
49
- Set swRefPlane = swFeatureMgr.InsertRefPlane( _
50
- swRefPlaneReferenceConstraint_Angle, ${args.angle || 45} * 3.14159 / 180, _
51
- 0, 0, 0, 0)` : ''}
52
- ${args.referenceType === 'parallel' ? `
53
- Set swRefPlane = swFeatureMgr.InsertRefPlane( _
54
- swRefPlaneReferenceConstraint_Parallel, 0, _
55
- 0, 0, 0, 0)` : ''}
56
-
57
- If Not swRefPlane Is Nothing Then
58
- MsgBox "Reference plane created successfully"
59
- Else
60
- MsgBox "Failed to create reference plane"
61
- End If
62
-
63
- swModel.ClearSelection2 True
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.map((ref, i) => `
81
- swModel.Extension.SelectByID2 "${ref}", "PLANE", 0, 0, 0, ${i === 0 ? 'False' : 'True'}, 0, Nothing, 0`).join('')}
82
-
83
- ' Create axis
84
- Set swFeature = swFeatureMgr.InsertAxis2(True)
85
-
86
- If Not swFeature Is Nothing Then
87
- swFeature.Name = "Reference Axis"
88
- MsgBox "Reference axis created: " & swFeature.Name
89
- End If
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
- ' Select guide curves
157
- ${args.guideCurves.map((guide, i) => `
158
- swModel.Extension.SelectByID2 "${guide}", "SKETCH", 0, 0, 0, True, 2, Nothing, 0`).join('')}` : ''}
159
-
160
- ' Create sweep
161
- Set swSweep = swFeatureMgr.CreateDefinition(swFeatureNameID_e.swFmSweep)
162
-
163
- swSweep.TwistAngle = ${args.twistAngle || 0} * 3.14159 / 180
164
- swSweep.MaintainTangency = True
165
- swSweep.AdvancedSmoothing = True
166
- ${args.thinFeature ? `
167
- swSweep.ThinFeature = True
168
- swSweep.ThinWallThickness = ${args.thickness || 1} / 1000` : ''}
169
-
170
- Set swFeature = swFeatureMgr.CreateFeature(swSweep)
171
-
172
- If Not swFeature Is Nothing Then
173
- swFeature.Name = "Sweep_${Date.now()}"
174
- MsgBox "Sweep feature created: " & swFeature.Name
175
- End If
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
- loft: `
178
- Sub CreateLoftFeature()
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
- Dim swLoft As SldWorks.LoftFeatureData
184
-
185
- Set swApp = Application.SldWorks
186
- Set swModel = swApp.ActiveDoc
187
-
188
- If swModel Is Nothing Then Exit Sub
189
-
190
- Set swFeatureMgr = swModel.FeatureManager
191
-
192
- ' Select profiles
193
- ${args.profiles.map((profile, i) => `
194
- swModel.Extension.SelectByID2 "${profile}", "SKETCH", 0, 0, 0, ${i === 0 ? 'False' : 'True'}, 1, Nothing, 0`).join('')}
195
-
196
- ${args.guideCurves && args.guideCurves.length > 0 ? `
197
- ' Select guide curves
198
- ${args.guideCurves.map((guide) => `
199
- swModel.Extension.SelectByID2 "${guide}", "SKETCH", 0, 0, 0, True, 2, Nothing, 0`).join('')}` : ''}
200
-
201
- ' Create loft
202
- Set swLoft = swFeatureMgr.CreateDefinition(swFeatureNameID_e.swFmLoft)
203
-
204
- swLoft.Merge = True
205
- swLoft.Close = False
206
- swLoft.PreserveTangency = True
207
- ${args.thinFeature ? `
208
- swLoft.ThinFeature = True
209
- swLoft.Thickness = ${args.thickness || 1} / 1000` : ''}
210
-
211
- Set swFeature = swFeatureMgr.CreateFeature(swLoft)
212
-
213
- If Not swFeature Is Nothing Then
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.object({
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
- }).optional(),
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.map((name, i) => `
292
- swModel.Extension.SelectByID2 "${name}", "BODYFEATURE", 0, 0, 0, ${i === 0 ? 'False' : 'True'}, 0, Nothing, 0`).join('')}
293
-
294
- ' Select direction references
295
- swModel.Extension.SelectByID2 "Right Plane", "PLANE", 0, 0, 0, True, 1, Nothing, 0
296
- ${args.direction2 ? `swModel.Extension.SelectByID2 "Top Plane", "PLANE", 0, 0, 0, True, 2, Nothing, 0` : ''}
297
-
298
- ' Create linear pattern
299
- Set swFeature = swFeatureMgr.FeatureLinearPattern4( _
300
- ${args.direction1.instances}, ${args.direction1.spacing / 1000}, _
301
- ${args.direction2 ? args.direction2.instances : 1}, ${args.direction2 ? args.direction2.spacing / 1000 : 0}, _
302
- False, ${args.direction1.reverseDirection ? 'True' : 'False'}, _
303
- "NULL", "NULL", False, False, False, False, False, False, _
304
- True, True, False, False, 0, 0)
305
-
306
- If Not swFeature Is Nothing Then
307
- swFeature.Name = "LinearPattern_${Date.now()}"
308
- MsgBox "Linear pattern created: " & swFeature.Name
309
- End If
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.map((name, i) => `
327
- swModel.Extension.SelectByID2 "${name}", "BODYFEATURE", 0, 0, 0, ${i === 0 ? 'False' : 'True'}, 0, Nothing, 0`).join('')}
328
-
329
- ' Select axis
330
- swModel.Extension.SelectByID2 "${args.axis || 'Axis1'}", "AXIS", 0, 0, 0, True, 1, Nothing, 0
331
-
332
- ' Create circular pattern
333
- Set swFeature = swFeatureMgr.FeatureCircularPattern5( _
334
- ${args.direction1.instances}, ${(args.angle || 360) * Math.PI / 180}, _
335
- False, "NULL", False, True, False, False)
336
-
337
- If Not swFeature Is Nothing Then
338
- swFeature.Name = "CircularPattern_${Date.now()}"
339
- MsgBox "Circular pattern created: " & swFeature.Name
340
- End If
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
- ' Create base flange
417
- swModel.Extension.SelectByID2 "Sketch1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0
418
- Set swFeature = swFeatureMgr.InsertSheetMetalBaseFlange2( _
419
- ${args.thickness / 1000}, False, ${(args.bendRadius || args.thickness) / 1000}, _
420
- 0, ${args.kFactor}, True, False, True, _
421
- 0, 0, 0, False, 0, 0, 0, 0)` : ''}
422
-
423
- ${args.operation === 'edge_flange' ? `
424
- ' Create edge flange
425
- swModel.Extension.SelectByID2 "Edge1", "EDGE", 0, 0, 0, False, 0, Nothing, 0
426
- Set swFeature = swFeatureMgr.InsertSheetMetalEdgeFlange2( _
427
- 0, False, ${(args.bendAngle || 90) * Math.PI / 180}, _
428
- 50 / 1000, 0, 0, ${(args.bendRadius || args.thickness) / 1000}, _
429
- 0, 0, False, False, False, False, True, _
430
- 0, 0, 0, 0, 0)` : ''}
431
-
432
- ${args.operation === 'hem' ? `
433
- ' Create hem
434
- swModel.Extension.SelectByID2 "Edge1", "EDGE", 0, 0, 0, False, 0, Nothing, 0
435
- Set swFeature = swFeatureMgr.InsertSheetMetalHem2( _
436
- 1, 1, False, ${args.thickness * 2 / 1000}, _
437
- ${(args.bendRadius || args.thickness) / 1000}, 0, 0, _
438
- 0, 0, False, False, 0)` : ''}
439
-
440
- If Not swFeature Is Nothing Then
441
- swFeature.Name = "SheetMetal_${args.operation}_${Date.now()}"
442
- MsgBox "Sheet metal feature created: " & swFeature.Name
443
- Else
444
- MsgBox "Failed to create sheet metal feature"
445
- End If
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
- ' Surface extrude
477
- swModel.Extension.SelectByID2 "${args.sketches[0]}", "SKETCH", 0, 0, 0, False, 0, Nothing, 0
478
- Set swFeature = swFeatureMgr.FeatureExtruRefSurface2( _
479
- True, False, False, 0, 0, ${(args.distance || 10) / 1000}, 0, _
480
- False, False, False, False, 0, 0, False, False, False, False, False)` : ''}
481
-
482
- ${args.surfaceType === 'revolve' ? `
483
- ' Surface revolve
484
- swModel.Extension.SelectByID2 "${args.sketches[0]}", "SKETCH", 0, 0, 0, False, 0, Nothing, 0
485
- swModel.Extension.SelectByID2 "Axis1", "AXIS", 0, 0, 0, True, 1, Nothing, 0
486
- Set swFeature = swFeatureMgr.FeatureRevolve2( _
487
- True, True, False, False, False, False, 0, 0, _
488
- ${(args.angle || 360) * Math.PI / 180}, 0, False, False, 0, 0, 0, 0, 0, True, True, True)` : ''}
489
-
490
- ${args.surfaceType === 'offset' ? `
491
- ' Offset surface
492
- swModel.Extension.SelectByID2 "Surface1", "SURFACE", 0, 0, 0, False, 0, Nothing, 0
493
- Set swFeature = swFeatureMgr.InsertOffsetSurface( _
494
- ${(args.offsetDistance || 5) / 1000}, False)` : ''}
495
-
496
- ${args.surfaceType === 'thicken' ? `
497
- ' Thicken surface
498
- swModel.Extension.SelectByID2 "Surface1", "SURFACE", 0, 0, 0, False, 0, Nothing, 0
499
- Set swFeature = swFeatureMgr.FeatureThicken( _
500
- ${(args.thickenDepth || 2) / 1000}, 0, 0, False, True, True, True)` : ''}
501
-
502
- ${args.surfaceType === 'knit' ? `
503
- ' Knit surfaces
504
- ${args.sketches.map((sketch, i) => `
505
- swModel.Extension.SelectByID2 "${sketch}", "SURFACE", 0, 0, 0, ${i === 0 ? 'False' : 'True'}, 0, Nothing, 0`).join('')}
506
- Set swFeature = swFeatureMgr.InsertKnitSurface2(0.0001, True, False, True)` : ''}
507
-
508
- If Not swFeature Is Nothing Then
509
- swFeature.Name = "Surface_${args.surfaceType}_${Date.now()}"
510
- MsgBox "Surface created: " & swFeature.Name
511
- End If
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