@atlisp/mcp 1.6.6 → 1.6.8
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 +93 -62
- package/package.json +1 -1
package/dist/atlisp-mcp.js
CHANGED
|
@@ -23,7 +23,7 @@ var FILE_EXTENSIONS = {
|
|
|
23
23
|
"BricsCAD": [".des"]
|
|
24
24
|
};
|
|
25
25
|
var SERVER_NAME = "atlisp-mcp-server";
|
|
26
|
-
var SERVER_VERSION = "1.6.
|
|
26
|
+
var SERVER_VERSION = "1.6.7";
|
|
27
27
|
var MOCK_PACKAGES = [
|
|
28
28
|
{ name: "base", description: "\u57FA\u7840\u51FD\u6570\u5E93", version: "1.0.0" },
|
|
29
29
|
{ name: "at-pm", description: "\u5DE5\u7A0B\u9879\u76EE\u7BA1\u7406", version: "2.1.0" },
|
|
@@ -610,6 +610,58 @@ var __dirname2 = path4.dirname(fileURLToPath2(import.meta.url));
|
|
|
610
610
|
var STANDARDS_DIR = path4.join(__dirname2, "..", "standards");
|
|
611
611
|
var CACHE_TTL = config_default.resourceCacheTtl;
|
|
612
612
|
var resourceCache = /* @__PURE__ */ new Map();
|
|
613
|
+
var ENTITY_PROPERTIES_LISP = `
|
|
614
|
+
(defun entity:to-list (val)
|
|
615
|
+
(cond
|
|
616
|
+
((= (type val) 'VARIANT) (entity:to-list (vlax-variant-value val)))
|
|
617
|
+
((= (type val) 'SAFEARRAY) (vlax-safearray->list val))
|
|
618
|
+
(T val)))
|
|
619
|
+
|
|
620
|
+
(defun entity:try-get (obj names / result val)
|
|
621
|
+
(foreach name names
|
|
622
|
+
(if (not (vl-catch-all-error-p
|
|
623
|
+
(setq val (vl-catch-all-apply
|
|
624
|
+
(function vlax-get-property)
|
|
625
|
+
(list obj name)))))
|
|
626
|
+
(setq result (cons (cons name (entity:to-list val)) result))))
|
|
627
|
+
(reverse result))
|
|
628
|
+
|
|
629
|
+
(setq *common-props* '(ObjectName Handle Layer Color Linetype LinetypeScale Lineweight Visibility Material))
|
|
630
|
+
|
|
631
|
+
(setq *entity-props*
|
|
632
|
+
'((AcDbLine StartPoint EndPoint Angle Delta Length Thickness Normal)
|
|
633
|
+
(AcDbCircle Center Radius Diameter Circumference Area Thickness Normal)
|
|
634
|
+
(AcDbArc Center Radius StartAngle EndAngle TotalAngle ArcLength Area Normal)
|
|
635
|
+
(AcDbPoint Position Thickness Normal)
|
|
636
|
+
(AcDbText TextString Position Height Width ObliqueAngle Rotation StyleName HorizontalAlignment VerticalAlignment Normal Backward UpsideDown)
|
|
637
|
+
(AcDbMText TextString Location Height Width Rotation StyleName AttachmentPoint DrawingDirection LinespacingFactor LinespacingDistance LinespacingStyle FlowDirection)
|
|
638
|
+
(AcDbBlockReference Name InsertionPoint Rotation XScale YScale ZScale Normal)
|
|
639
|
+
(AcDbPolyline Coordinates Closed ConstantWidth Elevation Normal Thickness LinetypeGeneration Area Length)
|
|
640
|
+
(AcDb2dPolyline Coordinates Closed Elevation Normal Thickness LinetypeGeneration Area Length Type Width)
|
|
641
|
+
(AcDb3dPolyline Coordinates Closed Type Normal Length Area)
|
|
642
|
+
(AcDbAlignedDimension DimLinePoint1 DimLinePoint2 ExtLinePoint1 ExtLinePoint2 TextPosition TextRotation Measurement)
|
|
643
|
+
(AcDbRotatedDimension DimLinePoint1 DimLinePoint2 ExtLinePoint1 ExtLinePoint2 TextPosition TextRotation Measurement Rotation)
|
|
644
|
+
(AcDbRadialDimension Center Diameter LeaderLength TextPosition)
|
|
645
|
+
(AcDbDiametricDimension Center Diameter LeaderLength TextPosition)
|
|
646
|
+
(AcDbAngularDimension AngleVertex AngleEndPoint ArcPoint TextPosition Measurement)
|
|
647
|
+
(AcDbHatch PatternName PatternType Area Elevation Normal NumberOfLoops AssociativeHatch HatchObjectType PatternAngle PatternScale PatternSpace ISOPenWidth)
|
|
648
|
+
(AcDbSpline Degree NumberOfControlPoints NumberOfFitPoints ControlPoints FitPoints Knots Weights Area Length Closed Periodic StartTanVector EndTanVector Elevation Normal)
|
|
649
|
+
(AcDbEllipse Center MajorRadius MinorRadius RadiusRatio StartAngle EndAngle Area Circumference Normal)
|
|
650
|
+
(AcDbRegion Area Perimeter Centroid MomentsOfInertia PrincipalMoments PrincipalDirections Normal)
|
|
651
|
+
(AcDb3dSolid Volume Area Centroid MomentsOfInertia PrincipalMoments PrincipalDirections)
|
|
652
|
+
(AcDbRasterImage ImageFile ImageWidth ImageHeight Origin Rotation Width Height ShowImage ClippingEnabled)
|
|
653
|
+
(AcDbLeader Coordinates ArrowheadType ArrowheadSize Color ScaleFactor StyleName TextString TextPosition Type Normal)
|
|
654
|
+
(AcDbViewport Center Width Height ScaleFactor CustomScale StandardScale GridOn SnapOn On DisplayLocked)
|
|
655
|
+
(AcDbTable TableStyleName Position Rows Columns Direction FlowDirection)))
|
|
656
|
+
|
|
657
|
+
(defun entity:properties (ent / obj object-name result)
|
|
658
|
+
(setq obj (if (= (type ent) 'VLA-OBJECT) ent (vlax-ename->vla-object ent)))
|
|
659
|
+
(setq result (entity:try-get obj *common-props*))
|
|
660
|
+
(setq object-name (cdr (assoc 'ObjectName result)))
|
|
661
|
+
(if object-name
|
|
662
|
+
(setq result (append result (entity:try-get obj (cdr (assoc (read object-name) *entity-props*))))))
|
|
663
|
+
result)
|
|
664
|
+
`;
|
|
613
665
|
function getCached(key) {
|
|
614
666
|
const entry = resourceCache.get(key);
|
|
615
667
|
if (entry && Date.now() - entry.timestamp < CACHE_TTL) {
|
|
@@ -812,34 +864,18 @@ function lispPairsToObject(pairs) {
|
|
|
812
864
|
}
|
|
813
865
|
return obj;
|
|
814
866
|
}
|
|
815
|
-
function
|
|
816
|
-
if (!Array.isArray(
|
|
867
|
+
function propertyPairsToObject(pairs) {
|
|
868
|
+
if (!Array.isArray(pairs))
|
|
817
869
|
return null;
|
|
818
|
-
const
|
|
819
|
-
const
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
color,
|
|
824
|
-
linetype: String(linetype)
|
|
825
|
-
};
|
|
826
|
-
const entType = typeof entity.type === "string" ? entity.type.toUpperCase() : entity.type;
|
|
827
|
-
if (/^(TEXT|MTEXT|ATTRIB|TCH_TEXT)$/.test(entType) && rest[0] != null) {
|
|
828
|
-
entity.text = String(rest[0]);
|
|
829
|
-
}
|
|
830
|
-
if (/^(LINE|LWPOLYLINE|POLYLINE|ARC|CIRCLE|SPLINE|ELLIPSE|XLINE|RAY)$/.test(entType) && Array.isArray(rest[0])) {
|
|
831
|
-
entity.points = rest[0].map((pt) => {
|
|
832
|
-
if (Array.isArray(pt) && pt.length >= 2)
|
|
833
|
-
return { x: Number(pt[0]), y: Number(pt[1]), z: Number(pt[2] || 0) };
|
|
834
|
-
return null;
|
|
835
|
-
}).filter(Boolean);
|
|
836
|
-
}
|
|
837
|
-
if (entType === "INSERT" && rest[0] != null) {
|
|
838
|
-
entity.blockName = String(rest[0]);
|
|
870
|
+
const obj = {};
|
|
871
|
+
for (const pair of pairs) {
|
|
872
|
+
if (Array.isArray(pair) && pair.length >= 2) {
|
|
873
|
+
obj[String(pair[0])] = pair[1] !== null && pair[1] !== void 0 ? pair[1] : null;
|
|
874
|
+
}
|
|
839
875
|
}
|
|
840
|
-
return
|
|
876
|
+
return obj;
|
|
841
877
|
}
|
|
842
|
-
function
|
|
878
|
+
function buildEntityPropertiesCode({ type, layer, bbox }) {
|
|
843
879
|
const items = [];
|
|
844
880
|
if (type)
|
|
845
881
|
items.push(`(cons 0 "${type.replace(/"/g, '\\"')}")`);
|
|
@@ -861,27 +897,12 @@ function buildEntityCode({ type, layer, bbox }) {
|
|
|
861
897
|
const ssgetExpr = items.length ? `(ssget "_X" ${filterExpr})` : '(ssget "_X")';
|
|
862
898
|
return `(progn
|
|
863
899
|
(vl-load-com)
|
|
864
|
-
|
|
865
|
-
(setq r (vl-catch-all-apply f (list ent)))
|
|
866
|
-
(if (vl-catch-all-error-p r) nil r))
|
|
867
|
-
(defun @e:dp (ent / ed typ gcl is)
|
|
868
|
-
(setq ed (entget ent) typ (cdr (assoc 0 ed)) gcl (assoc 62 ed) is (assoc 6 ed))
|
|
869
|
-
(append
|
|
870
|
-
(list typ (cdr (assoc 5 ed)) (cdr (assoc 8 ed))
|
|
871
|
-
(if gcl (cdr gcl) 256)
|
|
872
|
-
(if is (cdr is) "ByLayer"))
|
|
873
|
-
(cond
|
|
874
|
-
((wcmatch typ "TEXT,MTEXT,ATTRIB,TCH_TEXT")
|
|
875
|
-
(list (@e:safe-fn '(lambda (e) (text:remove-fmt (text:get-mtext e))) ent)))
|
|
876
|
-
((wcmatch typ "LINE,LWPOLYLINE,POLYLINE,ARC,CIRCLE,SPLINE,ELLIPSE,XLINE,RAY")
|
|
877
|
-
(list (@e:safe-fn 'curve:get-points ent)))
|
|
878
|
-
((= typ "INSERT")
|
|
879
|
-
(list (@e:safe-fn 'block:get-effectivename ent)))
|
|
880
|
-
(t nil))))
|
|
900
|
+
${ENTITY_PROPERTIES_LISP}
|
|
881
901
|
(setq @e:total (if (setq @e:ss ${ssgetExpr}) (sslength @e:ss) 0)
|
|
882
902
|
@e:ents nil @e:i 0)
|
|
883
|
-
(while (and @e:ss (< @e:i @e:total)(< (length @e:ents) 3000))
|
|
884
|
-
(setq @e:ents (cons (
|
|
903
|
+
(while (and @e:ss (< @e:i @e:total) (< (length @e:ents) 3000))
|
|
904
|
+
(setq @e:ents (cons (entity:properties (ssname @e:ss @e:i)) @e:ents)
|
|
905
|
+
@e:i (1+ @e:i)))
|
|
885
906
|
(vl-prin1-to-string (list @e:total (reverse @e:ents))))`;
|
|
886
907
|
}
|
|
887
908
|
function buildTextCode({ layer, bbox, offset, limit }) {
|
|
@@ -902,15 +923,19 @@ function buildTextCode({ layer, bbox, offset, limit }) {
|
|
|
902
923
|
}
|
|
903
924
|
const filterExpr = `(list ${items.join(" ")})`;
|
|
904
925
|
return `(progn
|
|
905
|
-
(defun @t:props (ent / ed
|
|
906
|
-
(setq ed (entget ent)
|
|
907
|
-
(
|
|
908
|
-
(
|
|
909
|
-
(vl-prin1-to-string (
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
(
|
|
913
|
-
(vl-prin1-to-string (
|
|
926
|
+
(defun @t:props (ent / ed ins)
|
|
927
|
+
(setq ed (entget ent) ins (cdr (assoc 10 ed)))
|
|
928
|
+
(list
|
|
929
|
+
(list "type" (vl-prin1-to-string (cdr (assoc 0 ed))))
|
|
930
|
+
(list "handle" (vl-prin1-to-string (cdr (assoc 5 ed))))
|
|
931
|
+
(list "layer" (vl-prin1-to-string (cdr (assoc 8 ed))))
|
|
932
|
+
(list "color" (if (assoc 62 ed) (cdr (assoc 62 ed)) 256))
|
|
933
|
+
(list "linetype" (vl-prin1-to-string (if (assoc 6 ed) (cdr (assoc 6 ed)) "ByLayer")))
|
|
934
|
+
(list "text" (vl-prin1-to-string (cdr (assoc 1 ed))))
|
|
935
|
+
(list "insert" (list (car ins) (cadr ins) (caddr ins)))
|
|
936
|
+
(list "height" (cdr (assoc 40 ed)))
|
|
937
|
+
(list "rotation" (cdr (assoc 50 ed)))
|
|
938
|
+
(list "style" (vl-prin1-to-string (if (assoc 7 ed) (cdr (assoc 7 ed)) "Standard")))))
|
|
914
939
|
(defun @t:run nil
|
|
915
940
|
(setq ss (ssget "_X" ${filterExpr}))
|
|
916
941
|
(if (null ss)
|
|
@@ -926,8 +951,8 @@ function buildTextCode({ layer, bbox, offset, limit }) {
|
|
|
926
951
|
var RESOURCES = [
|
|
927
952
|
{ uri: "atlisp://cad/info", name: "CAD Info", description: "CAD \u8FDE\u63A5\u4FE1\u606F", mimeType: "application/json", subscribable: true },
|
|
928
953
|
{ uri: "atlisp://dwg/layers", name: "Layers", description: "\u56FE\u5C42\u5217\u8868", mimeType: "application/json", subscribable: true },
|
|
929
|
-
{ uri: "atlisp://dwg/entities", name: "Entities", description: "\u56FE\u5143\u5217\u8868\
|
|
930
|
-
{ uri: "atlisp://dwg/texts", name: "Texts", description: "\u6587\u672C\u5B9E\u4F53\
|
|
954
|
+
{ uri: "atlisp://dwg/entities", name: "Entities", description: "\u56FE\u5143\u5217\u8868\u3002\u65E0\u53C2\u6570\u65F6\u8FD4\u56DE\u603B\u6570\u548C\u6309\u7C7B\u578B\u7EDF\u8BA1\uFF1B\u6709\u53C2\u6570\u65F6\u8FD4\u56DE filtered \u56FE\u6587\u7684 entity:properties \u5168\u5C5E\u6027 JSON\uFF08ObjectName, Handle, Layer, Color, Center, Radius \u7B49\uFF09\uFF0C\u652F\u6301 ?type=LINE&layer=0&bbox=0,0,100,100", mimeType: "application/json", subscribable: true },
|
|
955
|
+
{ uri: "atlisp://dwg/texts", name: "Texts", description: "\u6587\u672C\u5B9E\u4F53 key:value \u5217\u8868 (TEXT/MTEXT/ATTRIB/TCH_TEXT)\uFF0C\u652F\u6301 ?layer=0&bbox=0,0,100,100&limit=5000&offset=0", mimeType: "application/json", subscribable: true },
|
|
931
956
|
{ uri: "atlisp://dwg/name", name: "DWG Name", description: "\u5F53\u524D DWG \u6587\u4EF6\u540D", mimeType: "application/json", subscribable: true },
|
|
932
957
|
{ uri: "atlisp://dwg/path", name: "DWG Path", description: "\u6587\u4EF6\u5B8C\u6574\u8DEF\u5F84", mimeType: "application/json", subscribable: true },
|
|
933
958
|
{ uri: "atlisp://cad/dwgs", name: "DWG List", description: "\u6240\u6709\u6253\u5F00\u7684 DWG \u6587\u4EF6\u5217\u8868", mimeType: "application/json", subscribable: true },
|
|
@@ -1130,7 +1155,7 @@ async function getEntities(params = {}) {
|
|
|
1130
1155
|
return await getEntitiesSummary(cacheKey);
|
|
1131
1156
|
}
|
|
1132
1157
|
try {
|
|
1133
|
-
const code =
|
|
1158
|
+
const code = buildEntityPropertiesCode({
|
|
1134
1159
|
type: params.type || null,
|
|
1135
1160
|
layer: params.layer || null,
|
|
1136
1161
|
bbox: params.bbox || null
|
|
@@ -1147,7 +1172,7 @@ async function getEntities(params = {}) {
|
|
|
1147
1172
|
if (parsed && Array.isArray(parsed) && parsed.length >= 2) {
|
|
1148
1173
|
total = typeof parsed[0] === "number" ? parsed[0] : 0;
|
|
1149
1174
|
const rawEntities = Array.isArray(parsed[1]) ? parsed[1] : [];
|
|
1150
|
-
entities = rawEntities.map(
|
|
1175
|
+
entities = rawEntities.map(propertyPairsToObject).filter(Boolean);
|
|
1151
1176
|
}
|
|
1152
1177
|
const result = { total, entities };
|
|
1153
1178
|
log(`getEntities: total=${total}, returned=${entities.length}`);
|
|
@@ -1249,7 +1274,7 @@ async function getTexts(params = {}) {
|
|
|
1249
1274
|
const textsIdx = parsed.indexOf("texts");
|
|
1250
1275
|
const rawTexts = textsIdx !== -1 && Array.isArray(parsed[textsIdx + 1]) ? parsed[textsIdx + 1] : [];
|
|
1251
1276
|
const data = lispPairsToObject(parsed);
|
|
1252
|
-
data.texts = rawTexts.length > 0 ? rawTexts.map(
|
|
1277
|
+
data.texts = rawTexts.length > 0 ? rawTexts.map(propertyPairsToObject).filter(Boolean) : [];
|
|
1253
1278
|
data.offset = offset;
|
|
1254
1279
|
data.limit = limit;
|
|
1255
1280
|
setCache(cacheKey, data);
|
|
@@ -2982,9 +3007,15 @@ var RESOURCE_TEMPLATES = [
|
|
|
2982
3007
|
mimeType: "application/json"
|
|
2983
3008
|
},
|
|
2984
3009
|
{
|
|
2985
|
-
uriTemplate: "atlisp://dwg/entities
|
|
2986
|
-
name: "Entities
|
|
2987
|
-
description: "\u6309\u7C7B\u578B\
|
|
3010
|
+
uriTemplate: "atlisp://dwg/entities",
|
|
3011
|
+
name: "Entities Summary",
|
|
3012
|
+
description: "\u8FD4\u56DE\u56FE\u5143\u603B\u6570\u548C\u6309\u7C7B\u578B\u7EDF\u8BA1\u5217\u8868",
|
|
3013
|
+
mimeType: "application/json"
|
|
3014
|
+
},
|
|
3015
|
+
{
|
|
3016
|
+
uriTemplate: "atlisp://dwg/entities?type={type}&layer={layer}&bbox={bbox}",
|
|
3017
|
+
name: "Filtered Entities",
|
|
3018
|
+
description: "\u6309 type/layer/bbox \u8FC7\u6EE4\u56FE\u5143\uFF0C\u8FD4\u56DE entity:properties \u5168\u5C5E\u6027 JSON\uFF08ObjectName, Handle, Layer, Color, Center, Radius \u7B49\uFF09",
|
|
2988
3019
|
mimeType: "application/json"
|
|
2989
3020
|
},
|
|
2990
3021
|
{
|