ZKX's LAB

CADlisp编程:如何用lisp处理一个dwg图形中的多个多线段? lisp多段线处理

2021-04-06知识2

lisp程序能求多段线上任意一点到其中一个端点的距离,,每次要量桩号很烦。哪位大侠给个..谢谢了。。.. ;用AP命令加载后,输e799bee5baa6e79fa5e98193e4b893e5b19e31333332643962入命令GM,先选中心线,再选任意点即可(defun C:GM(/cur pt olderr olderror*error*)自定义错误处理函数(defun myerror(s)(if(and(/s\"函数被取消\")(/s\"函数已取消\")(/s\"Function cancelled\")(/s\"quit/exit abort\")(princ(strcat\"错误:\"s))(setq*error*olderror)(command\"UNDO\"\"END\")(setvar\"CMDECHO\"1)(princ)系统变量设置(setvar\"cmdecho\"0)(setq olderror*error*error*myerror(while(not cur)(princ\"\\n请选择曲线:\")(setq cur(car(entsel)))(if cur(setq cur(vlax-ename->;vla-object cur)))(setq pt(getpoint))(if(not pt)(exit))(setq pt(vlax-curve-getClosestPointTo cur pt))(princ\"\\n桩号=\")(princ(vlax-curve-getDistAtPoint cur pt))还原系统变量(setq*error*olderror)(setvar\"CMDECHO\"1)(princ)

用lisp求多段线等的面积和。求大侠修改指点。 增加了点功能。可以统计1:1和1:1000的绘图比例中的面积。

编写lisp程序多条多段线连接成一条多段线 命令HB合并多段线(defun c:hb(/myL@lpNum@etLst@e69da5e887aae799bee5baa631333363383339ent@ptLst)(setq@myL(ssget\"i\"'((0.\"LINE,LWPOLYLINE\"))))将创建已经选择的线(多段线或者直线)的选择集(setq@lpNum 0);为循环计数参数赋值(repeat(sslength@myL);选择集包含几个对象就循环几次(setq@etLst(append@etLst(list(ssname@myL@lpNum)))逐个提取选择集中的图元名并储存到表@etLst中lpNum(1+lpNum);每循环一次循环计数参数+1(foreach@lpet@etLst;历遍表@etLst中每一个原子,以@lpet代替原子(progn(setq@ent(entget@lpet));将每个图元的详细列表赋值到@ent中(foreach@2lpe@ent(if(=(car@2lpe)10);如果子表中第一个原子为10(setq@ptLst(append@ptLst(list@2lpe)));将子表列入@ptLst(entdel@lpet);删除已提取过点的对象(entmake(append(list;通过点表创建新的多段线'(0.\"LWPOLYLINE\")'(100.\"AcDbEntity\")'(100.\"AcDbPolyline\")(cons 90(length@ptLst))ptLst(princ)分割线=顺带一说。你为何不用CAD自带的pedit命令?pedit(使用CAD原生的ACAD.PGP可简化为PE命令)→M→选择所有需要合并的线→(若有不含多段线的元素)按Y转换所有选择对象为多段。

#lisp多段线处理

随机阅读

qrcode
访问手机版