資源描述:
《cad 快速繪圖小插件程序》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、使用方法:將程序分別復(fù)制到txt記事本,保存后改后綴成.lsp保存后,打開cad加載使用。測量區(qū)域內(nèi)的面積(defunc:mj()(if*error*(command"_boundary"(setqp1(getpoint"點(diǎn)取要標(biāo)注的封閉區(qū)域內(nèi)部一點(diǎn):"))""))(setqEN(entlast))(command"area""o"EN)(setqsmj(getvar"area"))(setqimjsmj)(setqsmj(/smj1000000))(setqsmj(*smj1))(setqsmj(rt
2、ossmj22))(setqsmj(strcat"S="smj"m2"))(if(=htxtnil)(progn(setqhtxt(/(sqrtimj)15))))(setqhtxt1(getdist(strcat"輸入字體的高度<"(rtoshtxt21)">:")))(ifhtxt1(setqhtxthtxt1))(setqPt(getpoint"文字標(biāo)注位置:"))(command"style""MJ""txt.shx"htxt0.8"""n""""")(command"text""s""MJ
3、""j""BC"pt""smj"")'(COMMAND"TEXT"Ptffsize0smj))求cad圖紙內(nèi)任意數(shù)字之和(defunC:QH(/ssetqhbssltempt1hn)(setqsset(ssget))(setqqhbnil)(setqssl(sslengthsset))(if(>ssl25)(princ"確認(rèn)所選的圖元--請稍候."))(while(>ssl0)(setqtemp(ssnamesset(setqssl(1-ssl))))(if(=(cdr(assoc0(entgettem
4、p)))"TEXT")(progn(setqt1(cdr(assoc1(entgettemp))))(if(or(=(type(readt1))'INT)(=(type(readt1))'REAL))(setqqhb(cons(atoft1)qhb))))))(if(>(lengthqhb)0)(progn(setqh0)(foreachnqhb(setqh(+nh)))(prompt"和為:")(princh)(print))(prompt"ERROR:未選到數(shù)字!")))求cad圖紙內(nèi)任意線長之
5、和(defunC:ZCD(/CURVETLENSSNSUMLEN)(vl-load-com)(setqSUMLEN0)(setqSS(ssget'((0."CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE,ARC"))))(setqN0)(repeat(sslengthSS)(setqCURVE(vlax-ename->vla-object(ssnameSSN)))(setqTLEN(vlax-curve-getdistatparamCURVE(vlax-curve-getendpa
6、ramCURVE)))(setqSUMLEN(+SUMLENTLEN))(setqN(1+N)))(print(strcat"總長度:"(rtosSUMLEN25)))(princ))求cad圖紙內(nèi)任意數(shù)字之乘積和除法(defunC:q(/#os1#os2#os3@k)(setvar"cmdecho"0)(setvar"blipmode"0)(setvar"dimzin"0)(vl-load-com);;加載vlax擴(kuò)展函數(shù)(setq#os1(getvar"osmode"))(setq#os2(getvar
7、"Clayer")#os3(getvar"textstyle");取得當(dāng)前字體樣式)(initget"XS")(setq@k(getkword(strcat"請選擇方式[數(shù)值相乘(X)/數(shù)值除以(S)]:<""X"">")))(if(=@knil)(setq@k"X"))(setq@k(strcase@k))(setvar"osmode"0)(if(=@k"X")(CY2))(if(=@k"S")(CY4))(setvar"osmode"#os1)(setvar"Clayer"#os2)(setvar"
8、textstyle"#os3)(prin1))(defunCY2(/#k1#k2&k1&kw1sz1sz2)(princ"請選擇要相乘的數(shù)值")(setq&kw1(ssget(list(cons0"TEXT,MTEXT")(cons1"~*[~-.0-9]*"))))(if(/=&kw1nil)(progn(setq&k1(ssname&kw10))(setq#k2(entget&k1)SZ2nil)(whi