@atlisp/mcp 1.8.0 → 1.8.2
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 +448 -611
- package/dist/cad-worker.js +73 -0
- package/package.json +1 -1
package/dist/cad-worker.js
CHANGED
|
@@ -245,6 +245,63 @@ string encoding = d.encoding != null ? d.encoding.ToString() : "";
|
|
|
245
245
|
}
|
|
246
246
|
*/});
|
|
247
247
|
|
|
248
|
+
const cadGetActiveDocInfo = edge.func(function() {/*
|
|
249
|
+
async (input) => {
|
|
250
|
+
try {
|
|
251
|
+
string platform = input.ToString();
|
|
252
|
+
string progId = platform == "BricsCAD" ? "BricscadApp.AcadApplication" : platform + ".Application";
|
|
253
|
+
dynamic cad = System.Runtime.InteropServices.Marshal.GetActiveObject(progId);
|
|
254
|
+
if (cad != null) {
|
|
255
|
+
int docCount = cad.Documents.Count;
|
|
256
|
+
string docName = "";
|
|
257
|
+
string docPath = "";
|
|
258
|
+
try {
|
|
259
|
+
docName = cad.ActiveDocument.Name;
|
|
260
|
+
docPath = cad.ActiveDocument.FullName;
|
|
261
|
+
} catch {}
|
|
262
|
+
return new { hasDoc = docCount > 0, docCount = docCount, docName = docName, docPath = docPath };
|
|
263
|
+
}
|
|
264
|
+
} catch (Exception ex) {
|
|
265
|
+
System.Diagnostics.Debug.WriteLine("cadGetActiveDocInfo error: " + ex.Message);
|
|
266
|
+
}
|
|
267
|
+
return new { hasDoc = false, docCount = 0, docName = "", docPath = "" };
|
|
268
|
+
}
|
|
269
|
+
*/});
|
|
270
|
+
|
|
271
|
+
const cadStartMonitor = edge.func(function() {/*
|
|
272
|
+
async (input) => {
|
|
273
|
+
try {
|
|
274
|
+
string platform = input.ToString();
|
|
275
|
+
string progId = platform == "BricsCAD" ? "BricscadApp.AcadApplication" : platform + ".Application";
|
|
276
|
+
dynamic cad = System.Runtime.InteropServices.Marshal.GetActiveObject(progId);
|
|
277
|
+
if (cad == null) return new { success = false, error = "CAD not found" };
|
|
278
|
+
|
|
279
|
+
string prevName = "";
|
|
280
|
+
var timer = new System.Threading.Timer((_) => {
|
|
281
|
+
try {
|
|
282
|
+
string docName = cad.ActiveDocument.Name;
|
|
283
|
+
if (docName != prevName) {
|
|
284
|
+
prevName = docName;
|
|
285
|
+
string docPath = "";
|
|
286
|
+
try { docPath = cad.ActiveDocument.FullName; } catch {}
|
|
287
|
+
string json = "{\"type\":\"event\",\"eventType\":\"documentChanged\",\"docName\":\"" +
|
|
288
|
+
docName.Replace("\\", "\\\\").Replace("\"", "\\\"") +
|
|
289
|
+
"\",\"docPath\":\"" +
|
|
290
|
+
docPath.Replace("\\", "\\\\").Replace("\"", "\\\"") + "\"}";
|
|
291
|
+
Console.WriteLine(json);
|
|
292
|
+
}
|
|
293
|
+
} catch (Exception ex) {
|
|
294
|
+
System.Diagnostics.Debug.WriteLine("cadMonitor timer error: " + ex.Message);
|
|
295
|
+
}
|
|
296
|
+
}, null, 3000, 3000);
|
|
297
|
+
|
|
298
|
+
return new { success = true };
|
|
299
|
+
} catch (Exception ex) {
|
|
300
|
+
return new { success = false, error = ex.Message };
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
*/});
|
|
304
|
+
|
|
248
305
|
process.stdin.setEncoding('utf8');
|
|
249
306
|
|
|
250
307
|
let stdinBuffer = '';
|
|
@@ -581,5 +638,21 @@ async function handleMessage(msg) {
|
|
|
581
638
|
});
|
|
582
639
|
});
|
|
583
640
|
}
|
|
641
|
+
if (msg.type === 'getActiveDocInfo') {
|
|
642
|
+
return new Promise((resolve, reject) => {
|
|
643
|
+
cadGetActiveDocInfo(msg.platform || 'AutoCAD', (e, r) => {
|
|
644
|
+
if (e) reject(e);
|
|
645
|
+
else resolve(r);
|
|
646
|
+
});
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
if (msg.type === 'startMonitor') {
|
|
650
|
+
return new Promise((resolve, reject) => {
|
|
651
|
+
cadStartMonitor(msg.platform || 'AutoCAD', (e, r) => {
|
|
652
|
+
if (e) reject(e);
|
|
653
|
+
else resolve(r);
|
|
654
|
+
});
|
|
655
|
+
});
|
|
656
|
+
}
|
|
584
657
|
return { error: 'unknown message type' };
|
|
585
658
|
}
|