@atlisp/mcp 1.8.17 → 1.8.19
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/dist/atlisp-mcp.js +2306 -1458
- package/dist/cad-worker.js +53 -17
- package/dist/config.js +13 -2
- package/dist/handlers/batch-transaction-handlers.js +70 -0
- package/dist/handlers/cad-handlers.js +51 -91
- package/dist/handlers/draw-handlers.js +66 -154
- package/dist/handlers/entity-handlers.js +61 -111
- package/dist/handlers/layer-handlers.js +70 -98
- package/dist/handlers/resource-handlers.js +1219 -26
- package/package.json +4 -2
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { cad } from '../cad.js';
|
|
2
|
-
import { escapeLispString } from '../handler-utils.js';
|
|
3
|
-
|
|
4
|
-
export async function createLayer(name, color = 7, linetype = 'Continuous') {
|
|
5
|
-
if (!cad.connected) { await cad.connect(); }
|
|
6
|
-
if (!cad.connected) return { content: [{ type: 'text', text: '未连接 CAD' }], isError: true };
|
|
2
|
+
import { withCadConnection, mcpSuccess, mcpError, escapeLispString } from '../handler-utils.js';
|
|
7
3
|
|
|
4
|
+
export const createLayer = withCadConnection(async (name, color = 7, linetype = 'Continuous') => {
|
|
8
5
|
const code = `(progn
|
|
9
6
|
(vl-load-com)
|
|
10
7
|
(if (not (tblsearch "LAYER" "${escapeLispString(name)}"))
|
|
@@ -23,24 +20,17 @@ export async function createLayer(name, color = 7, linetype = 'Continuous') {
|
|
|
23
20
|
"EXISTS"
|
|
24
21
|
)
|
|
25
22
|
)`;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return { content: [{ type: 'text', text: `已创建图层: ${name}` }] };
|
|
30
|
-
}
|
|
31
|
-
if (result === 'EXISTS' || result === '"EXISTS"') {
|
|
32
|
-
return { content: [{ type: 'text', text: `图层已存在: ${name}` }] };
|
|
33
|
-
}
|
|
34
|
-
return { content: [{ type: 'text', text: `创建失败: ${result}` }], isError: true };
|
|
35
|
-
} catch (e) {
|
|
36
|
-
return { content: [{ type: 'text', text: `错误: ${e.message}` }], isError: true };
|
|
23
|
+
const result = await cad.sendCommandWithResult(code);
|
|
24
|
+
if (result === 'CREATED' || result === '"CREATED"') {
|
|
25
|
+
return mcpSuccess(`已创建图层: ${name}`);
|
|
37
26
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
27
|
+
if (result === 'EXISTS' || result === '"EXISTS"') {
|
|
28
|
+
return mcpSuccess(`图层已存在: ${name}`);
|
|
29
|
+
}
|
|
30
|
+
return mcpError(`创建失败: ${result}`);
|
|
31
|
+
});
|
|
43
32
|
|
|
33
|
+
export const deleteLayer = withCadConnection(async (name) => {
|
|
44
34
|
const code = `(progn
|
|
45
35
|
(vl-load-com)
|
|
46
36
|
(cond
|
|
@@ -54,27 +44,20 @@ export async function deleteLayer(name) {
|
|
|
54
44
|
(t "NOTFOUND")
|
|
55
45
|
)
|
|
56
46
|
)`;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return { content: [{ type: 'text', text: `已删除图层: ${name}` }] };
|
|
61
|
-
}
|
|
62
|
-
if (result === 'CURRENT' || result === '"CURRENT"') {
|
|
63
|
-
return { content: [{ type: 'text', text: `无法删除当前图层: ${name}` }], isError: true };
|
|
64
|
-
}
|
|
65
|
-
if (result === 'NOTFOUND' || result === '"NOTFOUND"') {
|
|
66
|
-
return { content: [{ type: 'text', text: `图层不存在: ${name}` }], isError: true };
|
|
67
|
-
}
|
|
68
|
-
return { content: [{ type: 'text', text: `删除失败: ${result}` }], isError: true };
|
|
69
|
-
} catch (e) {
|
|
70
|
-
return { content: [{ type: 'text', text: `错误: ${e.message}` }], isError: true };
|
|
47
|
+
const result = await cad.sendCommandWithResult(code);
|
|
48
|
+
if (result === 'DELETED' || result === '"DELETED"') {
|
|
49
|
+
return mcpSuccess(`已删除图层: ${name}`);
|
|
71
50
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (
|
|
76
|
-
|
|
51
|
+
if (result === 'CURRENT' || result === '"CURRENT"') {
|
|
52
|
+
return mcpError(`无法删除当前图层: ${name}`);
|
|
53
|
+
}
|
|
54
|
+
if (result === 'NOTFOUND' || result === '"NOTFOUND"') {
|
|
55
|
+
return mcpError(`图层不存在: ${name}`);
|
|
56
|
+
}
|
|
57
|
+
return mcpError(`删除失败: ${result}`);
|
|
58
|
+
});
|
|
77
59
|
|
|
60
|
+
export const setLayerProperty = withCadConnection(async (name, property, value) => {
|
|
78
61
|
let propCode = '';
|
|
79
62
|
switch (property) {
|
|
80
63
|
case 'color':
|
|
@@ -96,7 +79,7 @@ export async function setLayerProperty(name, property, value) {
|
|
|
96
79
|
propCode = `(command "._LAYER" "U" "${escapeLispString(name)}" "")`;
|
|
97
80
|
break;
|
|
98
81
|
default:
|
|
99
|
-
return
|
|
82
|
+
return mcpError(`不支持的属性: ${property}`);
|
|
100
83
|
}
|
|
101
84
|
|
|
102
85
|
const code = `(progn
|
|
@@ -109,21 +92,14 @@ export async function setLayerProperty(name, property, value) {
|
|
|
109
92
|
"NOTFOUND"
|
|
110
93
|
)
|
|
111
94
|
)`;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return { content: [{ type: 'text', text: `已设置图层 ${name} 的 ${property} 为 ${value}` }] };
|
|
116
|
-
}
|
|
117
|
-
return { content: [{ type: 'text', text: `操作失败: ${result}` }], isError: true };
|
|
118
|
-
} catch (e) {
|
|
119
|
-
return { content: [{ type: 'text', text: `错误: ${e.message}` }], isError: true };
|
|
95
|
+
const result = await cad.sendCommandWithResult(code);
|
|
96
|
+
if (result === 'OK' || result === '"OK"') {
|
|
97
|
+
return mcpSuccess(`已设置图层 ${name} 的 ${property} 为 ${value}`);
|
|
120
98
|
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export async function setCurrentLayer(name) {
|
|
124
|
-
if (!cad.connected) { await cad.connect(); }
|
|
125
|
-
if (!cad.connected) return { content: [{ type: 'text', text: '未连接 CAD' }], isError: true };
|
|
99
|
+
return mcpError(`操作失败: ${result}`);
|
|
100
|
+
});
|
|
126
101
|
|
|
102
|
+
export const setCurrentLayer = withCadConnection(async (name) => {
|
|
127
103
|
const code = `(progn
|
|
128
104
|
(vl-load-com)
|
|
129
105
|
(if (tblsearch "LAYER" "${escapeLispString(name)}")
|
|
@@ -134,48 +110,44 @@ export async function setCurrentLayer(name) {
|
|
|
134
110
|
"NOTFOUND"
|
|
135
111
|
)
|
|
136
112
|
)`;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return { content: [{ type: 'text', text: `已设置当前图层: ${name}` }] };
|
|
141
|
-
}
|
|
142
|
-
return { content: [{ type: 'text', text: `设置失败: ${result}` }], isError: true };
|
|
143
|
-
} catch (e) {
|
|
144
|
-
return { content: [{ type: 'text', text: `错误: ${e.message}` }], isError: true };
|
|
113
|
+
const result = await cad.sendCommandWithResult(code);
|
|
114
|
+
if (result === 'OK' || result === '"OK"') {
|
|
115
|
+
return mcpSuccess(`已设置当前图层: ${name}`);
|
|
145
116
|
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
117
|
+
return mcpError(`设置失败: ${result}`);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
export const layerIsolate = withCadConnection(async (name) => {
|
|
121
|
+
await cad.sendCommand(`(command "_.LAYISO" "${escapeLispString(name)}" "")\n`);
|
|
122
|
+
return mcpSuccess(`已隔离图层: ${name}`);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
export const layerUnisolate = withCadConnection(async () => {
|
|
126
|
+
await cad.sendCommand('(command "_.LAYUNISO")\n');
|
|
127
|
+
return mcpSuccess('已取消图层隔离');
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
export const layerFreezeAll = withCadConnection(async () => {
|
|
131
|
+
await cad.sendCommand('(command "_.LAYER" "F" "*" "")\n');
|
|
132
|
+
return mcpSuccess('已冻结所有图层');
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
export const layerThawAll = withCadConnection(async () => {
|
|
136
|
+
await cad.sendCommand('(command "_.LAYER" "T" "*" "")\n');
|
|
137
|
+
return mcpSuccess('已解冻所有图层');
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
export const layerLockAll = withCadConnection(async () => {
|
|
141
|
+
await cad.sendCommand('(command "_.LAYER" "LO" "*" "")\n');
|
|
142
|
+
return mcpSuccess('已锁定所有图层');
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
export const layerUnlockAll = withCadConnection(async () => {
|
|
146
|
+
await cad.sendCommand('(command "_.LAYER" "U" "*" "")\n');
|
|
147
|
+
return mcpSuccess('已解锁所有图层');
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
export const layerMerge = withCadConnection(async (sourceName, targetName) => {
|
|
151
|
+
await cad.sendCommand(`(command "_.LAYMRG" "${escapeLispString(sourceName)}" "" "${escapeLispString(targetName)}" "Y")\n`);
|
|
152
|
+
return mcpSuccess(`已将图层 ${sourceName} 合并到 ${targetName}`);
|
|
153
|
+
});
|