本帖最后由 wzg356 于 2014-9-13 19:25 编辑
这个小工具,很小众,但对我很有用。找了好久,没找到,自己动手写了。
改了好几个版本,这个觉得还可以,分享给需要的盆友
附件更新POLYLINE 无颜色组码62时的出错
解决3楼dbx511提出的 lwPOLYLINE 继续时按c闭合问题,已更新- ;;;wzg写于2014年3月22日,改了几版,完善在9月5日,还有待完善简化
- (defun c:pl-jx ( / oce1 oce2 oce3 oce4 oce5 vxs ss en ent en1 lst pt lw)
- ;;;系统变量
- (command "undo" "be");;命令编组开始
- (setq oce1 (getvar "cmdecho");;;保存命令响应原变量值
- oce2 (getvar "PLINEWID");;全局线宽
- oce3 (getvar "OSMODE");;;捕捉变量
- oce4 (getvar "CECOLOR");;绘图颜色
- oce5 (getvar "LWDEFAULT");;线宽
- )
- (setvar "cmdecho" 0);;;关闭命令响应
- (setvar "OSMODE" 39);;;改变捕捉模式
- (setvar "PLINETYPE" 2);;;高质量对线段
-
- ;;;子函数
- (defun vxs (e / i v lst);;示例(vxs (car (entsel))),返回三维点坐标
- (setq i -1)
- (while
- (setq v (vlax-curve-getpointatparam e (setq i (1+ i))))
- (setq lst (cons v lst))
- )
- (reverse lst)
- )
-
- ;;;主程序
- (setq SS (entsel "\n请点取要继续的多线线:"))
- (setq en (car SS))
- (setq ent (entget en))
- (if (or (= (cdr (assoc 0 ent)) "POLYLINE") (= (cdr (assoc 0 ent)) "LWPOLYLINE"))
- (progn
- (setq lst (vxs en))
- (if (= (cdr (assoc 0 ent)) "POLYLINE")
- (progn;继续POLYLINE
- (if(/= (assoc 62 ent)nil)
- (setvar "CECOLOR" (rtos(cdr (assoc 62 ent)) 2 0))
- (setvar "CECOLOR" "BYLAYER")
- )
- (if(/= (assoc 370 ent)nil)(setvar "LWDEFAULT" (cdr (assoc 370 ent))))
- (command "3dpoly" );注意以下三句的写法
- (foreach pt lst (command pt))
- (while(/=(getvar"cmdactive")0)(command pause))
- (setq en1 (entlast))
- (command "_matchprop" en en1 "")
- (command "_erase" en"")
- )
- (progn;继续LWPOLYLINE
- (setq lw (cdr (assoc 43 ent)));实体全局线宽
- (if (= lw nil) (setq lw (cdr (assoc 40 ent))));如果无实体全局线宽 则取起始线宽
- (setq pt (last lst));获取末端点坐标
- ;注意以下2句的写法
- (command "pline" pt "w" lw lw)
- (while(/=(getvar"cmdactive")0)
- (cond
- ((or(equal (grread t 8) '(2 67))(equal (grread t 8) '(2 99)))(command (car lst) ""));按下c/C键闭合
- ((= (car (grread t 8)) 11) (command ""));按下鼠标右键结束
- (t (command pause))
- )
- )
- (setq en1 (entlast))
- (command "_matchprop" en en1 "")
- (command "_join" en1 en "")
- )
- )
- )
- (alert "你选择的不是多线段!")
- )
- ;;;还原系统变量值
- (setvar "cmdecho" oce1);;;恢复命令响应
- (setvar "PLINEWID" oce2);;全局线宽
- (setvar "OSMODE" oce3);;;恢复捕捉模式
- (setvar "CECOLOR" oce4)
- (setvar "LWDEFAULT" oce5)
- (command "undo" "e")
- (princ)
- )
|