- 积分
- 2971
- 明经币
- 个
- 注册时间
- 2004-2-24
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
如题,请大家帮忙简化,优化一下刷多段线特性的程序。谢谢
;;多义线专用特性匹配程序,可同时匹配图层、线型、线型比例、颜色及宽度。
(DEFUN C:XM ( / STXT SLEN I E_NT B E_NAME NEW_1 p_cen d_en vos ipl ela ew elt els ec xm_oe xm_err ec1)
;-------------
(defun xm_err(s)
(if (/= s "Function cancelled")
(if (= s "quit / exit abort")
(princ)
(princ (strcat "\n错误: " s))
)
)
(if xm_oe (setq *error* xm_oe xm_oe nil))
(if new_1 (progn (redraw (car new_1) 4) (setq new_1 nil)))
(princ "用户取消了命令!")
(princ)
)
(SETVAR "CMDECHO" 0)
(setq ipl nil)
;重新设置错误函数
(setq xm_oe *error* *error* xm_err)
;------------
(PROMPT "\n多义线特性匹配程序,可匹配图层,颜色,线型,线型比例及宽度。")
(PROMPT "\n---------------------------------------------------------")
(while (not ipl)
(SETQ NEW_1 (entsel "\n请选择多义线源对象:"))
(if (/= new_1 nil) (progn
(setq e_nt (entget (car new_1)) e_name (cdr (assoc 0 e_nt)))
(if (= e_name "LWPOLYLINE") (progn (setq ipl T) (redraw (car new_1) 3)
(setq ela (cdr (assoc 8 e_nt)) elt (cdr (assoc 6 e_nt)) els (cdr (assoc 48 e_nt)))
(setq ew (cdr (assoc 40 e_nt)) ec (cdr (assoc 62 e_nt)))
));if
));if
);while
(if (= elt nil) (setq elt "BYLAYER"))
(if (= els nil) (setq els 1))
(cond ((= ec 0) (setq ec "BYBLOCK" ec1 ec))
((or (= ec nil) (= ec 256)) (setq ec "BYLAYER" ec1 ec))
((= ec 1) (setq ec1 "红色"))
((= ec 2) (setq ec1 "黄色"))
((= ec 3) (setq ec1 "绿色"))
((= ec 4) (setq ec1 "青色"))
((= ec 5) (setq ec1 "蓝色"))
((= ec 6) (setq ec1 "紫色"))
((= ec 7) (setq ec1 "白色"))
((= ec 8) (setq ec1 "红色"))
(T (setq ec1 (rtos ec 2 1)))
);cond
(prompt (strcat "\n源对象特性:图层=" ela ",线型=" elt ",线型比例=" (rtos els 2 2) ",颜色=" ec1 ",线宽=" (rtos ew 2 2) "。"))
(PROMPT "\n请选择要匹配的目标(多义线,直线,圆或圆弧):")
(SETQ STXT (SSGET))
(redraw (car new_1) 4)
(if stxt (progn
(command "undo" "group")
(SETQ SLEN (SSLENGTH STXT) I 0 )
(WHILE (SSNAME STXT I)
(SETQ E_NT (SSNAME STXT I))
(SETQ E_NAME (ENTGET E_NT))
(SETQ B (CDR (ASSOC 0 E_NAME)))
(COND ((or (= B "POLYLINE") (= B "LWPOLYLINE")) ;在R14中多义线名称为LWPOLYLINE;
(COMMAND "PEDIT" E_NT "W" ew "")
(command "change" e_nt "" "p" "C" ec "LA" ela "LT" elt "S" els "")
)
((= B "CIRCLE")
(setq vos (getvar "osmode"))
(command "osnap" "off")
(SETQ P_CEN (CDR (ASSOC 10 E_NAME)))
(SETQ D_EN (* (CDR (ASSOC 40 E_NAME)) 2.0))
(COMMAND "DONUT" (- D_EN ew) (+ D_EN ew) P_CEN "")
(ENTDEL E_NT)
(command "change" "L" "" "p" "C" ec "LA" ela "LT" elt "S" els "")
(setvar "osmode" vos)
)
((OR (= B "ARC") (= B "LINE"))
(COMMAND "PEDIT" E_NT "Y" "W" ew "")
;;; (COMMAND "PEDIT" E_NT "W" ew "")
(command "change" "L" "" "p" "C" ec "LA" ela "LT" elt "S" els "")
)
)
(SETQ I (1+ I))
)
(command "undo" "end")
));if
(if xm_oe (setq *error* xm_oe))
(PRINC)
)
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|