新建文本文档。在文档中输入以下内容:;统计cad图中线的总长度;**************WriteByzhenglin****************(defunc:tj_l(/pnee1e2lsx1x2y1y2xxyylllll)(setqln0lll0)(setqp(ssget));Selectobjects(ifp(progn;Ifanyobjectsselected(setql0n(sslengthp))(while(ln);Foreachselectedobject...(if(=LINE(cdr(assoc0(setqe(entget(ssnamepl))))))(progn(setqe1(assoc10e)e2(assoc11e))(setqx1(cadre1)y1(caddre1))(setqx2(cadre2)y2(caddre2))(setqxx(abs(-x2x1))yy(abs(-y2y1)))(setqll(sqrt(+(*xxxx)(*yyyy))))(setqlll(+lllll))(setqln(+ln1))))(setql(1+l)))))(printtotallinenumber=)(princln)(printtotallinelength=)(princlll)(terpri))另存为tj_l.lsp打开cad—工具—加载应用程序—找到并选中tj_l.lsp点加载在命令行输入tj_l然后选中所有要统计的线。按F2查看结果