123456789101112131415161718192021222324252627282930 |
- var mt=Object.defineProperty;var yt=(a,e,s)=>e in a?mt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[e]=s;var G=(a,e,s)=>yt(a,typeof e!="symbol"?e+"":e,s);import{i as xt,a as me,s as pt,c as ye,b as _,d as u,e as F,f as Pt,g as qe,h as ae,j as Be,k as j,l as V,m as Dt,n as $,o as B,p as H,q as de,r as ie,t as Z,u as q,v as L,w as We,x as ze,y as le,D as v,z as X,A as Qe,B as Mt,C as Xe,E as Te,F as ke,G as Je,H as bt,I as At,J as Pe,K as De,L as Ct,N as He,O as et,P as tt,Q as nt,R as st,S as kt,T as je,U as ce,V as it,W as ot,X as Et,_ as we,Y as Ae,Z as vt,$ as It,a0 as Lt,a1 as Tt,a2 as rt,a3 as Ye,a4 as Rt,a5 as St,a6 as at,a7 as Vt,a8 as _t,a9 as $t,aa as Ke,ab as Wt,ac as Nt,ad as zt}from"./index-D68iA7pN.js";import{M as Ft}from"./index-DygTP69T.js";import{s as Kt}from"./hooks-oYkL7aVN.js";import{p as Ot}from"./print-BUiXb7dt.js";const Bt=(a=!1,e=!1,s=!1)=>new Promise(async(n,i)=>{let f=_.App.getCurrentMxCAD().getCurrentFileName();f.length==0&&(f="temp_empty.mxweb");let o=f;!_.App.getCurrentMxCAD().saveFile(f,async d=>{let t;/^((?!chrome|android).)*safari/i.test(navigator.userAgent)?t=new Blob([d.buffer],{type:"application/octet-stream"}):t=new Blob([d.buffer],{type:"application/octet-binary"});try{n({blob:t,data:d,filename:o})}catch(M){i(M),console.error(M)}},e,s,a?void 0:{compression:0})&&i(u("452"))}),ct=async()=>{try{if(!xt()){const a=me(),{filename:e,blob:s,data:n}=await Bt(!0);await pt({blob:s,filename:e,types:[{description:"mxweb File",accept:{"application/octet-stream":[".mxweb"]}}]}),a&&ye("MxFullScreen")}}catch(a){console.error(a)}},Ht=async()=>{await ct()},Ut=()=>{F("Mx_Spline",()=>{Pt.use()})};async function Xt(a,e){let s=a+"_preloading.json",n=await qe.getJsonFromUrl(s),i={ok:!0,tz:!1};if(!n)return new Promise((g,d)=>{g(i)});n.tz&&(i.tz=n.tz);let f=[];return n.images.forEach(g=>{g.substring(0,5)!="http:"&&g.substring(0,6)!="https:"&&f.push(g)}),n.images=f,n.images.length===0&&n.externalReference.length===0?new Promise((g,d)=>{g(i)}):(n.hash=e,(await Kt(n))?.data?i.ok=!0:i.ok=!1,new Promise((g,d)=>{g(i)}))}const jt=async()=>{const a=new ae;a.setMessage(u("选择需要离散的实体"));let e;a.setUserDraw(g=>{e=g});const s=await a.go();if(!s||!s.isValid())return;let n=s.getMcDbCurve();if(!n||!(n instanceof Be))return;const i=new j;i.setUserDraw((g,d)=>{if(!n||!e)return;const t=n.clone();t&&(t.move(e,g),d.drawMcDbEntity(t))});const f=await i.go();if(!f)return;let o=n.clone();if(o)if(o.move(e,f),n instanceof V){const g=_.getCurrentMxCAD().drawEntity(o);let d=new Dt;d.copyFormAryId([g]),_.App.MxCADAssist.MxExplode(d.imp)}else{const g=o.getSamplePoints(.1);if(g.GetCount()===0)return;let d;const t=_.getCurrentMxCAD();g.forEach((w,M)=>{if(M===1010){const p=new $(w.x,w.y,w.z);if(d){const l=new B;l.startPoint=d,l.endPoint=p,l.colorIndex=o.colorIndex,l.trueColor=o.trueColor,l.drawOrder=o.drawOrder,l.layer=o.layer,l.layerId=o.layerId,l.linetype=o.linetype,l.linetypeScale=o.linetypeScale,l.lineweight=l.lineweight,l.textStyle=l.textStyle,t.drawEntity(l)}d=p}}),t.updateDisplay()}};F("_SampleCurve",jt);function Ee(a,e,s){const n=e.clone(),i=s.clone(),f=a.clone(),o=f.sub(n),g=i.sub(n),d=f.sub(i);let t,w=o.crossProduct(g).length()/g.length(),M=o.dotProduct(g);const p=g.clone().mult(M/g.length()**2);return n.clone().addvec(p),M<0?t=o.length():M>Math.pow(g.length(),2)?t=d.length():t=w,Math.floor(t)}const Yt=async()=>{const a=_.getCurrentMxCAD(),e=new j;e.setMessage(u("402")),e.setKeyWords("");let s=await e.go(),n,i;if(e.getStatus()===H.kNone){const t=new ae,w=new de;w.AddMcDbEntityTypes("CIRCLE,ARC,LINE,LWPOLYLINE");let M;const p=(l,y)=>{M=l;const x=X.findEntAtPoint(l.x,l.y,l.z,-1,w);if(!(x&&x.isValid()))return;const m=x.getMcDbEntity();m&&(i&&i.highlight(!1),m.highlight(!0),i=m)};for(;;){t.setMessage(u("403")),t.setUserDraw(p),t.setFilter(w);const y=(await t.go()).getMcDbEntity();if(i&&i.highlight(!1),t.getStatus()===H.kCancel)return;if(y instanceof ie){const x=y.getStartPoint().val,m=y.radius,r=Z.kXAxis.clone().rotateBy(y.endAngle).mult(m),h=y.center.clone().addvec(r);if(!x||!h)return;s=x,n=h;break}else if(y instanceof q){const x=y.center,m=y.getStartPoint().val;if(!m)return;s=m,n=m.clone().addvec(x.sub(m).mult(2));break}else if(y instanceof B){s=y.startPoint,n=y.endPoint;break}else if(y instanceof V){for(let x=0;x<y.numVerts();x++){const m=y.getPointAt(x).val,r=y.getPointAt(x+1).val,c=y.getClosestPointTo(M,!1).val;r&&Ee(c,m,r)===0&&(s=m,n=r)}break}else{L.acutPrintf(`
- `+u("404"));continue}}}if(!s||!n&&(e.setMessage(u("405")),e.setUserDraw((t,w)=>{s&&w.drawMcDbLine(s.x,s.y,s.z,t.x,t.y,t.z)}),n=await e.go(),!n))return;let f,o,g,d;for(;;){e.setMessage(u("406")),e.setKeyWords(`[${u("407")}(T)/${u("235")}(A)${typeof d>"u"?u("412")+"/(H)/"+u("413")+"(V)":""}/${u("414")}(R)]`),e.clearLastInputPoint();let t;const w=s.clone(),M=n.clone();let p,l;e.setUserDraw(m=>{if(!s||!n)return;t&&t.erase(),i instanceof q&&(p||(p=i.center.clone().addvec(Z.kXAxis.clone().rotateBy(Math.PI/2).mult(i.radius))),l||(l=i.center.clone().addvec(Z.kXAxis.clone().rotateBy(-Math.PI/2).mult(i.radius))),m.y<p.y&&m.y>l.y&&(m.x>s.x||m.x<n.x)&&(s=p,n=l),m.x<w.x&&m.x>M.x&&(m.y>p.y||m.y<l.y)&&(s=w,n=M)),d==="H"&&(m.x<s.x?m.x=s.x:m.x>n.x&&(m.x=n.x)),d==="V"&&(m.y<s.y&&(m.y=s.y),m.y>n.y&&(m.y=n.y)),t=a.drawDimRotated(s.x,s.y,n.x,n.y,m.x,m.y,g||0);const r=t.getMcDbDimension();r&&(r.textPosition=m,r.useSetTextPosition(),f&&(r.dimensionText=f),o&&(r.textRotation=o),r.trueColor=new We(0,255,0))});const y=await e.go();if(e.isKeyWordPicked("T")){const m=new ze;m.clearLastInputPoint(),m.setMessage(`${u("408")}<${f||t.getMcDbDimension()?.dimensionText||""}>`),m.setKeyWords("");const r=await m.go();if(typeof r!="string")return;f=r,t&&t.erase();continue}if(t&&t.erase(),e.isKeyWordPicked("A")){const m=new le;m.clearLastInputPoint(),m.setMessage(u("398"));const r=await m.go();if(!r||m.getStatus()===H.kCancel)return;m.getDetailedResult()===v.kCoordIn?o=r*(Math.PI/180):o=r;continue}if(e.isKeyWordPicked("H")){d="H";continue}if(e.isKeyWordPicked("V")){d="V";continue}if(e.isKeyWordPicked("R")){const m=new le;m.clearLastInputPoint(),m.setMessage(u("415"));const r=await m.go();if(!r||m.getStatus()===H.kCancel)return;m.getDetailedResult()===v.kCoordIn?g=r*(Math.PI/180):g=r;continue}if(!y)return;d==="H"&&(y.x<s.x?y.x=s.x:y.x>n.x&&(y.x=n.x)),d==="V"&&(y.y<s.y&&(y.y=s.y),y.y>n.y&&(y.y=n.y)),t=a.drawDimRotated(s.x,s.y,n.x,n.y,y.x,y.y,g||0);const x=t.getMcDbDimension();if(!x)return;x.textPosition=y,x.useSetTextPosition(),f&&(x.dimensionText=f),o&&(x.textRotation=o),x.trueColor=new We(0,255,0),a.updateDisplay();break}};F("_DrawRotatedDimension",Yt);const Gt=async()=>{const a=_.getCurrentMxCAD();console.log(a.drawDimStyle);const e=new j;e.setMessage(`${u("402")}<${u("134")}>`),e.setKeyWords("");let s=await e.go(),n;if(e.getStatus()===H.kNone){const o=new ae,g=new de;g.AddMcDbEntityTypes("CIRCLE,ARC,LINE,LWPOLYLINE");let d,t;const w=(M,p)=>{d=M;const l=X.findEntAtPoint(M.x,M.y,M.z,-1,g);if(!(l&&l.isValid()))return;const y=l.getMcDbEntity();y&&(t&&t.highlight(!1),y.highlight(!0),t=y)};for(;;){o.setMessage(u("403")),o.setUserDraw(w),o.setFilter(g);const p=(await o.go()).getMcDbEntity();if(t&&t.highlight(!1),o.getStatus()===H.kCancel)return;if(p instanceof ie){const l=p.getStartPoint().val,y=p.radius,x=Z.kXAxis.clone().rotateBy(p.endAngle).mult(y),r=p.center.clone().addvec(x);if(!l||!r)return;s=l,n=r;break}else if(p instanceof q){const l=p.center,y=p.getClosestPointTo(d,!1).val;if(!y)return;s=y,n=y.clone().addvec(l.sub(y).mult(2));break}else if(p instanceof B){s=p.startPoint,n=p.endPoint;break}else if(p instanceof V){for(let l=0;l<p.numVerts();l++){const y=p.getPointAt(l).val,x=p.getPointAt(l+1).val,m=p.getClosestPointTo(d,!1).val;x&&Ee(m,y,x)===0&&(s=y,n=x)}break}else{L.acutPrintf(`
- `+u("404"));continue}}}if(!s||!n&&(e.setMessage(u("405")),e.setUserDraw((o,g)=>{s&&g.drawMcDbLine(s.x,s.y,s.z,o.x,o.y,o.z)}),n=await e.go(),!n))return;let i,f;for(;;){e.setMessage(u("406")),e.setKeyWords(`[${u("407")}(T)/${u("235")}(A)]`),e.clearLastInputPoint();let o;e.setUserDraw(t=>{if(!s||!n)return;o&&o.erase(),o=a.drawDimAligned(s.x,s.y,n.x,n.y,t.x,t.y);const w=o.getMcDbDimension();w&&(i&&(w.dimensionText=i),f&&(w.textRotation=f))});const g=await e.go();if(e.isKeyWordPicked("T")){const t=new ze;t.clearLastInputPoint(),t.setMessage(`${u("408")}<${i||o.getMcDbDimension()?.dimensionText||""}>`),t.setKeyWords("");const w=await t.go();if(typeof w!="string")return;i=w,o&&o.erase();continue}if(o&&o.erase(),e.isKeyWordPicked("A")){const t=new le;t.clearLastInputPoint(),t.setMessage(u("398"));const w=await t.go();if(!w||t.getStatus()===H.kCancel)return;t.getDetailedResult()===v.kCoordIn?f=w*(Math.PI/180):f=w;continue}if(!g)return;o=a.drawDimAligned(s.x,s.y,n.x,n.y,g.x,g.y);const d=o.getMcDbDimension();if(!d)return;d.textPosition=g,i&&(d.dimensionText=i),f&&(d.textRotation=f),a.updateDisplay();break}};F("_DrawAlignedDimension",Gt);async function Zt(){let a=L.getCurrentDraw().getViewAngle();a-=Math.PI*.5,_.getCurrentMxCAD().zoomAngle(a)}async function qt(){const a=new Qe;a.setMessage(u("370")),a.setKeyWords(`[${u("371")} UCS(C)/${u("372")}(W)/${u("235")}(A)/${u("373")}(X)]`);const e=await a.go();if(e?.toLocaleLowerCase(),e?.toLocaleLowerCase(),e?.toLocaleLowerCase()==="a"){const s=new le;s.clearLastInputPoint(),s.setMessage(u("374"));let n=await s.go();if(!n)return;s.getDetailedResult()===v.kCoordIn&&(n=n*(Math.PI/180)),_.getCurrentMxCAD().zoomAngle(n)}if(e?.toLocaleLowerCase()==="x"){const s=new le;s.clearLastInputPoint(),s.setMessage(u("375"));let n=await s.go();if(!n)return;s.getDetailedResult()===v.kCoordIn&&(n=n*(Math.PI/180));let i=L.getCurrentDraw().getViewAngle();i+=n,_.getCurrentMxCAD().zoomAngle(i)}}F("Mx_Plan90CCW",Zt);F("Mx_Plan",qt);function Qt(){const a=_.getCurrentMxCAD();let e=a.mxdraw.getViewColor();const{createColor:s}=Mt();ye("Mx_Color",{color:s({color:Xe(e).toString()}),call:n=>{const i=Xe(n),f=i.red(),o=i.green(),g=i.blue();a.setViewBackgroundColor(f,o,g),L.callEvent("updateBackgroundColor",new We(f,o,g))}})}F("_ViewColor",Qt);function lt(a,e){const s=document.timeline?document.timeline.currentTime:performance.now();let n=!1;function i(f){if(n)return;const o=f-s,g=Math.round(o/a);e(g);const d=(g+1)*a+s,t=document.timeline?document.timeline.currentTime:performance.now();return setTimeout(()=>{requestAnimationFrame(i)},d-t)}return i(s),()=>{n=!0}}function dt(a,e,s){let n=e,i=s;for(;i-n>1e-4;){let o=(n+i)/2;Math.floor(a/o)*o>a||o<e?i=o:n=o}let f=Math.floor(a/n);return a/f}function Ce(a,e,s,n){const i=a.distanceTo(e),f=[],o=dt(i,s,n);if(isNaN(o))return f;const g=i/o,d=e.sub(a).normalize();for(let t=0;t<g;t++)f.push(a.clone().addvec(d.clone().mult(o*t)));return f}function Jt(a=new $,e=new $,s=3,n=Math.PI*2){const i=[];s=Math.max(3,s),i.push(e);const f=n/s;for(let o=1;o<s;o++){const g=Math.cos(f*o),d=Math.sin(f*o),t=a.clone(),w=e.clone(),M=w.x-t.x,p=w.y-t.y,l=M*g-p*d+t.x,y=M*d+p*g+t.y,x=new $(l,y);i.push(x)}return i}const en=(a,e)=>{const s=new $(a.x,e.y,a.z),n=new $(e.x,a.y,e.z);return[a,s,e,n]};async function tn(){const a=L.viewCoordLong2Cad(2);let e=Number(localStorage.getItem("mx_revcloud_minArcLength")),s=Number(localStorage.getItem("mx_revcloud_maxArcLength"));if(isNaN(e)||e<1e-4){const t=L.viewCoordLong2Cad(12);localStorage.setItem("mx_revcloud_minArcLength",t.toString())}if(isNaN(s)||s<1e-4){const t=L.viewCoordLong2Cad(12);localStorage.setItem("mx_revcloud_maxArcLength",t.toString())}const n=new j;let i=-.45,f=!1,o=!1,g=!1;function d(t,w){t.colorIndex=w.colorIndex,t.trueColor=w.trueColor,t.drawOrder=w.drawOrder,t.layer=w.layer,t.layerId=w.layerId,t.linetype=w.linetype,t.linetypeScale=w.linetypeScale,t.lineweight=w.lineweight,t.textStyle=w.textStyle}for(;;){let t=u("416");f&&(t=u("417")),o&&(t=u("418")),n.setMessage(t),n.setKeyWords(`[${u("419")}(A)/${u("137")}(O)/${u("189")}(R)/${u("420")}(P)/${u("421")}(F)/${u("422")}(S)]`);const w=new V;n.clearLastInputPoint();const M=async l=>{if(n.clearLastInputPoint(),n.setMessage(u("423")),n.setKeyWords(`[${u("140")}(Y)/${u("141")}(N)]`),await n.go(),n.isKeyWordPicked("Y")){const y=l.numVerts();for(let x=0;x<y;x++){const m=l.getBulgeAt(x);l.setBulgeAt(x,-m)}}return!0};let p=await n.go();if(n.isKeyWordPicked("A")){const l=new Te;l.setMessage(u("424"));let y=await l.go();if(typeof y!="number")return;if(y<1e-5){L.acutPrintf(`
- `+u("425"));return}e=y,localStorage.setItem("mx_revcloud_minArcLength",y.toString());const x=async()=>{l.setMessage(u("426"));let m=await l.go();if(typeof m!="number")return!1;if(m<1e-5){L.acutPrintf(`
- `+u("427"));return}if(m<e)return L.acutPrintf(`
- `+u("428")),await x();s=m,localStorage.setItem("mx_revcloud_maxArcLength",m.toString())};if(await x()===!1)return;continue}if(n.isKeyWordPicked("O")){const l=new de;l.AddMcDbEntityTypes("CIRCLE,ARC,LINE,LWPOLYLINE,ELLIPSE");const x=(await X.userSelect(u("134"),l))[0];if(!x)return;const m=x.getMcDbEntity();if(!m)return;if(m instanceof V){w.isClosed=m.isClosed,w.constantWidth=m.constantWidth,d(w,m);const r=m.numVerts();let c;for(let h=0;h<r;h++){const P=m.getPointAt(h).val;c&&P&&Ce(c,P,e,s).forEach(D=>{w.addVertexAt(D,i,void 0,g?a:void 0)}),c=P}return w.isClosed?Ce(c,m.getPointAt(0).val,e,s).forEach(h=>{w.addVertexAt(h,i,void 0,g?a:void 0)}):w.addVertexAt(c,i),await M(w),m.erase(),_.getCurrentMxCAD().drawEntity(w)}if(m instanceof B)return d(w,m),Ce(m.startPoint,m.endPoint,e,s).forEach(r=>{w.addVertexAt(r,i,void 0,g?a:void 0)}),w.addVertexAt(m.endPoint,i,void 0,g?a:void 0),await M(w),m.erase(),_.getCurrentMxCAD().drawEntity(w);if(m instanceof q){const r=m.getLength().val,c=r/dt(r,e,s),h=m.getStartPoint().val;return Jt(m.center,h,c).forEach(P=>{w.addVertexAt(P,i,void 0,g?a:void 0)}),d(w,m),m instanceof q&&(w.isClosed=!0),await M(w),m.erase(),_.getCurrentMxCAD().drawEntity(w)}}if(n.isKeyWordPicked("R")){f=!0,o=!1;continue}if(n.isKeyWordPicked("P")){o=!0,f=!1;continue}if(n.isKeyWordPicked("F")){o=!1,f=!1;continue}if(n.isKeyWordPicked("S")){if(n.setMessage(u("429")),n.setKeyWords(`[${u("430")}(N)/${u("431")}(C)]`),await n.go(),n.getDetailedResult()===v.kEcsIn||n.getDetailedResult()===v.kNewCommadIn||n.getStatus()===H.kNone||n.getStatus()===H.kCancel)return;n.isKeyWordPicked("N")&&(g=!1),n.isKeyWordPicked("C")&&(g=!0);continue}if(!p)return;if(f){n.setMessage(u("410")),n.setMessage("");const l=(x,m)=>{if(!p)return;const[r,c,h,P]=en(p,m),D=p.x<m.x&&p.y<m.y||p.x>m.x&&p.y>m.y;[[r,c],[c,h],[h,P],[P,r]].forEach(([A,b])=>{Ce(A,b,e,s).forEach(C=>{x.addVertexAt(C,D?i:-i,void 0,g?a:void 0)})}),x.isClosed=!0};n.setUserDraw((x,m)=>{const r=new V;l(r,x),m.drawMcDbEntity(r)});const y=await n.go();return y?(l(w,y),_.getCurrentMxCAD().drawEntity(w)):void 0}else if(o){let l=p;const y=[];y.push(l);const x=(m,r)=>{let c;r.forEach(h=>{c&&Ce(c,h,e,s).forEach(P=>{m.addVertexAt(P,i,void 0,g?a:void 0)}),c=h}),r.length>2?(m.isClosed=!0,Ce(c,r[0],e,s).forEach(h=>{m.addVertexAt(h,i,void 0,g?a:void 0)})):m.addVertexAt(c,i,void 0,g?a:void 0)};for(n.setUserDraw((m,r)=>{const c=new V;x(c,[...y,m]),r.drawMcDbEntity(c)});;){n.setMessage(u("432")),n.setKeyWords(y.length<2?"":`[${u("433")}(U)]`);const m=await n.go();if(n.isKeyWordPicked("U")){y.pop(),n.clearLastInputPoint();continue}if(n.getDetailedResult()===v.kNullEnterIn||n.getDetailedResult()===v.kMouseRightIn)return x(w,y),await M(w),_.getCurrentMxCAD().drawEntity(w);if(!m)return;y.push(m)}}else{w.addVertexAt(p,i,void 0,g?a:void 0);const l=p.clone();let y=0,x=p;const m=async()=>{c(),await M(w),_.getCurrentMxCAD().drawEntity(w)};n.setMessage(u("434")+"..."),n.setKeyWords(""),n.setUserDraw((P,D)=>{p&&(x=P,y=p.distanceTo(P),D.drawMcDbEntity(w.clone()),D.drawLine(p.toVector3(),P.toVector3()))}),n.clearLastInputPoint();let r=!1;const c=lt(20,async()=>{if(!(y<e)){if(x.distanceTo(l)<e){w.isClosed=!0,L.stopRunCommand(),r=!0;return}w.addVertexAt(x,i,void 0,g?a:void 0),p=x,y=0}}),h=await n.go();if((n.getDetailedResult()===v.kMouseRightIn||n.getDetailedResult()===v.kNullEnterIn)&&await m(),!h&&!r)return c();h&&w.addVertexAt(h,i,void 0,g?a:void 0),await m();break}}}F("_Revcloud",tn);async function nn(){const a=me(),e=()=>{a&&ye("MxFullScreen")},s=(g,d,t=210,w=297,M=0)=>{let{baseUrl:p="",mxfilepath:l="",printPdfUrl:y=""}=bt()||{},x={width:""+t,height:""+w,roate_angle:M,bd_pt1_x:""+g.x,bd_pt1_y:""+g.y,bd_pt2_x:""+d.x,bd_pt2_y:""+d.y};_.getCurrentMxCAD().saveFileToUrl(y,(m,r)=>{try{let c=JSON.parse(r);if(c.ret=="ok"){let h=p+l+c.file;Ot(h),e()}else console.log(r)}catch{console.log("Mx: sserverResult error")}},void 0,JSON.stringify(x))};L.acutPrintf(`
- `+u("376"));let n=_.getCurrentMxCAD(),i=0,f=!1;for(;;){let g=new j;g.setMessage(`
- `+u("377")+":"),g.setKeyWords(`[${u("378")}(S)/[${u("379")}(D)]`),g.disableAllTrace();let d=await g.go();if(g.isKeyWordPicked("D"))f=!0;else if(g.isKeyWordPicked("S")){let t=new Qe;t.setMessage(u("380")),t.setKeyWords(`[A1(A)/A2(B)/A3(C)/A4(D)/${u("381")}16.55x23.90(E)]`),t.setDisableDynInput(!0);const w=await t.go();if(!w)return;let M={A:{w:594,h:841},B:{w:420,h:594},C:{w:297,h:420},D:{w:210,h:297},E:{w:165.5,h:239,nw:130,nh:190}};if(!M[w])return;let p=new ze;p.setMessage(`${u("382")}(${u("383")})`);let l=await p.go();if(!l)return;var o=parseFloat(l);if(isNaN(o)){L.acutPrintf(u("384"));return}let y=M[w].w*o,x=M[w].h*o,m=0,r=0;if(M[w].nw&&(m=M[w].nw*o),M[w].nh&&(r=M[w].nh*o),f){let D=y;y=x,x=D,D=m,m=r,r=D}g=new j,g.disableAllTrace(),g.setMessage(`
- `+u("385")),g.setKeyWords(""),g.setUserDraw((D,A)=>{A.setColor(16711680);let b=new V,C=new $(D.x-y*.5,D.y-x*.5),E=new $(D.x-y*.5,D.y+x*.5),R=new $(D.x+y*.5,D.y+x*.5),I=new $(D.x+y*.5,D.y-x*.5);b.addVertexAt(C),b.addVertexAt(E),b.addVertexAt(R),b.addVertexAt(I),b.constantWidth=L.screenCoordLong2Doc(2),b.isClosed=!0,A.drawMcDbEntity(b);let k=[];if(k.push(C.toVector3()),k.push(E.toVector3()),k.push(R.toVector3()),k.push(I.toVector3()),A.setColor(12868),A.drawSolid(k,.5),m>0&&r>0){let T=new $(D.x-m*.5,D.y-r*.5),S=new $(D.x-m*.5,D.y+r*.5),z=new $(D.x+m*.5,D.y+r*.5),O=new $(D.x+m*.5,D.y-r*.5),W=[];W.push(T.toVector3()),W.push(S.toVector3()),W.push(z.toVector3()),W.push(O.toVector3()),W.push(T.toVector3());let K=n.mxdraw.viewCoordLong2Cad(3),U=ke.createDashedLines(W,16777215,K*2,K);A.drawEntity(U)}});let c=await g.go();if(!c)return e();let h=new $(c.x-y*.5,c.y-x*.5),P=new $(c.x+y*.5,c.y+x*.5);s(h,P,f?M[w].h:M[w].w,f?M[w].w:M[w].h,i);return}else{if(!d)return e();g.setMessage(`
- `+u("386")+":"),g.setUserDraw((w,M)=>{if(!d)return e();M.setColor(16711680);let p=new V;p.addVertexAt(d),p.addVertexAt(new $(d.x,w.y)),p.addVertexAt(w),p.addVertexAt(new $(w.x,d.y)),p.constantWidth=L.screenCoordLong2Doc(2),p.isClosed=!0,M.drawMcDbEntity(p);let l=[];l.push(d.toVector3()),l.push(new THREE.Vector3(d.x,w.y)),l.push(w.toVector3()),l.push(new THREE.Vector3(w.x,d.y)),M.setColor(12868),M.drawSolid(l,.5)}),g.setDisableOsnap(!0),g.setDisableOrthoTrace(!0),g.setDynamicInputType(Je.kXYCoordInput);let t=await g.go();if(!t)return e();s(d,t,f?297:210,f?210:297,i);return}}}F("Plot",nn);async function sn(){const a=L.viewCoordLong2Cad(20),e=new j;e.setDisableDynInput(!0),e.setDynamicInputType(Je.kNoInput);let s=await e.go();if(!s)return;const n=new V;let i=0,f=s;const o=lt(20,()=>{i<a||(n.addVertexAt(f),s=f,i=0)});e.setUserDraw((t,w)=>{s&&(f=t,i=s.distanceTo(t),w.drawMcDbEntity(n.clone()),w.drawLine(s.toVector3(),t.toVector3()))});const g=await e.go();if(!g)return o();o(),n.addVertexAt(g),_.getCurrentMxCAD().drawEntity(n)}F("MxET_Pencil",sn);function on(a){const e=a.requestFullscreen||a.mozRequestFullScreen||a.webkitRequestFullScreen||a.msRequestFullscreen;e?e.call(a):(Pe().error(u("369")+"!"),console.error(u("369")+"!"))}function rn(){const a=document.exitFullscreen||document.mozCancelFullScreen||document.webkitExitFullscreen||document.msExitFullscreen;a?a.call(document):(Pe().error(u("369")+"!"),console.error(u("369")+"!"))}window.addEventListener("keydown",a=>{a.keyCode===122&&(a.returnValue=!1,ye("MxFullScreen"))},!0);At.register({key:{keyCode:"Escape"},when(a){return a.isRunCommand?!1:me()},action(){ye("MxFullScreen")}});F("MxFullScreen",()=>{me()?(rn(),"keyboard"in navigator&&navigator.keyboard.unlock()):(on(document.body),"keyboard"in navigator&&navigator.keyboard.lock())});async function an(){const a=new Te;a.setMessage(u("指定圆环的内径"));const e=await a.go();if(!e)return;a.setMessage(u("指定圆环的外径"));const s=await a.go();if(!s)return;const n=new j;n.clearLastInputPoint(),n.setMessage(u("指定圆环的中心点")),n.setUserDraw((M,p)=>{const l=new q,y=new q;l.radius=e/2,y.radius=s/2,l.center=M,y.center=M,p.drawMcDbEntity(l),p.drawMcDbEntity(y)});const i=await n.go();if(!i)return;const f=Math.abs(e-s)/4,o=Math.min(e,s),g=i.clone().addvec(Z.kXAxis.clone().mult(o/2+f)),d=i.clone().addvec(Z.kXAxis.clone().negate().mult(o/2+f)),t=new V,w=1;t.addVertexAt(g,w),t.addVertexAt(d,w),t.addVertexAt(g,w),t.isClosed=!0,t.constantWidth=f*2,_.getCurrentMxCAD().drawEntity(t)}F("_donut",an);function Re(a,e,s=0){const n=a.numVerts();for(let i=0;i<a.numVerts();i++){const f=a.getPointAt(i).val;let o=a.getPointAt(i+1).val;if(a.getBulgeAt(i)===0){if(i+1===n&&a.isClosed&&(o=a.getPointAt(0).val),o&&Ee(e,f,o)<s)return{start:f,end:o,startIndex:i,endIndex:i+1}}else if(o){const d=a.getParamAtPoint(f).val,t=a.getParamAtPoint(o).val,w=a.getParamAtPoint(e).val;if(t>w&&w>d)return{start:f,end:o,startIndex:i,endIndex:i+1}}}if(a.isClosed){const i=a.getPointAt(0).val,f=a.getPointAt(a.numVerts()-1).val;if(Ee(e,f,i)<s)return{start:f,end:i,startIndex:a.numVerts()-1,endIndex:0,isClosed:!0}}}async function cn(){const a=_.getCurrentMxCAD(),e=new ae;let s,n,i,f,o,g;const d=new de;d.AddMcDbEntityTypes("CIRCLE,ARC,LINE,LWPOLYLINE");let t,w;const M=(m,r)=>{t=m;const c=X.findEntAtPoint(m.x,m.y,m.z,-1,d);if(!(c&&c.isValid()))return;const h=c.getMcDbEntity();h&&(w&&w.highlight(!1),h.highlight(!0),w=h)};for(;;){e.setMessage(`${u("167")}${u("241")}、${u("201")}、${u("238")}${u("387")} <${u("388")}>`),e.setUserDraw(M),e.setFilter(d);const r=(await e.go()).getMcDbEntity();if(w&&w.highlight(!1),e.getStatus()===H.kCancel)return;if(e.getStatus()===H.kNone){const c=new j;c.clearLastInputPoint(),c.setMessage(u("389"));const h=await c.go();if(!h)return;c.setBasePt(h),c.setMessage(u("390"));const P=await c.go();if(!P)return;c.setMessage(u("391"));const D=await c.go();if(!D)return;s=h.x,n=h.y,i=P.x,f=P.y,o=D.x,g=D.y;break}else if(r instanceof ie){const c=r.getStartPoint().val,h=r.radius,P=Z.kXAxis.clone().rotateBy(r.endAngle).mult(h),D=r.center,A=D.clone().addvec(P);if(!c||!A)return;i=c.x,f=c.y,o=A.x,g=A.y,s=D.x,n=D.y;break}else if(r instanceof q){const c=r.center;s=c.x,n=c.y,i=t.x,f=t.y;const h=new j;h.setMessage(u("391"));const P=await h.go();if(!P)return;const D=r.getClosestPointTo(P,!1).val;o=D.x,g=D.y;break}else if(r instanceof B||r instanceof V){const c=new ae,h=new de;h.AddMcDbEntityTypes("LINE,LWPOLYLINE"),c.setFilter(h);let P;w=null,c.setUserDraw((b,C)=>{M(b),P=b});const D=r.getClosestPointTo(t,!1).val;let A;if(i=D.x,f=D.y,r instanceof B)A=r,A.highlight(!0);else{const{start:b,end:C}=Re(r,D,2)||{};b&&C&&(A=new B(b,C)),r.highlight(!1)}if(!A)return;for(;;){c.setMessage(u("392"));const b=await c.go();if(c.getStatus()===H.kCancel)return A.highlight(!1);if(!b||!b.isValid())continue;let C=b.getMcDbEntity(),E;if(C instanceof V){const{start:T,end:S}=Re(C,c.getDocPickPoint(),2)||{};E=new B(T,S),C.highlight(!1)}else if(C instanceof B)E=C;else{L.acutPrintf(`
- `+u("393"));continue}if(!E)return A.highlight(!1);A.highlight(!1),E.highlight(!1);const R=A.clone()?.IntersectWith(E.clone(),De.Intersect.kExtendBoth);if(console.log(12),R.isEmpty())continue;const I=R.at(0),k=E.getClosestPointTo(P,!1).val;o=k.x,g=k.y,s=I.x,n=I.y;break}break}}const p=new j;p.clearLastInputPoint();let l,y,x;if(![s,n,i,f,o,g].some(m=>typeof m!="number"))for(;;){p.setMessage(u("394")),p.setKeyWords(`[${u("246")}(T)/${u("235")}(A)/${u("395")}(Q)]`),p.setUserDraw((c,h)=>{let P=new Ct;P.compute(s,n,i,f,o,g,c.x,c.y),y&&(P.dimensionText=y),x&&(P.textRotation=x),h.drawMcDbEntity(P,!0)});const m=await p.go();if(p.isKeyWordPicked("T")){const c=new ze;c.clearLastInputPoint(),c.setMessage(`${u("396")}${u("397")}<${y||l.getMcDbDimension()?.dimensionText||""}>`),c.setKeyWords("");const h=await c.go();if(typeof h!="string")return;y=h;continue}if(p.isKeyWordPicked("A")){const c=new le;c.clearLastInputPoint(),c.setMessage(u("398"));const h=await c.go();if(!h||c.getStatus()===H.kCancel)return;c.getDetailedResult()===v.kCoordIn?x=h*(Math.PI/180):x=h;continue}if(p.isKeyWordPicked("Q"),!m)return;a.drawUseDefaultProperties=!0,l=a.drawDimAngular(s,n,i,f,o,g,m.x,m.y);const r=l.getMcDbDimension();if(!r)return;y&&(r.dimensionText=y),x&&(r.textRotation=x);return}}F("_dimangular",cn);function ln(a,e,s){const{x:n,y:i}=e,{x:f,y:o}=s,{x:g,y:d}=a,t=Math.min(n,f),w=Math.min(i,o),M=Math.max(n,f),p=Math.max(i,o);return g>=t&&g<=M&&d>=w&&d<=p}function Oe(a,e,s,n,i){const f=e.sub(a),o=s.distanceTo(n)===0,g=s.x>n.x;i.forEach(d=>{if(d)if(g&&!o&&!(d instanceof q)&&!(d instanceof tt&&(d.startAngle===0&&d.endAngle===Math.PI*2||d.endAngle===0&&d.startAngle===Math.PI*2))){const t=d.getGripPoints();if(t.isEmpty())return;t.forEach((w,M)=>{if(ln(w,s,n)&&!(d instanceof ie&&M===2)&&!(d instanceof B&&M===2)){if(d instanceof V&&t.length()!==d.numVerts()){const p=d.numVerts();let l=0;for(let y=0;y<p;y++){if(d.getPointAt(y).val,d.getBulgeAt(y)!==0&&(l++,l===M))return;l++}}d.moveGripPointsAt(M,f.x,f.y,f.z)}})}else d.move(a,e)})}const Ve=He(0,"_stretch_offsetX"),_e=He(0,"_stretch_offsetY"),$e=He(0,"_stretch_offsetZ");async function dn(){const a=new et;let e=X.getCurrentSelect(),s,n;if(e.length<=0){if(!await a.userSelect(u("436")))return;e=a.getIds();const t=a.getSelectPoint();s=t.pt1,n=t.pt2}else{const{point1:t,point2:w}=X.getCurrentSelectPoints();s=t,n=w}const i=new j;i.setMessage(`
- `+u("437")),i.setKeyWords(`[${u("438")}(D)]`);const f=await i.go(),o=async t=>{if(!(typeof t>"u"&&(i.setMessage(`
- ${u("439")}<${Ve.value}, ${_e.value}, ${$e.value}>`),i.setKeyWords(""),i.clearLastInputPoint(),t=await i.go(),!t))){if(t){const{x:w,y:M,z:p}=t;Ve.value=w,_e.value=M,$e.value=p}else{if(Ve.value===0&&_e.value===0&&$e.value===0)return;t=new $(Ve.value,_e.value,$e.value)}Oe(new $,t,s,n,e.map(w=>w.getMcDbEntity()))}};if(i.isKeyWordPicked("D")||i.getStatus()===H.kNone)return await o();if(!f)return;i.setMessage(`
- ${u("440")}${u("387")}<${u("441")}>`),i.setBasePt(f),i.setKeyWords(""),i.setUserDraw((t,w)=>{const M=e.map(p=>p.clone());Oe(f,t,s,n,M),M.forEach((p,l)=>{const y=e[l]?.getMcDbEntity();if(y){const x=y.trueColor.getColorValue(y.layerId);w.setColor(Number(x))}w.drawMcDbEntity(p)})});let g=await i.go();if(i.getStatus()===H.kNone)return await o(f);if(!g)return;const d=e.map(t=>t.getMcDbEntity()).filter(t=>!!t);Oe(f,g,s,n,d)}F("_stretch",dn);class un{constructor(e){G(this,"resizeObserver",null);G(this,"mutationObserver",null);G(this,"element",null);this.callback=e}addListener(e){this.element=e,this.setupResizeObserver(),this.setupMutationObserver()}removeListener(){this.resizeObserver&&(this.resizeObserver.unobserve(this.element),this.resizeObserver.disconnect(),this.resizeObserver=null),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.element=null}setupResizeObserver(){typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(this.callback),this.resizeObserver.observe(this.element))}setupMutationObserver(){typeof MutationObserver<"u"&&(this.mutationObserver=new MutationObserver(this.callback),this.mutationObserver.observe(this.element,{attributes:!0}))}}function gn(a,e){const s=new un(e);return s.addListener(a),s}function fn(a){a.removeListener()}function wn(a,e){let s;return function(...n){clearTimeout(s),s=setTimeout(()=>a(...n),e)}}function hn(a,e,s){typeof e=="string"&&(e=parseFloat(e));const n=document.createElement("canvas"),i=n.getContext("2d");if(!i)return;i.font=e+"px "+s;let o=i.measureText(a).width,d=e*1.2;return n.remove(),o=Math.ceil(o),d=Math.ceil(d),{width:o,height:d}}function mn(a){const e=document.createElement("template");e.innerHTML=a.trim();const s=document.createElement("div");s.style.position="absolute",s.style.visibility="hidden",s.style.pointerEvents="none",s.appendChild(e.content.cloneNode(!0)),document.body.appendChild(s);let{width:n,height:i}=s.getBoundingClientRect();return n=Math.ceil(n)+5,i=Math.ceil(i),document.body.removeChild(s),{width:n,height:i}}function yn(a){let e={watermark_txt:u("442"),watermark_html:"",watermark_x:20,watermark_y:20,watermark_rows:200,watermark_cols:200,watermark_x_space:80,watermark_y_space:80,watermark_color:"#aaa",watermark_alpha:.4,watermark_fontsize:"15px",watermark_font:"微软雅黑",watermark_width:"auto",watermark_height:"auto",watermark_angle:15,watermark_className:"mx_mask_div"};e={...e,...a};const s=_.getCurrentMxCAD().mxdraw.getCanvas();let n=null,i=null,f;const o=()=>{document.querySelectorAll("."+e.watermark_className).forEach(w=>w.remove())},g=()=>{o(),f&&fn(f)},d=()=>{const t=document.createDocumentFragment(),w=s.parentElement,M=w.clientWidth,p=w.clientHeight;if(M===n&&p===i)return;n=M,i=p,o();const l=Math.max(w.scrollWidth,w.clientWidth),y=Math.max(w.scrollHeight,w.clientHeight);if(e.watermark_width==="auto"||e.watermark_height==="auto")if(e.watermark_html!==""){const{width:c,height:h}=mn(e.watermark_html);e.watermark_width==="auto"&&(e.watermark_width=c),e.watermark_height==="auto"&&(e.watermark_height=h)}else{const c=e.watermark_txt.length,h=parseFloat(e.watermark_fontsize)||16,{width:P=c*h,height:D=h+e.watermark_x_space+e.watermark_y_space}=hn(e.watermark_txt,e.watermark_fontsize,e.watermark_font)||{};e.watermark_width==="auto"&&(e.watermark_width=P),e.watermark_height==="auto"&&(e.watermark_height=D)}e.watermark_cols=Math.ceil(l/(e.watermark_x_space+e.watermark_width)),e.watermark_rows=Math.ceil(y/(e.watermark_y_space+e.watermark_height));let x,m;for(let c=0;c<e.watermark_rows;c++){m=e.watermark_y+(e.watermark_y_space+e.watermark_height)*c;for(let h=0;h<e.watermark_cols;h++){x=e.watermark_x+(e.watermark_width+e.watermark_x_space)*h;var r=document.createElement("div");r.id=(e.watermark_className||"")+c+h,r.className=e.watermark_className||"",e.watermark_html!==""?r.innerHTML=e.watermark_html:r.appendChild(document.createTextNode(e.watermark_txt)),r.style.webkitTransform="rotate(-"+e.watermark_angle+"deg)",r.style.MozTransform="rotate(-"+e.watermark_angle+"deg)",r.style.msTransform="rotate(-"+e.watermark_angle+"deg)",r.style.OTransform="rotate(-"+e.watermark_angle+"deg)",r.style.transform="rotate(-"+e.watermark_angle+"deg)",r.style.visibility="",r.style.position="absolute",r.style.left=x+"px",r.style.top=m+"px",r.style.overflow="hidden",r.style.zIndex="9999",r.style.pointerEvents="none",r.style.opacity=e.watermark_alpha.toString(),r.style.fontSize=e.watermark_fontsize,r.style.fontFamily=e.watermark_font,r.style.color=e.watermark_color,r.style.textAlign="center",r.style.width=e.watermark_width+"px",r.style.height=e.watermark_height+"px",r.style.display="block",t.appendChild(r)}}w.appendChild(t)};return d(),f=gn(s,wn(d,200)),g}F("_watermark",yn);async function xn(){const a=_.getCurrentMxCAD();for(;;){const e=new ae;e.setMessage(u("409"));const s=await e.go();if(e.getStatus()===H.kCancel||e.getStatus()===H.kNone)return;const n=s.getMcDbEntity();if(n instanceof ie||n instanceof q){const i=new j;i.setMessage(u("410"));const f=await i.go();if(i.getStatus()===H.kCancel||i.getStatus()===H.kNone)return;if(f){const o=n.center.clone(),g=f.sub(o).normalize().mult(n.radius),d=o.clone().addvec(g),t=o.clone().addvec(g.clone().negate()),w=Math.min(t.distanceTo(f),d.distanceTo(f));a.drawDimDiametric(d.x,d.y,t.x,t.y,w)}break}else{L.acutPrintf(u("411"));continue}}}F("_DrawDiametricDimension",xn);async function pn(){const a=_.getCurrentMxCAD();for(;;){const e=new ae;e.setMessage(u("选择圆弧或者圆"));const s=await e.go();if(e.getStatus()===H.kCancel||e.getStatus()===H.kNone)return;const n=s.getMcDbEntity();if(n instanceof ie||n instanceof q){const i=n.center.clone(),f=Z.kXAxis.clone().mult(n.radius),o=i.clone().addvec(f);a.drawDimDiametric(i.x,i.y,o.x,o.y,n.radius);break}else{L.acutPrintf(u("所选对象不是圆弧或圆"));continue}}}F("_DrawRadialDimension",pn);function ut(a){return new Promise(e=>{const{hideLoading:s,showLoading:n}=st();try{let i=Pe().info(u("502")+"...");const f=_.App.getCurrentMxCAD().openWebFile(a,o=>{o===0?(Pe().success(u("503")),e(!0)):(Pe().error(u("367")),e(!1)),s(),i()});nt(a).then(o=>{o/(1024*1024)>1&&f&&n()}),e(f)}catch{s(),e(!1)}})}function Pn(a){ut(a)}F("_openMxweb",Pn);let Ge=!1;kt(()=>{if(Ge)return;let a;const e=[],s=_.getCurrentMxCAD().mxdraw.getOrbitControls();s.addEventListener("change",()=>{clearTimeout(a),a=setTimeout(function(){const i=s.object.position.clone(),f=s.object.zoom,o=s.target.clone(),g=_.getCurrentMxCAD().mxdraw.getCamera();e.push({zoom:f,position:i,target:o,camera:g.clone(!1)})},500)});const n=i=>{if(!i)return!1;const f=_.getCurrentMxCAD().mxdraw,o=f.getOrbitControls(),g=o.object.position.clone(),d=o.object.zoom,t=o.target.clone(),w=_.getCurrentMxCAD().mxdraw.getCamera();return w.copy(i.camera,!1),w.updateProjectionMatrix(),d===i.zoom&&g.equals(i.position)&&t.equals(i.target)?n(e.pop()):(o.object.position.copy(i.position),o.object.zoom=i.zoom,o.target.copy(i.target),o.update(),f._mxdrawObj.mcObject.updateDisplayMatrixData(),!0)};F("Mx_WindowZoom",async()=>{let i=new j;i.setMessage(`
- `+u("453")),i.setKeyWords(`[${u("194")}(A)/${u("165")}(E)/${u("216")}(P)/${u("137")}(O)]`);let f=_.getCurrentMxCAD(),o=await i.go();if(i.isKeyWordPicked("A"))return f.mxdraw.zoomInitialStates();if(i.isKeyWordPicked("E"))return f.zoomAll(!0);if(i.isKeyWordPicked("P")){n(e.pop())||L.acutPrintf(`
- `+u("454")+`
- `+u("455"));return}if(i.isKeyWordPicked("O")){const d=await X.userSelect(`ZOOM ${u("134")}`);if(d.length<=0)return;const t=X.getMcDbEntitysBoundingBox(d);if(!t)return;const{minPt:w,maxPt:M}=t;return f.zoomW(w,M)}if(o==null)return;i.setUserDraw((d,t)=>{t.drawRect(je.cad2doc1(o),je.cad2doc1(d))}),i.setKeyWords("");let g=await i.go();g!=null&&f.zoomW(o,g)}),Ge=!0});class Me extends ce{constructor(){super(...arguments);G(this,"dDashArray",.03);G(this,"dDashRatio",.1);G(this,"isAligned",!1);G(this,"fixedSize",!0);G(this,"referenceAxis",new THREE.Vector3(0,1,1));G(this,"offsetHeight");G(this,"isDrawsMallRound",!0)}getTypeName(){return"MxAuxiliaryLine"}create(){return new Me}onViewChange(){return this.fixedSize?(this.setNeedUpdateDisplay(!1),!0):!1}worldDraw(s){const{dDashArray:n,dDashRatio:i}=this.getDash();let f=s.getMxObject();s.setLineWidth(.7),s.setDash(n,i);let o=this.toSmallcoord(f,this.pt1),g=this.toSmallcoord(f,this.pt2),d=o,t=g;typeof this.offsetHeight>"u"&&(this.offsetHeight=f.screenCoordLong2World(40));const w=this.offsetHeight;if(this.isAligned){o.x>g.x&&(o=this.pt2,g=this.pt1);const l=g.clone().sub(o).cross(this.referenceAxis.clone().normalize()).normalize();d=o.clone().add(l.clone().multiplyScalar(w)),t=g.clone().add(l.clone().multiplyScalar(w))}else{const l=Math.abs(this.referenceAxis.y?o.y-g.y:o.x-g.x)+w;let y=w,x=l;(this.referenceAxis.x!==0&&o.x>g.x||this.referenceAxis.y!==0&&o.y>g.y)&&(o=this.pt2,g=this.pt1),this.referenceAxis.x>0&&(y=l,x=w),this.referenceAxis.y>0&&(y=l,x=w),d=o.clone().add(this.referenceAxis.clone().multiplyScalar(y)),t=g.clone().add(this.referenceAxis.clone().multiplyScalar(x))}d.setZ(o.z),t.setZ(g.z);const M=ke.createDashedLines([o,d,t,g],8421504,.1,.1);if(s.drawEntity(M),this.isDrawsMallRound){const l=f.screenCoordLong2World(1);s.drawCircle(o,l),s.drawCircle(g,l),s.drawCircle(d,l),s.drawCircle(t,l)}const p=d.distanceTo(t).toFixed(3);if(s.getType()===it.kWorldDraw){const l=new ot;l.opacity=1,l.text=p,l.backgroundColor=16777185,l.color=16,l.position=new THREE.Vector3((d.x+t.x)/2,(d.y+t.y)/2),l.setFontSize(36),l.height=f.screenCoordLong2World(16),l.setLineWidthByPixels(!0),l.setUseSmallcoordDisplay(this.use_smallcoord_display),l.worldDraw(s)}else{const l=ke.creatTextSprite(p,new THREE.Vector3((d.x+t.x)/2,(d.y+t.y)/2),f.screenCoordLong2World(16),0,16777215);l&&s.drawEntity(l)}}getGripPoints(){return[this.pt1,this.pt2]}moveGripPointsAt(s,n){return s===0&&this.pt1.add(n),s===1&&this.pt2.add(n),!0}dwgIn(s){return super.dwgIn(s),this.dwgInHelp(s,["referenceAxis","isAligned","offsetHeight","fixedSize","isDrawsMallRound"]),!0}dwgOut(s){return s=super.dwgOut(s),this.dwgOutHelp(s,["referenceAxis","isAligned","offsetHeight","fixedSize","isDrawsMallRound"]),s}}class he extends Et{constructor(){super(...arguments);G(this,"dDashArray",.03);G(this,"dDashRatio",.1);G(this,"pt1");G(this,"pt2");G(this,"center");G(this,"fixedSize",!0);G(this,"offsetDist");G(this,"isClockwise","auto");G(this,"isDrawsMallRound",!0);G(this,"isMaxRadius",!1);G(this,"radius")}getTypeName(){return"MxAuxiliaryArc"}create(){return new he}onViewChange(){return this.fixedSize?(this.setNeedUpdateDisplay(!1),!0):!1}calculateLineAngle(s,n,i){const f=Math.PI*2/360;let o=Math.atan2(n.y-s.y,n.x-s.x)*180/Math.PI*f,g=Math.atan2(i.y-s.y,i.x-s.x)*180/Math.PI*f;return{startAngle:o,endAngle:g}}getClockwise(){const s=this.getStartPoint(),n=this.getEndPoint();let i=this.isClockwise;if(i==="auto"){const f=s.clone().sub(this.center),o=n.clone().sub(this.center);i=f.x*o.y-f.y*o.x<0}return i}getAngle(){const s=this.center,n=this.getStartPoint(),i=this.getEndPoint();let f=this.getClockwise();const{startAngle:o,endAngle:g}=this.calculateLineAngle(s,n,i);let d=g-o;return!f&&d<0?d+=2*Math.PI:f&&d>0&&(d-=2*Math.PI),Math.abs(d)}getRadius(s=!1){return this.radius?this.radius+(s&&this.offsetDist||0):this.isMaxRadius?Math.max(this.center.distanceTo(this.pt1),this.center.distanceTo(this.pt2)):this.center.distanceTo(this.pt2)+(s&&this.offsetDist||0)}getStartPoint(s=L.getCurrentDraw()){let n=this.pt1;this.pt2;let i=this.center,f=n;typeof this.offsetDist>"u"&&(this.offsetDist=s.screenCoordLong2World(40));const o=this.offsetDist,g=n.clone().sub(i).normalize(),d=this.getRadius()+o;return f=i.clone().add(g.multiplyScalar(d)),f.setZ(n.z),f}getEndPoint(s=L.getCurrentDraw()){let n=this.pt2,i=this.center,f=n;typeof this.offsetDist>"u"&&(this.offsetDist=s.screenCoordLong2World(40));const o=this.offsetDist,g=n.clone().sub(i).normalize(),d=this.getRadius()+o;return f=i.clone().add(g.multiplyScalar(d)),f.setZ(n.z),f}worldDraw(s){const{dDashArray:n,dDashRatio:i}=this.getDash();let f=s.getMxObject();s.setDash(n,i),s.setLineWidth(.7),this.toSmallcoord(f,this.pt2);let o=this.center;typeof this.offsetDist>"u"&&(this.offsetDist=f.screenCoordLong2World(40));const g=this.offsetDist,d=this.getStartPoint(),t=this.getEndPoint(),w=this.getRadius()+g,{startAngle:M,endAngle:p}=this.calculateLineAngle(o,d,t);let l=this.getClockwise();const y=new THREE.ArcCurve(o.x,o.y,w,M,p,l),x=new THREE.Geometry().setFromPoints(y.getPoints(50)),m=ke.createDashedLines([d,o,t],8421504,.1,.1);if(s.setColor(8421504),s.drawEntity(m),s.drawGeometryLines(x),this.isDrawsMallRound){const A=f.screenCoordLong2World(2);s.drawCircle(d,A),s.drawCircle(t,A)}const r=this.getAngle(),c=THREE.MathUtils.radToDeg(r).toFixed(3)+"°",{x:h,y:P}=y.getPointAt(.5),D=new THREE.Vector3(h,P);if(s.getType()===it.kWorldDraw){const A=new ot;A.opacity=1,A.text=c,A.backgroundColor=16777185,A.color=16,A.position=D,A.setFontSize(36),A.height=f.screenCoordLong2World(16),A.setLineWidthByPixels(!0),A.setUseSmallcoordDisplay(this.use_smallcoord_display),A.worldDraw(s)}else{const A=ke.creatTextSprite(c,D,f.screenCoordLong2World(16),0,16777215);A&&s.drawEntity(A)}}getGripPoints(){return[this.pt1,this.pt2,this.center]}moveGripPointsAt(s,n){return s===0&&this.pt1.add(n),s===1&&this.pt2.add(n),s===2&&this.center.add(n),!0}dwgIn(s){return this.dwgInHelp(s,["fixedSize","isDrawsMallRound","offsetDist","pt1","pt2","center","isClockwise","isMaxRadius","radius"]),!0}dwgOut(s){return this.dwgOutHelp(s,["fixedSize","isDrawsMallRound","offsetDist","pt1","pt2","center","isClockwise","isMaxRadius","radius"]),s}}function Le(a,e,s){if(a.isEqualTo(e))return 0;let n=a.c().addvec(e.c().sub(a).mult(.5)),i=e.c().sub(a);i.rotateBy(Math.PI/2,Z.kZAxis);let f=new B(n,n.c().addvec(i)),o=s.c();o.rotateBy(Math.PI/2,Z.kZAxis);let g=new B(a,a.c().addvec(o)),d=f.IntersectWith(g,De.Intersect.kExtendBoth);if(d.isEmpty())return 0;let t=d.at(0),w=t.distanceTo(a);i.normalize(),i.mult(w);let M=t.c().addvec(i),p=t.c().subvec(i),l=M.c().sub(a),y=p.c().sub(a),x=M;return l.angleTo1(s)>y.angleTo1(s)&&(x=p),X.calcBulge(a,x,e).val}const gt=async(a,e)=>{let s=!0;const n=new j;let i=!1;const f=l=>{l.key==="Control"&&(i=!0)},o=_.getCurrentMxCAD(),g=()=>i=!1;window.addEventListener("keydown",f),window.addEventListener("keyup",g);const d=()=>{window.removeEventListener("keydown",f),window.removeEventListener("keyup",g)};if(!a){n.clearLastInputPoint(),n.setMessage(u("456"));const l=await n.go();if(n.getDetailedResult()===v.kNewCommadIn)return d(),!1;if(!l)return d();a=l}const t=[{point:a}];for(;;)if(s){n.setMessage(u("457")),n.setKeyWords(`[${u("241")}(A)/${t.length>2?u("458")+"(C)/":""}${u("433")}(U)/${u("459")}(T)]`),n.setUserDraw((y,x)=>{const m=new V;t.forEach(({point:r,bulge:c})=>{m.addVertexAt(r,c)}),m.addVertexAt(y),x.drawMcDbEntity(m)});const l=await n.go();if(n.getDetailedResult()===v.kNullEnterIn||n.getDetailedResult()===v.kNullSpaceIn){const y=new V;t.forEach(({point:r,bulge:c})=>{y.addVertexAt(r,c)});const x=y.getLength().val,m=o.drawEntity(y);return e&&e(t),{dist:x,pl:y,plId:m}}if(n.getDetailedResult()===v.kNewCommadIn)return d(),!1;if(n.getStatus()===H.kCancel||n.getStatus()===H.kNone)return d();if(n.isKeyWordPicked("A")){s=!1;continue}else if(n.isKeyWordPicked("U")){t.length===0?L.acutPrintf(u("460")):(t.pop(),t[t.length-1]?.point&&n.setLastInputPoint(t[t.length-1].point),e&&e(t));continue}else if(n.isKeyWordPicked("T")){const y=new V;t.forEach(({point:r,bulge:c})=>{y.addVertexAt(r,c)});const x=y.getLength().val,m=o.drawEntity(y);return e&&e(t),{dist:x,pl:y,plId:m}}else if(n.isKeyWordPicked("C")){const y=new V;y.isClosed=!0,t.forEach(({point:r,bulge:c})=>{y.addVertexAt(r,c)});const x=y.getLength().val;e&&e(t);const m=o.drawEntity(y);return{dist:x,pl:y,plId:m}}else if(l){t.push({point:l}),e&&e(t);continue}}else{const l=n;l.setMessage(we("NO1_ID_ARX_PL5",`${u("461")}(${u("462")})`)),l.setKeyWords(`[${u("235")}(A)/${u("463")}(CE)/${t.length>2?u("458")+"(C)/":""}${u("176")}(D)/${u("238")}(L)/${u("234")}(R)/${u("464")}(S)/${u("433")}(U)]`);let y=new Z;if(t.length<2)y.copy(Z.kXAxis);else{let r=t.length,c=t[r-2].point,h=t[r-2].bulge,P=t[r-1].point;if(!h||Math.abs(h)<1e-7)y=new $(P.x,P.y,0).sub(new $(c.x,c.y,0));else{let D=new V;D.addVertexAt(c,h),D.addVertexAt(P);let A=D.getFirstDeriv(new $(P.x,P.y,0));A.ret?y=A.val:y.copy(Z.kXAxis)}}let x=t[t.length-1];l.setUserDraw((r,c)=>{let h=Le(x.point,r,i?y.clone().negate():y),P=new V;t.forEach(({point:D,bulge:A})=>{P.addVertexAt(D,A)}),P.addVertexAt(x.point,h),P.addVertexAt(r),c.drawMcDbEntity(P)});let m=await l.go();if(l.getDetailedResult()===v.kNullEnterIn||l.getDetailedResult()===v.kNullSpaceIn){const r=new V;t.forEach(({point:P,bulge:D})=>{r.addVertexAt(P,D)});const c=r.getLength().val,h=o.drawEntity(r);return e&&e(t),{dist:c,pl:r,plId:h}}if(m!==null){let r={point:m,bulge:0};t[t.length-1].bulge=Le(x.point,r.point,i?y.clone().negate():y),t.push(r),e&&e(t)}else if(l.getStatus()==H.kKeyWord){if(l.isKeyWordPicked("A")){const r=new le;r.setBasePt(x.point),r.setMessage(we("ID_ARX_PLGET_I_ANGLE",u("465")));const c=await r.go();if(r.getDetailedResult()===v.kNewCommadIn)return d(),!1;if(c===null)break;l.setMessage(`${u("461")}(${u("462")})`),l.setKeyWords(`[${u("463")}(CE)/${u("234")}(R)]`),l.setLastInputPoint(x.point);const h=t[t.length-1].point,P=b=>{const C=Math.PI/2-c/2,E=new $((b.x+h.x)/2,(b.y+h.y)/2),R=E.distanceTo(h),I=R/Math.sin(C),k=R/Math.tan(C),T=E.sub(h).rotateBy(Math.PI/2).normalize().mult(i?-I-k:I-k),S=E.addvec(T);return X.calcBulge(h,S,b).val};l.setUserDraw((b,C)=>{const E=P(b);let R=new V;t.forEach(({point:I,bulge:k})=>{R.addVertexAt(I,k)}),R.addVertexAt(x.point,E),R.addVertexAt(b),C.drawMcDbEntity(R)});const D=await l.go();if(l.isKeyWordPicked("CE")){l.setMessage(u("466")),l.setKeyWords(""),l.setBasePt(h),l.setUserDraw((I,k)=>{const T=I.distanceTo(h),S=I.addvec(I.sub(h).rotateBy(c).normalize().mult(T)),z=P(S);let O=new V;t.forEach(({point:W,bulge:K})=>{O.addVertexAt(W,K)}),O.addVertexAt(x.point,z),O.addVertexAt(S),k.drawMcDbEntity(O)});const b=await l.go();if(l.getDetailedResult()===v.kNewCommadIn)return d(),!1;if(!b)break;const C=b.distanceTo(h),E=b.addvec(b.sub(h).rotateBy(c).normalize().mult(C));let R={};R.bulge=0,R.point=E,t[t.length-1].bulge=P(E),t.push(R),l.setLastInputPoint(E),e&&e(t);continue}if(l.isKeyWordPicked("R")){const b=new Te;b.setMessage(u("467")),b.setKeyWords("");const C=await b.go();if(b.getDetailedResult()===v.kNewCommadIn)return d(),!1;if(typeof C!="number")break;const E=C*Math.sin(c/2);l.setBasePt(h),l.setMessage(`${u("468")}(${u("469")})`),l.setKeyWords(""),l.setUserDraw((T,S)=>{const z=h.clone().addvec(T.sub(h).normalize().mult(E*2)),O=P(z);let W=new V;t.forEach(({point:K,bulge:U})=>{W.addVertexAt(K,U)}),W.addVertexAt(x.point,O),W.addVertexAt(z),S.drawMcDbEntity(W)});const R=await l.go();if(l.getDetailedResult()===v.kNewCommadIn)return d(),!1;if(!R)break;const I=h.clone().addvec(R.sub(h).normalize().mult(E*2));let k={};k.bulge=0,k.point=I,t[t.length-1].bulge=P(I),t.push(k),e&&e(t);continue}if(!D)break;let A={};A.bulge=0,A.point=D,t[t.length-1].bulge=P(D),t.push(A),e&&e(t)}if(l.isKeyWordPicked("CE")){l.setMessage(u("466")),l.setKeyWords(""),l.setUserDraw(()=>{});const r=await l.go();if(l.getDetailedResult()===v.kNewCommadIn)return d(),!1;if(!r)return d();const c=x.point,h=r.distanceTo(c);l.setLastInputPoint(c),l.setMessage(`${u("461")}(${u("462")})`),l.setKeyWords(`[${u("235")}(A)/${u("470")}(L)]`),l.clearLastInputPoint(),l.setUserDraw((k,T)=>{T.drawLine(k.toVector3(),r.toVector3());const S=r.clone().addvec(k.sub(r).normalize().mult(h)),z=r.sub(c).angleTo2(r.sub(S),Z.kZAxis),O=new $((c.x+S.x)/2,(c.y+S.y)/2),W=r.sub(O).normalize().mult(-h),K=r.clone().addvec((i?z<Math.PI:z>Math.PI)?W.negate():W),U=X.calcBulge(c,K,S).val;let Y=new V;t.forEach(({point:J,bulge:te})=>{Y.addVertexAt(J,te)}),Y.addVertexAt(x.point,U),Y.addVertexAt(S),T.drawMcDbEntity(Y)});const P=await l.go();if(l.isKeyWordPicked("A")){const k=new le;k.setBasePt(r),k.setMessage(we("ID_ARX_PLGET_I_ANGLE",`${u("465")}(${u("462")})`)),k.setKeyWords(""),k.setUserDraw((J,te)=>{const ne=Z.kXAxis.clone().angleTo2(J.sub(r),Z.kZAxis),se=i?Math.PI*2-ne/2:ne/2,ue=c.sub(r).rotateBy(se).normalize().mult(h),ge=c.sub(r).rotateBy(ne).normalize().mult(h),oe=r.clone().addvec(ue),Q=r.clone().addvec(ge),fe=X.calcBulge(c,oe,Q).val;let re=new V;t.forEach(({point:Fe,bulge:xe})=>{re.addVertexAt(Fe,xe)}),re.addVertexAt(x.point,fe),re.addVertexAt(Q),te.drawMcDbEntity(re)});const T=await k.go();if(k.getDetailedResult()===v.kNewCommadIn)return d(),!1;if(T===null)break;const S=i?Math.PI*2-T/2:T/2,z=c.sub(r).rotateBy(S).normalize().mult(h),O=c.sub(r).rotateBy(T).normalize().mult(h),W=r.clone().addvec(z),K=r.clone().addvec(O),U=X.calcBulge(c,W,K).val;let Y={};Y.bulge=0,Y.point=K,t[t.length-1].bulge=U,t.push(Y),new V,e&&e(t);continue}if(l.isKeyWordPicked("L")){const k=new Te;k.setMessage(`${u("471")}(${u("462")})`),k.setKeyWords(""),k.setBasePt(c),k.setUserDraw((Y,J)=>{const te=Y.distanceTo(c);if(te>h*2)return;const ne=Math.asin(te/2/h)*2,se=c.sub(r).normalize().mult(h),ue=r.clone().addvec(se.clone().rotateBy(i?Math.PI-ne/2:ne/2)),ge=r.clone().addvec(se.clone().rotateBy(ne)),oe=X.calcBulge(c,ue,ge).val;let Q=new V;t.forEach(({point:fe,bulge:re})=>{Q.addVertexAt(fe,re)}),Q.addVertexAt(x.point,oe),Q.addVertexAt(ge),J.drawMcDbEntity(Q)});const T=await k.go();if(k.getDetailedResult()===v.kNewCommadIn)return d(),!1;if(typeof T!="number")break;if(T>h*2){L.acutPrintf(`*${u("472")} ${u("473")}*`),l.setLastInputPoint(c);continue}const S=Math.asin(T/2/h)*2,z=c.sub(r).normalize().mult(h),O=r.clone().addvec(z.clone().rotateBy(i?Math.PI-S/2:S/2)),W=r.clone().addvec(z.clone().rotateBy(S)),K=X.calcBulge(c,O,W).val;let U={};U.bulge=0,U.point=W,t[t.length-1].bulge=K,t.push(U),l.setLastInputPoint(W),e&&e(t);continue}if(l.getDetailedResult()===v.kNewCommadIn)return d(),!1;if(!P)return d();const D=r.clone().addvec(P.sub(r).normalize().mult(h)),A=r.sub(c).angleTo2(r.sub(D),Z.kZAxis),b=new $((c.x+D.x)/2,(c.y+D.y)/2),C=r.sub(b).normalize().mult(-h),E=r.clone().addvec((i?A<Math.PI:A>Math.PI)?C.negate():C),R=X.calcBulge(c,E,D).val;let I={};I.bulge=0,I.point=D,t[t.length-1].bulge=R,t.push(I),l.setLastInputPoint(D),e&&e(t);continue}if(l.isKeyWordPicked("R")){let r=new Te;r.setMessage(we("ID_ARX_PLGETSTARTRADIUS",u("474"))),r.setKeyWords("");let c=await r.go();if(r.getDetailedResult()===v.kNewCommadIn)return d(),!1;if(c===null)break;const h=x.point;l.setLastInputPoint(h),l.setMessage(`${u("461")}(${u("462")})`),l.setKeyWords(`[${u("235")}(A)]`),l.setUserDraw((I,k)=>{if(!c)return;const T=I.distanceTo(h);if(T>c*2)return;const S=Math.acos(T/2/c),z=h.clone().addvec(I.sub(h).rotateBy(S).normalize().mult(c)),O=z.clone().addvec(new $((h.x+I.x)/2,(h.y+I.y)/2).sub(z).normalize().mult(i?-c:c)),W=X.calcBulge(h,O,I).val;let K=new V;t.forEach(({point:U,bulge:Y})=>{K.addVertexAt(U,Y)}),K.addVertexAt(x.point,W),K.addVertexAt(I),k.drawMcDbEntity(K)});const P=await l.go();if(l.isKeyWordPicked("A")){const I=new le;I.setMessage(we("ID_ARX_PLGET_I_ANGLE",u("465"))),I.setKeyWords(""),I.setBasePt(h);const k=await I.go();if(I.getDetailedResult()===v.kNewCommadIn)return d(),!1;if(typeof k!="number")break;const T=Math.sin(k/2)*c*2;l.setMessage(`${u("468")}(${u("462")})`),l.setKeyWords(""),l.setBasePt(h),l.setUserDraw((J,te)=>{if(!c)return;const ne=J.sub(h).normalize(),se=h.clone().addvec(ne.clone().mult(T)),ue=se.clone().addvec(ne.clone().negate().rotateBy(-(Math.PI/2-k/2)).mult(c)),ge=ue.clone().addvec(ue.sub(new $((h.x+se.x)/2,(h.y+se.y)/2)).normalize().mult(i?c:-c)),oe=X.calcBulge(h,ge,se).val;let Q=new V;t.forEach(({point:fe,bulge:re})=>{Q.addVertexAt(fe,re)}),Q.addVertexAt(x.point,oe),Q.addVertexAt(se),te.drawMcDbEntity(Q)});const S=await l.go();if(l.getDetailedResult()===v.kNewCommadIn)return d(),!1;if(!S)break;const z=S.sub(h).normalize(),O=h.clone().addvec(z.clone().mult(T)),W=O.clone().addvec(z.clone().negate().rotateBy(-(Math.PI/2-k/2)).mult(c)),K=W.clone().addvec(W.sub(new $((h.x+O.x)/2,(h.y+O.y)/2)).normalize().mult(i?c:-c)),U=X.calcBulge(h,K,O).val;let Y={};Y.bulge=0,Y.point=O,t[t.length-1].bulge=U,t.push(Y),e&&e(t);continue}if(l.getDetailedResult()===v.kNewCommadIn)return d(),!1;if(!P)break;const D=P.distanceTo(h);if(D>c*2){L.acutPrintf(`${u("461")} *${u("473")}*`);continue}const A=Math.acos(D/2/c),b=h.clone().addvec(P.sub(h).rotateBy(A).normalize().mult(c)),C=b.clone().addvec(new $((h.x+P.x)/2,(h.y+P.y)/2).sub(b).normalize().mult(i?-c:c)),E=X.calcBulge(h,C,P).val;let R={};R.bulge=0,R.point=P,t[t.length-1].bulge=E,t.push(R),e&&e(t);continue}if(l.isKeyWordPicked("D")){l.setMessage(u("475")),l.setKeyWords(""),l.setUserDraw((D,A)=>{A.drawLine(D.toVector3(),x.point.toVector3())});const r=await l.go();if(l.getDetailedResult()===v.kNewCommadIn)return d(),!1;if(!r)break;const c=r.sub(x.point);l.setLastInputPoint(x.point),l.setMessage(`${u("461")}(${u("462")})`),l.setKeyWords(""),l.setUserDraw((D,A)=>{let b=Le(x.point,D,i?c.clone().negate():c),C=new V;t.forEach(({point:E,bulge:R})=>{C.addVertexAt(E,R)}),C.addVertexAt(x.point,b),C.addVertexAt(D),A.drawMcDbEntity(C)});const h=await l.go();if(l.getDetailedResult()===v.kNewCommadIn)return d(),!1;let P={};P.bulge=0,P.point=h,t[t.length-1].bulge=Le(x.point,P.point,i?c.clone().negate():c),t.push(P),e&&e(t);continue}if(l.isKeyWordPicked("L"))s=!0;else if(l.isKeyWordPicked("S")){let r=new $(t[t.length-1].point.x,t[t.length-1].point.y,0),c=new j;c.setMessage(we("NO1_ID_SPECIFY_ARC2",u("84"))),c.setBasePt(r);let h=await c.go();if(c.getDetailedResult()===v.kNewCommadIn)return d(),!1;if(h===null)break;let P=new j;P.setMessage(we("ID_CIRCULAR_ENDPOINT",`${u("461")}(${u("462")})`)),P.setUserDraw((A,b)=>{const C=new ie;C.computeArc(r.x,r.y,h.x,h.y,A.x,A.y);let E=h;i&&(E=C.center.clone().addvec(C.center.clone().sub(h)));let R=X.calcBulge(r,E,A).val;const I=new V;t.forEach(({point:k,bulge:T})=>{I.addVertexAt(k,T)}),I.addVertexAt(x.point,R),I.addVertexAt(A),b.drawMcDbEntity(I)});let D=await P.go();if(D!==null){let A=h;if(i){const C=new ie;C.computeArc(r.x,r.y,h.x,h.y,D.x,D.y),A=C.center.clone().addvec(C.center.clone().sub(h))}let b=X.calcBulge(r,A,D);if(b.ret){let C={};C.point=D,C.dBluge=0,t[t.length-1].bulge=b.val,t.push(C),e&&e(t)}else L.acutPrintf(we("ID_ENDPOINT_INVALID1",`
- ${u("476")} *${u("473")}*`))}else{if(P.getDetailedResult()===v.kNewCommadIn)return d(),!1;break}}else if(l.isKeyWordPicked("C")){t[t.length-1].bulge=Le(x.point,a,i?y.clone().negate():y);const r=new V;r.isClosed=!0,t.forEach(({point:P,bulge:D})=>{r.addVertexAt(P,D)});const c=r.getLength().val;e&&e(t);const h=o.drawEntity(r);return{dist:c,pl:r,plId:h}}else if(l.isKeyWordPicked("U")&&t.length>1){t.pop();const r=new V;t.forEach(({point:c,bulge:h})=>{r.addVertexAt(c,h)}),e&&e(t),t.length>0&&l.setLastInputPoint(t[t.length-1].point)}}else{if(l.getDetailedResult()===v.kNewCommadIn)return d(),!1;break}}const w=new V;t.forEach(({point:l,bulge:y})=>{w.addVertexAt(l,y)});const M=w.getLength().val;e&&e(t);const p=o.drawEntity(w);return{dist:M,pl:w,plId:p}};function Ze(a,e){const s=e.x,n=e.y;return a.x>s&&a.y>n||a.x<s&&a.y<n}function Dn(a,e){const s=(a.x+e.x)/2,n=(a.y+e.y)/2;return new $(s,n)}function Mn(a,e,s){const n=Ze(a,s),i=Ze(e,s);return n&&i}async function ft(a=!1){const e=new j;let s=[];e.clearLastInputPoint(),e.setMessage(u("456"));const n=await e.go();if(e.getDetailedResult()===v.kNewCommadIn)return!1;if(!n)return;e.setUserDraw((f,o)=>{o.drawLine(n.toVector3(),f.toVector3())}),e.setMessage(u("494")),e.setKeyWords(`[${u("495")}(M)]`);const i=await e.go();if(e.getDetailedResult()===v.kNewCommadIn)return!1;if(e.getStatus()!==H.kCancel){if(e.isKeyWordPicked("M")){const f=await gt(n,d=>{const t=new V;d.forEach(({point:w,bulge:M})=>{t.addVertexAt(w,M)}),L.acutPrintf(u("233")+" = "+t.getLength().val)});if(f===!1)return f;const{plId:o}=f||{};if(!o)return;const g=o.getMcDbEntity();return g&&s.push(g),{markedLines:s}}else if(i){if(a){const p=Mn(n,i,Dn(n,i)),l=new Me;if(l.referenceAxis=new THREE.Vector3(0,0,p?-1:1),l.isAligned=!0,l.pt1=n.toVector3(),l.pt2=i.toVector3(),L.addToCurrentSpace(l),s.push(l),Math.abs(n.x-i.x)>.001&&Math.abs(n.y-i.y)>.001){const x=new Me;x.isAligned=!1,x.referenceAxis=new THREE.Vector3(0,n.y>i.y?1:-1,-1),x.pt1=n.toVector3(),x.pt2=i.toVector3(),L.addToCurrentSpace(x),s.push(x);const m=new Me;m.isAligned=!1,m.referenceAxis=new THREE.Vector3(n.x>i.x?1:-1,0,-1),m.pt1=n.toVector3(),m.pt2=i.toVector3(),L.addToCurrentSpace(m),s.push(m);const r=new he;r.offsetDist=0,r.center=n.toVector3(),r.pt1=n.toVector3().add(new THREE.Vector3(1,0,0)),r.pt2=i.toVector3(),L.addToCurrentSpace(r),s.push(r)}const y=new ce;y.pt1=n.toVector3(),y.pt2=i.toVector3(),L.addToCurrentSpace(y),s.push(y)}const f=n.distanceTo(i);let o=i.x-n.x,g=i.y-n.y,d=i.z-n.z,t=Math.atan2(g,o)*(180/Math.PI),w=Math.sqrt(o*o+g*g+d*d),M=w===0?0:Math.asin(d/w)*(180/Math.PI);return L.acutPrintf(`${u("233")} = ${Ae(f,4)} , XY ${u("496")} = ${Ae(t,4)} , ${u("497")} XY ${u("498")} = ${Ae(M,4)}
- X 增量 = ${Ae(o,4)}, Y 增量 = ${Ae(g,4)}, Z 增量 = ${Ae(d,4)}`),{dist:f,angleInDegrees:t,angleWithZAxis:M,deltaX:o,deltaY:g,deltaZ:d,markedLines:s}}}}F("_MxMeasurementDistance",ft);async function bn(a=!1){for(;;){const e=new ae,s=new de;s.AddMcDbEntityTypes("CIRCLE,ARC"),e.setFilter(s),e.setMessage(u("489"));const n=await e.go();if(e.getDetailedResult()===v.kCodeAbort||e.getDetailedResult()===v.kEcsIn||e.getDetailedResult()===v.kMouseRightIn)return;if(e.getDetailedResult()===v.kNewCommadIn)return!1;if(e.getDetailedResult()===v.kNullSpaceIn||e.getDetailedResult()===v.kNullEnterIn||!n)return;const i=n.getMcDbEntity();if(i instanceof ie||i instanceof q){const f=[];if(a){const{val:o,ret:g}=i.getClosestPointTo(e.getDocPickPoint(),!1);if(!g||!o)return;const d=i.center,t=new Me;t.pt1=o.toVector3(),t.pt2=d.toVector3(),t.isAligned=!0,t.offsetHeight=0,L.addToCurrentSpace(t),f.push(t)}return L.acutPrintf(u("234")+" = "+i.radius+`
- `+u("490")+" = "+i.radius*2+`
- `),{radius:i.radius,markedLines:f}}}}function Ne(a,e,s,n){const i=Ee(n,a,s),f=Ee(n,e,s);return isNaN(f)?!0:isNaN(i)?!1:f===i?s.distanceTo(a)>s.distanceTo(e):i<f}async function An(){const a=new ae,e=new de;for(e.AddMcDbEntityTypes("CIRCLE,ARC,LINE,LWPOLYLINE");;){a.setFilter(e),a.setMessage(`${u("167")}${u("241")}、${u("201")}、${u("238")}<${u("388")}>`);const s=await a.go(),n=a.getDetailedResult(),i=[];if(a.getDetailedResult()===v.kNewCommadIn||a.getDetailedResult()===v.kCodeAbort)return!1;if(a.getDetailedResult()===v.kEcsIn)return;if(n===v.kNullEnterIn||n===v.kNullSpaceIn||n===v.kMouseRightIn){const o=new vt,g=new he;o.setMessage(`
- ${u("478")}`);const d=await o.go();if(!d)return;g.center=d,o.setMessage("\n${t('390')}"),o.setUserDraw((x,m)=>{m.drawLine(x,d)});const t=await o.go();if(!t)return;g.pt1=t,o.setMessage(`
- ${u("391")}:`),o.setUserDraw((x,m)=>{m.drawLine(x,d),m.drawLine(t,d),g.offsetDist=0,g.pt2=x,m.drawCustomEntity(g)});const w=await o.go();if(!w)return;g.pt2=w;let M=d.distanceTo(t)-d.distanceTo(w);g.offsetDist=M<0?0:M/2;const p=new ce;p.pt1=d,p.pt2=t;const l=new ce;l.pt1=d,l.pt2=w,L.addToCurrentSpace(p),L.addToCurrentSpace(l),L.addToCurrentSpace(g);const y=g.getAngle();return L.acutPrintf(u("235")+" = "+y+"°"),i.push(g,p,l),{angle:y,markedArcs:i}}if(!s)continue;const f=s.getMcDbEntity();if(f){if(f instanceof B||f instanceof V){let o,g,d,t;const w=a.getDocPickPoint();let M;if(f instanceof V){const{start:A,end:b}=Re(f,w,2)||{};o=A,g=b}else o=f.startPoint,g=f.endPoint;if(!o||!g)continue;for(;;){const A=new de;A.AddMcDbEntityTypes("LINE,LWPOLYLINE"),a.setFilter(A),a.setMessage(u("392"));const b=await a.go();if(M=a.getDocPickPoint(),a.getDetailedResult()===v.kNewCommadIn||a.getDetailedResult()===v.kCodeAbort)return!1;if(a.getDetailedResult()===v.kEcsIn)return;if(!b||!b.isValid())continue;let C=b.getMcDbEntity();if(C instanceof V){const{start:E,end:R}=Re(C,M,2)||{};d=E,t=R}else C instanceof B&&(d=C.startPoint,t=C.endPoint);if(d&&t)break}const p=new B(o,g).IntersectWith(new B(d,t),De.Intersect.kExtendBoth);if(p.isEmpty()){L.acutPrintf(u("479"));return}if(!o||!g||!d||!t||!M)continue;const l=p.at(0),x=Ne(o,g,l,w)?o:g,r=Ne(d,t,l,w)?d:t,c=new he;c.center=l.toVector3(),c.pt1=x.toVector3(),c.pt2=r.toVector3(),c.isMaxRadius=!0,c.offsetDist=0,L.addToCurrentSpace(c);const h=c.getAngle();L.acutPrintf(u("235")+" = "+h+"°"),i.push(c);const P=new ce;P.pt1=c.pt1,P.pt2=c.center;const D=new ce;return D.pt1=c.center,D.pt2=c.pt2,L.addToCurrentSpace(P),L.addToCurrentSpace(D),i.push(P,D),{angle:h,markedArcs:i}}if(f instanceof ie){const o=new he;o.offsetDist=f.radius,o.center=f.center.toVector3(),o.pt1=new THREE.Vector3(f.radius),o.pt1.applyAxisAngle(new THREE.Vector3(0,0,1),f.startAngle).add(f.center.toVector3()),o.pt2=new THREE.Vector3(f.radius),o.pt2.applyAxisAngle(new THREE.Vector3(0,0,1),f.endAngle).add(f.center.toVector3());let g=f.endAngle-f.startAngle;g>Math.PI?g-=Math.PI*2:g<-Math.PI&&(g+=Math.PI*2),o.isClockwise=Math.abs(g)>Math.PI&&g>0,L.addToCurrentSpace(o);const d=o.getAngle();L.acutPrintf(u("235")+" = "+d+"°"),i.push(o);const t=new ce;t.pt1=o.pt1,t.pt2=o.center;const w=new ce;return w.pt1=o.center,w.pt2=o.pt2,L.addToCurrentSpace(t),L.addToCurrentSpace(w),i.push(t,w),{angle:d,markedArcs:i}}if(f instanceof q){const o=new he;o.center=f.center.toVector3(),o.pt1=a.getDocPickPoint().toVector3();const g=new j;g.setUserDraw((w,M)=>{o.pt2=w.toVector3(),o.offsetDist=0,M.drawCustomEntity(o)}),g.setMessage(u("480"));const d=await g.go();if(g.getDetailedResult()===v.kNewCommadIn)return!1;if(!d)return;o.pt2=d.toVector3(),o.offsetDist=f.radius,L.addToCurrentSpace(o);const t=o.getAngle();return L.acutPrintf(u("235")+" = "+t+"°"),i.push(o),{angle:t,markedArcs:i}}}}}const wt=a=>{const e=a.numVerts(),s=[];if(e<3)return s;const n=_.getCurrentMxCAD(),i=a.getPointAt(0).val,f=a.getPointAt(e-1).val;if(!a.isClosed&&!i.isEqualTo(f))return s;n.pathMoveTo(i.x,i.y);for(let d=0;d<e;d++){const t=a.getPointAt(d).val,w=a.getBulgeAt(d),{val1:M,val2:p}=a.getWidthsAt(d);n.pathLineToEx(t.x,t.y,M,p,w)}n.pathLineTo(f.x,f.y);const g=n.drawPathToHatch().getMcDbEntity();return g&&s.push(g),s},Cn=async a=>{const e=_.getCurrentMxCAD();if(a instanceof V)return wt(a);if(a instanceof q){e.pathMoveTo(a.center.x,a.center.y),e.pathCircle(a.center.x,a.center.y,a.radius);const n=e.drawPathToHatch().getMcDbEntity();if(n)return[n]}else{const s=a.clone(),{minPt:n,maxPt:i}=e.getDatabase().currentSpace.getBoundingBox(),f=n.clone(),o=i.clone();s.move(f,o);const g=s.getBoundingBox(),d=new $((g.minPt.x+g.maxPt.x)/2,(g.minPt.y+g.maxPt.y)/2),t=e.drawEntity(s);await(async()=>new Promise(M=>setTimeout(M,1)))();const w=X.builderHatchFromPoint(d);if(t.erase(),s.erase(),w){w.move(o,f);const p=e.drawEntity(w).getMcDbEntity();if(p)return[p]}}},kn=async()=>{const a=new j;let e=[],s=!1,n=!1,i=0;for(;;){a.setMessage((s?`(${u("481")})`:"")+(n?`(${u("482")})`:"")+`${u("417")}<${u("137")}>`),a.setKeyWords(`[${u("137")}(O)/${s?"":u("483")+"(A)/"}${n?"":u("484")+"(S)/"}${u("485")}(X)]`),await(async()=>new Promise(o=>setTimeout(o,1)))();const f=await a.go();if(a.getDetailedResult()===v.kNewCommadIn)return e.length>0?{markedLines:e}:!1;if(a.getDetailedResult()===v.kCodeAbort)return e.length>0?{markedLines:e}:!1;if(a.getDetailedResult()===v.kEcsIn||a.getDetailedResult()===v.kMouseRightIn)return e.length>0?{markedLines:e}:void 0;if(a.isKeyWordPicked("O")||a.getDetailedResult()===v.kNullEnterIn||a.getDetailedResult()===v.kNullSpaceIn)for(;;){const o=new ae;o.setMessage(u("134")),await(async()=>new Promise(p=>setTimeout(p,1)))();const g=await o.go();if(o.getDetailedResult()===v.kNewCommadIn)return e.length>0?{markedLines:e}:!1;if(o.getDetailedResult()===v.kCodeAbort)return e.length>0?{markedLines:e}:!1;if(o.getDetailedResult()===v.kEcsIn)return e.length>0?{markedLines:e}:!1;if(o.getDetailedResult()===v.kNullEnterIn||o.getDetailedResult()===v.kNullSpaceIn||o.getDetailedResult()===v.kMouseRightIn)break;if(!g)continue;const d=g.getMcDbEntity();if(!d)continue;let t=d.getArea().val,w=0;d instanceof Be&&(w=d.getLength().val);const M=await Cn(d);if(M&&e.push(...M),t===0&&M)if(d instanceof q)t=Math.PI*Math.pow(d.radius,2);else if(d instanceof tt&&d.startAngle===0&&d.endAngle===Math.PI*2){const p=Math.sqrt(d.majorAxis.x*d.majorAxis.x+d.majorAxis.y*d.majorAxis.y)/2,l=p*d.radiusRatio;t=Math.PI*p*l;const y=Math.pow((p-l)/(p+l),2);w=Math.PI*(p+l)*(1+3*y/(10+Math.sqrt(4-3*y)))}else t=M.reduce((p,l)=>p+l.getArea().val,0);if(t===0?L.acutPrintf(u("486")+`
- `):L.acutPrintf(`${u("163")} = ${t}, ${u("487")} = ${w}
- `),s||n){s?i+=t:i-=t,L.acutPrintf(`${u("488")} = ${i}
- `);continue}return{markedLines:e}}if(a.isKeyWordPicked("A")){s=!0,n=!1;continue}if(a.isKeyWordPicked("S")){n=!0,s=!1;continue}if(a.isKeyWordPicked("X"))return L.acutPrintf(`${u("488")} = ${i}
- `),e.length>0?{markedLines:e}:void 0;if(f){const o=await gt(f);if(o===!1)return e.length>0?{markedLines:e}:o;const{plId:g}=o||{};if(!g)return e.length>0?{markedLines:e}:void 0;const d=g.getMcDbEntity();if(d instanceof V){d.isClosed=!0,e.push(d);const t=wt(d);e.push(...t);const w=d.getArea().val;if(L.acutPrintf(`${u("163")} = ${d.getArea().val}, ${u("487")} = ${d.getLength().val}
- `),s||n){s?i+=w:i-=w,L.acutPrintf(`${u("488")} = ${i}
- `);continue}return{markedLines:e}}}}};class En extends ce{getTypeName(){return"MxSelectLine"}worldDraw(e){e.setLineWidthByPixels(!0),e.setLineWidth(10),e.setColor(16737894),e.drawSelectLine(this.pt1,this.pt2)}}function vn(a,e,s){const i=a.distanceTo(e)/2,f=i*s,o=(i*i+f*f)/(2*f),g=(a.x+e.x)/2,d=(a.y+e.y)/2;return new $(g,d).addvec(e.clone().sub(a).perpVector().normalize().mult(o-f))}F("_MEASUREGEOM",async()=>{let a,e,s=u("491"),n=[];const i=()=>{n.forEach(f=>{f.erase()})};try{for(;;){let f=function(r,c,h){const P=c.clone().sub(r),D=h.clone().sub(r),A=P.length(),b=P.clone().add(D).normalize();return r.clone().add(b.multiplyScalar(A))};const o=new j;o.setCursorType(It.kCross),o.disableAllTrace(),o.setDisableDynInput(!0),o.clearLastInputPoint(),o.setMessage(s);const g=`[${u("233")}(D)/${u("234")}(R)/${u("235")}(A)/${u("236")}(AR)/${u("492")}(Q)/${u("493")}(M)/${u("485")}(X)]`;o.setKeyWords(g);const d=_.getCurrentMxCAD(),t=new et,w=new de([Lt.kEntityType,"LINE,ARC,CIRCLE,LWPOLYLINE,INSERT"]),M=(r,c,h)=>{let P,D,A;for(let b=0;b<r.length;b++){let E=r[b].getMcDbEntity();if(!E)continue;if(E instanceof Tt){const T=E.blockTableRecordId.getMcDbBlockTableRecord();if(!T)continue;return M(T.getAllEntityId(),c.clone(),h.clone())}if(!(E instanceof Be))continue;const R=E.IntersectWith(new B(c,h),De.Intersect.kOnBothOperands);if(E instanceof V&&E.isClosed){const T=E.numVerts()-1,S=E.getPointAt(0).val,z=E.getPointAt(T).val,O=new B(S,z).IntersectWith(new B(c,h),De.Intersect.kOnBothOperands);if(!O.isEmpty()){const W=O.at(0),K=W.distanceTo(c);(typeof P>"u"||K<P)&&(D=E,P=K,A=W)}}if(R.isEmpty())continue;let I,k;R.forEach(T=>{const S=T.distanceTo(c);(typeof k>"u"||S<k)&&(k=S,I=T)}),(typeof P>"u"||k<P)&&(D=E,P=k,A=I)}if(D)return{minDistEnt:D,minDist:P,intersectPt:A}},p=(r,c)=>(t.crossingSelect(r.x,r.y,c.x,c.y,w),t.isNull()?void 0:M(t.getIds(),r,c)),l=(r,c,h,P)=>{const D=c.clone().addvec(h.clone().mult(L.viewCoordLong2Cad(16))),A=ke.createDashedLines([c.toVector3(),D.toVector3()],8421504,.1,.1),b=c.clone().addvec(h.clone().mult(L.viewCoordLong2Cad(28)));r.drawEntity(A),r.drawText(P,L.viewCoordLong2Cad(16),0,b.toVector3())},y=(r,c,h,P,D)=>{let A;if(c instanceof V||c instanceof B){let b,C;if(c instanceof B&&(b=c.startPoint,C=c.endPoint),c instanceof V){const E=Re(c,D,10);if(!E)return;const R=c.getBulgeAt(E.startIndex);if(R===0)b=E.start,C=E.end;else{const I=c.getParamAtPoint(E.start).val,k=c.getParamAtPoint(E.end).val,T=c.getDistAtParam(I).val,S=c.getDistAtParam(k).val,z=vn(E.start,E.end,R);r.drawCircle(E.end.toVector3(),5);const{x:O,y:W}=f(z.toVector3(),E.start.toVector3(),E.end.toVector3()),K=new $(O,W);let U=K.clone().sub(z).normalize();const Y=z.distanceTo(K);Math.abs(R)>1&&(K.addvec(z.clone().sub(K).normalize().mult(Y*2)),U.negate()),l(r,K,U,Math.abs(S-T).toFixed(3))}}if(b&&C){const E=new En;E.pt1=b.toVector3(),E.pt2=C.toVector3(),r.drawCustomEntity(E);const R=new Me;R.pt1=b.toVector3(),R.pt2=C.toVector3(),R.isAligned=!0,A=(k=P.x>h.x||P.y<h.y)=>{R.referenceAxis=new THREE.Vector3(0,0,k?1:-1),r.drawCustomEntity(R)};const I=new B(b,C);return{draw:A,line:I}}}if(c instanceof q){const b=new Z(-1,0,0),C=c.center.clone().addvec(b.clone().mult(c.radius));l(r,C,b,c.getLength().val.toFixed(3))}if(c instanceof ie){const C=c.getGripPoints().at(2);l(r,C,C.sub(c.center).normalize(),c.getLength().val.toFixed(3))}},x=(r,c,h,P,D)=>{if(!P||!D||P.startPoint.isEqualTo(D.startPoint)&&P.endPoint.isEqualTo(D.endPoint))return;const A=P.IntersectWith(D,De.Intersect.kOnBothOperands);if(A.isEmpty())return;const b=new he;b.offsetDist=0;const C=A.at(0),E=Ne(P.startPoint,P.endPoint,C,c),R=Ne(D.startPoint,D.endPoint,C,h);E?b.pt1=P.startPoint.toVector3():b.pt1=P.endPoint.toVector3(),R?b.pt2=D.startPoint.toVector3():b.pt2=D.endPoint.toVector3(),b.center=C.toVector3();const I=b.getAngle();if(I===Math.PI/2){r.setColor(16760576),b.radius=Math.min(L.viewCoordLong2Cad(10),Math.min(P.getLength().val,D.getLength().val)/10);const k=b.getRadius(!0),T=b.getStartPoint().clone().add(b.center.clone().sub(b.pt1).normalize().negate().multiplyScalar(k)),S=b.getEndPoint().clone().add(b.center.clone().sub(b.pt2).normalize().negate().multiplyScalar(k)),z=new THREE.Vector3(T.x+S.x-b.center.x,T.y+S.y-b.center.y);r.drawLine(T,z),r.drawLine(S,z)}else b.radius=L.viewCoordLong2Cad(26),r.drawCustomEntity(b);return I},m=(r,c,h,P,D,A)=>{const b=new B(c,h),C=new B(c,P),E=new B(c,D),R=new B(c,A),I=p(c,h),k=p(c,P),T=p(c,D),S=p(c,A);I&&(b.endPoint=I.intersectPt),k&&(C.endPoint=k.intersectPt),T&&(E.endPoint=T.intersectPt),S&&(R.endPoint=S.intersectPt),r.setColor(16777215);const{line:z,draw:O}=I&&y(r,I.minDistEnt,c,h,I.intersectPt)||{},{line:W,draw:K}=k&&y(r,k.minDistEnt,c,P,k.intersectPt)||{},{line:U,draw:Y}=T&&y(r,T.minDistEnt,c,D,T.intersectPt)||{},{line:J,draw:te}=S&&y(r,S.minDistEnt,c,A,S.intersectPt)||{},ne=I&&T&&x(r,I.intersectPt,T.intersectPt,z,U),se=I&&S&&x(r,I.intersectPt,S.intersectPt,z,J),ue=k&&T&&x(r,k.intersectPt,T.intersectPt,W,U),ge=k&&S&&x(r,k.intersectPt,S.intersectPt,W,J);I&&k&&x(r,I.intersectPt,k.intersectPt,z,W),T&&S&&x(r,T.intersectPt,S.intersectPt,U,J);const oe=Math.PI/2,Q=ne===oe&&se===oe&&ue===oe&&ge===oe;function fe(N){return N.startPoint.x===N.endPoint.x?1/0:(N.endPoint.y-N.startPoint.y)/(N.endPoint.x-N.startPoint.x)}const re=(N,ee)=>{const be=fe(N),pe=fe(ee);return be===pe},Fe=(N,ee)=>{const be=N.getLength().val,pe=ee.getLength().val;return be===pe},xe=(N,ee)=>re(N,ee)&&Fe(N,ee),Ie=[];z&&Ie.push({line:z,draw:O,info:I}),W&&Ie.push({line:W,draw:K,info:k}),U&&Ie.push({line:U,draw:Y,info:T}),J&&Ie.push({line:J,draw:te,info:S}),Ie.reduce((N,ee)=>{let be=!1;for(let pe=0;pe<N.length;pe++){const Ue=N[pe];if(xe(Ue[0].line,ee.line)){Ue.push(ee),be=!0;break}}return be||N.push([ee]),N},[]).forEach(N=>{if(N.length===1){if(xe(N[0].line,new B(b.endPoint,C.endPoint))||xe(N[0].line,new B(E.endPoint,R.endPoint)))return;N[0].draw&&N[0].draw()}else if(!Q)if(N.length===2){if(xe(N[1].line,new B(b.endPoint,C.endPoint))||xe(N[1].line,new B(E.endPoint,R.endPoint)))return;I&&k||T&&S?(I&&k&&(I.intersectPt.distanceTo(c)<k.intersectPt.distanceTo(c)?O&&O(!0):K&&K()),T&&S&&(T.intersectPt.distanceTo(c)<S.intersectPt.distanceTo(c)?Y&&Y(!1):te&&te())):(N[0].draw&&N[0].draw(),N[1].draw&&N[1].draw())}else N.forEach(({draw:ee})=>{ee&&ee()})}),r.setColor(16760576),r.drawMcDbEntity(b),r.drawMcDbEntity(C),r.drawMcDbEntity(E),r.drawMcDbEntity(R);const Se=L.viewCoordLong2Cad(16);if(I&&k){const N=b.endPoint.distanceTo(C.endPoint);b.endPoint.distanceTo(c)>C.endPoint.distanceTo(c)?r.drawText(N.toFixed(3),Se,0,new THREE.Vector3((c.x+b.endPoint.x)/2,(c.y+b.endPoint.y)/2)):r.drawText(N.toFixed(3),Se,0,new THREE.Vector3((c.x+C.endPoint.x)/2,(c.y+C.endPoint.y)/2))}if(T&&S){const N=E.endPoint.distanceTo(R.endPoint);E.endPoint.distanceTo(c)>R.endPoint.distanceTo(c)?r.drawText(N.toFixed(3),Se,0,new THREE.Vector3((c.x+E.endPoint.x)/2,(c.y+E.endPoint.y)/2)):r.drawText(N.toFixed(3),Se,0,new THREE.Vector3((c.x+R.endPoint.x)/2,(c.y+R.endPoint.y)/2))}};if(o.setUserDraw((r,c)=>{const h=L.viewCoordLong2Cad(d.mxdraw.getViewWidth()),P=L.viewCoordLong2Cad(d.mxdraw.getViewHeight()),D=new $(-h,r.y),A=new $(r.x+h,r.y),b=new $(r.x,r.y+P),C=new $(r.x,-P);m(c,r,D,A,b,C)}),await o.go(),a=o.keyWordPicked(),o.getStatus()===H.kCancel||o.getDetailedResult()===v.kCodeAbort||o.getDetailedResult()===v.kEcsIn)break;if((o.getDetailedResult()===v.kMouseRightIn||o.getDetailedResult()===v.kNullSpaceIn||o.getDetailedResult()===v.kNullEnterIn)&&(a=e),a?.toLocaleUpperCase()==="D"){i();const r=await ft(!0);if(r===!1)break;const{markedLines:c}=r||{};c&&n.push(...c),await(async()=>new Promise(h=>setTimeout(h,1)))()}if(a?.toLocaleUpperCase()==="R"){i();const r=await bn(!0);if(r===!1)break;const{markedLines:c}=r||{};c&&n.push(...c),await(async()=>new Promise(h=>setTimeout(h,1)))()}if(a?.toLocaleUpperCase()==="A"){i();const r=await An();if(r===!1)break;const{markedArcs:c}=r||{};c&&n.push(...c),await(async()=>new Promise(h=>setTimeout(h,1)))()}if(a?.toLocaleUpperCase()==="AR"){i();const r=await kn();if(r===!1)break;const{markedLines:c}=r||{};c&&n.push(...c),await(async()=>new Promise(h=>setTimeout(h,1)))()}if(a?.toLocaleUpperCase()==="Q"&&i(),a?.toLocaleUpperCase()==="X")break;g.includes(a)&&a!==""&&(e=a)}}catch(f){console.warn(f)}i()});async function In(){const a=new j;a.setMessage(u("指定点"));const e=await a.go();e&&L.acutPrintf(`X = ${e.x} Y = ${e.y} Z = ${e.z}
- `)}F("ID",In);Ut();async function ht(a,e){return new Promise(async s=>{let n=a.hash,i=a.type;const f=a.file,{hideLoading:o,showLoading:g}=st();if(i==="mxweb"){f.source.source.size/(1024*1024)>1&&g();const t=URL.createObjectURL(f.source.source);setTimeout(()=>{ut(t),setTimeout(()=>{URL.revokeObjectURL(t)},5e3)})}else{let{mxfilepath:t=""}=at()||{},w=Vt(),M=w+t+n+"."+i+".mxweb",p=w+t+n+"/___mx___tz___.dwg.mxweb",l=!1;if(!a.isUseServerExistingFile){let r=await Xt(M,n);if(!r.ok)return o(),s(!1);r.tz&&(l=!0)}_t(u("365")+"..."),$t(!0);var d=new Date().getTime();let y=0;e||(y=Ke.EMSCRIPTEN_FETCH_LOAD_TO_MEMORY|Ke.EMSCRIPTEN_FETCH_PERSIST_FILE|Ke.EMSCRIPTEN_FETCH_REPLACE);let x=_.App.getCurrentMxCAD();const m=x.openWebFile(M,r=>{if(o(),Wt(),r===0){s(!0);var c=new Date().getTime();if(c-d>5e3&&Pe().success(u("366")+"..."),l){let h=w+"/mxcad/files/tz";Nt.post(h,{fileHash:n}).then(P=>{P&&P.data&&P.data.code==0&&x.getImp().loadTz(p)})}}else s(!1),Pe().error(u("367"))},void 0,void 0,y,!l);nt(M).then(r=>{r/(1024*1024)>1&&m&&g()}),s(!!m),s(!1)}zt(f.name)})}let ve=me();F("OpenDwg",async()=>{ve=me(),await rt(!1,"OpenDwgImp"),ve&&ye("MxFullScreen")});F("OpenDwg_DoNotUseCache",async()=>{ve=me(),await rt(!0,"OpenDwgImp_DoNotUseCache"),ve&&ye("MxFullScreen")});F("OpenDwgImp_DoNotUseCache",async a=>{await ht(a,!1)});F("OpenDwgImp",async a=>{await ht(a,!0)});F("Mx_SaveAs",ct);F("Mx_QSave",Ht);F("Mx_Export_DWG",async()=>{{ve=me();const a=()=>{ve&&ye("MxFullScreen")};let{baseUrl:e="",saveDwgUrl:s="",mxfilepath:n=""}=at()||{};e.substring(0,16)=="http://localhost"&&(e=Ye()+e.substring(16)),s.substring(0,16)=="http://localhost"&&(s=Ye()+s.substring(16)),_.getCurrentMxCAD().saveFileToUrl(s,(i,f)=>{try{let o=JSON.parse(f);if(o.ret=="ok"){let g=e+n+o.file;fetch(g).then(async d=>{const t=await d.blob();await qe.saveAsFileDialog({blob:t,filename:o.file,types:[{description:"dwg"+u("160"),accept:{"application/octet-stream":[".dwg"]}}]}),a()})}else console.log(f)}catch{console.log("Mx: sserverResult error")}})}});F("Mx_debug",()=>{});F("Mx_clear_buf",()=>{});F("Mx_Array",Ft);F("Mx_NewFile",()=>{_.getCurrentMxCAD().newFile()});F("Mx_NewFile_Template",()=>{_.getCurrentMxCAD().openWebFile("empty_template.mxweb")});F("MxPE_DrawMText",async()=>{const a=new j;a.setMessage(u("368"));const e=await a.go();if(!e)return;const{open:s}=Rt(),n=await s();if(typeof n!="string")return;const i=new St;i.contents=n||"",i.location=e,i.trueColor=new We(_.getCurrentMxCAD().getCurrentDatabaseDrawColor()),i.rotation=0,i.attachment=De.AttachmentPoint.kTopLeft;const f=_.getCurrentMxCAD(),o=f.drawEntity(i);return f.updateDisplay(),o});
|