自动坐标标注
<p>帮网上一个朋友做的一个坐标自动标注程序,虽然解决了大部分问题,但是还有少量缺点,弄不起来了,希望高手指点:</p><p>主要集中两点:1。程序不能把坐轴移动到标注基点上</p><p>2。程序运行时候,多数情况正常,但是偶尔有时候会出现“未知命令”情况,找不到原因</p><p>;;; =================================================================<br/>;;; 自动坐标标注<br/>;;; 原作者:zml84 由langjs修改于2009-05-25 命令:tt<br/>;;; =================================================================<br/>(princ "\n 自动坐标标注 命令:tt ")<br/>(defun C:TT (/ chanshu001 ent ent1 i lst_1 lst_2 lst_3 lst_4 lst_pt lst_x lst_y p001 p002 p003 p004<br/> pmax pmay pminx pminy pt0 pzhx pzhxl pzhy pzhyl sc snap ss ssguol uuu x_last xlins<br/> xxxx xzuih xzuihbak xzuihbak2 y_last ylins yyyy yzuih yzuihbak3 PT0linshijidian<br/> )<br/> (setvar "cmdecho" 0) ; 关闭命令响应<br/> (setq ss (ssget '((0 . "LINE,CIRCLE,PLINE,LWPOLYLINE,INSERT"))))<br/> (setq PT0linshijidian '(0.0 0.0 0.0))<br/> (setq PT0 (getpoint "\n指定基点: "))<br/> (cond<br/> ((null PT0)<br/> (setq PT0 PT0linshijidian)<br/> )<br/> ((= PT0 0.0)<br/> (setq PT0 PT0linshijidian)<br/> )<br/> )<br/> (setq SC 1)<br/> (setq SC (getreal "\n输入比例 <1>: "))<br/> (cond<br/> ((null SC)<br/> (setq SC 1)<br/> )<br/> ((= uuu 0.0)<br/> (setq SC 1)<br/> )<br/> )<br/> (setq chanshu001 (* 7 (getvar "dimtxt") (getvar "dimscale")))<br/> (setq uuu (atof (getstring (strcat "\n标注拉伸 <" (rtos chanshu001) ">:"))))<br/> (cond<br/> ((null uuu)<br/> (setq uuu chanshu001)<br/> )<br/> ((= uuu 0.0)<br/> (setq uuu chanshu001)<br/> )<br/> ) ; 下面程序设置过滤虚线条件<br/> (setq ssguol '("ACAD_ISO03W100" "ACAD_ISO02W100"<br/> "DASHED" "DASHED2"<br/> "DASHEDX2" "HIDDEN"<br/> "HIDDEN2" "HIDDENX2"<br/> )<br/> ) ; 下面程序将虚线图层加入虚线过滤条件<br/> (setq ssguol (append<br/> SSguol<br/> (TT-01 "ACAD_ISO03W100")<br/> (TT-01 "ACAD_ISO02W100")<br/> (TT-01 "DASHED")<br/> (TT-01 "DASHED2")<br/> (TT-01 "DASHEDX2")<br/> (TT-01 "HIDDEN")<br/> (TT-01 "HIDDEN2")<br/> (TT-01 "HIDDENX2")<br/> )<br/> ) ; 下面程序将选择集中随层的虚线图层中的线过滤掉<br/> (SETQ i 0)<br/> (while (< i (sslength ss))<br/> (setq ent (ssname ss i))<br/> (setq ent1 (entget ent))<br/> (if (and<br/> (member (cdr (assoc 8 ent1)) ssguol)<br/> (/= (cdr (assoc 0 ent1)) "INSERT")<br/> (= (assoc 6 ent1) nil)<br/> )<br/> (setq ss (ssdel ent ss))<br/> (SETQ i (+ 1 i))<br/> )<br/> ) ; 下面程序将选择集中其他层的虚线图元过滤掉<br/> (SETQ i 0)<br/> (while (< i (sslength ss))<br/> (setq ent (ssname ss i))<br/> (setq ent1 (entget ent))<br/> (if (member (cdr (assoc 6 ent1)) ssguol)<br/> (setq ss (ssdel ent ss))<br/> (SETQ i (+ 1 i))<br/> )<br/> ) ; 主要程序<br/> (vl-cmdf ".UNDO" "BE") ; 设置UNDO起点<br/> (setq snap (getvar "osmode"))<br/> (setvar "osmode" 0) ; 关闭捕捉<br/> (progn<br/> (setq LST_PT (TT-02 ss))<br/> (setq LST_PT (cons PT0 LST_PT)) ; 下面程序坐标分象限<br/> (setq i 1<br/> pminx (car (nth 0 LST_PT))<br/> pmax pminx<br/> pminy (cadr (nth 0 LST_PT))<br/> pmay pminy<br/> )<br/> (while (<= i (length LST_PT))<br/> (setq xxxx (car (nth (- i 1) LST_PT)))<br/> (setq yyyy (cadr (nth (- i 1) LST_PT)))<br/> (cond<br/> ((< xxxx pminx)<br/> (setq pminx xxxx)<br/> )<br/> ((> xxxx pmax)<br/> (setq pmax xxxx)<br/> )<br/> ((< yyyy pminy)<br/> (setq pminy yyyy)<br/> )<br/> ((> yyyy pmay)<br/> (setq pmay yyyy)<br/> )<br/> (t<br/> (princ)<br/> )<br/> )<br/> (setq i (+ i 1))<br/> ) ; 求坐标范围中间数值<br/> (setq pzhx (/ (+ pminx pmax) 2))<br/> (setq pzhy (/ (+ pminy pmay) 2)) ; 求4个象限的坐标对齐点<br/> (setq p001 (list (- pminx uuu) (- pminy uuu) 0.0)<br/> p002 (list (- pminx uuu) (+ pmay uuu) 0.0)<br/> p003 (list (+ pmax uuu) (- pminy uuu) 0.0)<br/> p004 (list (+ pmax uuu) (+ pmay uuu) 0.0)<br/> ) ; 将坐标分类到四个象限<br/> (setq i 0<br/> LST_1 '()<br/> LST_2 '()<br/> LST_3 '()<br/> LST_4 '()<br/> )<br/> (while (< i (length LST_PT))<br/> (setq pzhxl (car (nth i LST_PT))<br/> pzhyl (cadr (nth i LST_PT))<br/> )<br/> (if (and<br/> (<= pzhxl pzhx)<br/> (<= pzhyl pzhy)<br/> )<br/> (setq LST_1 (cons (nth i LST_PT) LST_1))<br/> )<br/> (if (and<br/> (<= pzhxl pzhx)<br/> (> pzhyl pzhy)<br/> )<br/> (setq LST_2 (cons (nth i LST_PT) LST_2))<br/> )<br/> (if (and<br/> (> pzhxl pzhx)<br/> (<= pzhyl pzhy)<br/> )<br/> (setq LST_3 (cons (nth i LST_PT) LST_3))<br/> )<br/> (if (and<br/> (> pzhxl pzhx)<br/> (> pzhyl pzhy)<br/> )<br/> (setq LST_4 (cons (nth i LST_PT) LST_4))<br/> )<br/> (setq i (+ i 1))<br/> ) ; 坐标分象限结束<br/> (setq Xlins '(0.0)<br/> Ylins '(0.0)<br/> )<br/> (setq LST_X (TT-03 LST_1)<br/> LST_Y (TT-04 LST_1)<br/> )<br/> (setq LST_X (TT-10 SS LST_X)<br/> LST_Y (TT-11 SS LST_Y)<br/> )<br/> (setq X_LAST (caar LST_X))<br/> (setq Y_LAST (caar LST_Y))<br/> (TT-07 LST_X LST_Y PT0 SC p001)<br/> (setq Xzuihbak Xzuih)<br/> (setq LST_X (TT-05 LST_2)<br/> LST_Y (TT-04 LST_2)<br/> )<br/> (setq LST_X (TT-10 SS LST_X)<br/> LST_Y (TT-11 SS LST_Y)<br/> )<br/> (setq X_LAST (caar LST_X))<br/> (TT-07 LST_X LST_Y PT0 SC p002)<br/> (setq Xzuihbak2 Xzuih)<br/> (setq Yzuihbak2 Yzuih)<br/> (setq LST_X (TT-03 LST_3)<br/> LST_Y (TT-06 LST_3)<br/> )<br/> (setq LST_X (TT-10 SS LST_X)<br/> LST_Y (TT-11 SS LST_Y)<br/> )<br/> (setq X_LAST Xzuihbak)<br/> (setq Y_LAST (caar LST_Y))<br/> (TT-07 LST_X LST_Y PT0 SC p003)<br/> (setq Yzuihbak3 Yzuih)<br/> (setq X_LAST Xzuihbak2)<br/> (setq LST_X (TT-05 LST_4)<br/> LST_Y (TT-06 LST_4)<br/> )<br/> (if (= Yzuihbak2 Yzuihbak3)<br/> (setq Y_LAST (caar LST_Y))<br/> (setq Y_LAST Yzuihbak3)<br/> )<br/> (setq LST_X (TT-10 SS LST_X)<br/> LST_Y (TT-11 SS LST_Y)<br/> )<br/> (TT-07 LST_X LST_Y PT0 SC p004)<br/> )<br/> (vl-cmdf ".UNDO" "E") ; 设置UNDO终点<br/> (setvar "osmode" snap)<br/> (princ)<br/>)<br/>;;; =================================================================<br/>;;; 获取包含指定线型的图层<br/>(defun TT-01 (xianxing / layers)<br/> (setq layers '())<br/> (setq layers (get_layer_linetype xianxing)) ; 获取包含指定线型的图层<br/> layers<br/>)<br/>(defun get_layer (/ layer_info layers) ; 返回当前图纸中图层信息<br/> (setq layer_info (tblnext "layer" t))<br/> (while (/= layer_info nil)<br/> (setq layers (append<br/> layers<br/> (list layer_info)<br/> )<br/> )<br/> (setq layer_info (tblnext "layer"))<br/> )<br/> layers<br/>)<br/>(defun get_layer_linetype (linetype / ly_info ly_infos tmplist) ; 提取包含指定线型的图层<br/> (setq ly_Infos (get_layer))<br/> (foreach ly_info ly_Infos<br/> (if (= linetype (substr (cdr (assoc 6 ly_info)) 1 (strlen linetype)))<br/> (setq tmplist (append<br/> tmplist<br/> (list (CDR (assoc 2 ly_info)))<br/> )<br/> )<br/> )<br/> )<br/> tmplist<br/>)<br/>;;; =================================================================<br/>;;; 获取特征点坐标<br/>(defun TT-02 (SS / ent i lst_pt lstl n pt)<br/> (setq LST_PT '()<br/> I 0<br/> )<br/> (repeat (sslength SS)<br/> (setq ENT (entget (ssname SS I)))<br/> (foreach N ENT<br/> (if (<= 10 (car N) 19)<br/> (setq PT (cdr N)<br/> LST_PT (cons PT LST_PT)<br/> )<br/> )<br/> )<br/> (setq I (1+ I))<br/> )<br/> (setq i 0<br/> LSTL '()<br/> )<br/> (while (< i (length LST_PT))<br/> (setq LSTL (cons (list (car (nth i LST_PT)) (cadr (nth i LST_PT)) 0.0) LSTL))<br/> (setq i (+ 1 i))<br/> )<br/> (setq LST_PT LSTL) ; 返回<br/> (reverse LST_PT)<br/>)<br/>;;; =================================================================<br/>;;; 提炼 X 坐标,并排序<br/>(defun TT-03 (LST_PT / e1 e2 i lst_x lstl pt tmp x y)<br/> (setq LST_X '())<br/> (foreach PT LST_PT<br/> (setq X (car PT)<br/> Y (cadr PT)<br/> )<br/> (if (setq TMP (assoc X LST_X))<br/> (setq LST_X (subst<br/> (append<br/> (list X Y)<br/> (cdr TMP)<br/> )<br/> TMP<br/> LST_X<br/> )<br/> )<br/> (setq LST_X (cons (list X Y) LST_X))<br/> )<br/> ) ; 排序<br/> (setq LST_X (mapcar<br/> '(lambda (E1)<br/> (cons (car E1) (vl-sort (cdr E1) '<))<br/> )<br/> LST_X<br/> )<br/> )<br/> (setq LST_X (vl-sort LST_X '(lambda (E1 E2)<br/> (< (car E1) (car E2))<br/> )<br/> )<br/> )<br/> (setq i 0<br/> LSTL '()<br/> )<br/> (while (< i (length LST_X))<br/> (setq LSTL (cons (list (car (nth i LST_X)) (cadr (nth i LST_X)) 0.0) LSTL))<br/> (setq i (+ 1 i))<br/> )<br/> (setq LST_X (reverse LSTL)) ; 返回<br/> LST_X<br/>)<br/>;;; =================================================================<br/>;;; 提炼 Y 坐标,并排序<br/>(defun TT-04 (LST_PT / e1 e2 i lst_y lstl pt tmp x y)<br/> (setq LST_Y '())<br/> (foreach PT LST_PT<br/> (setq X (car PT)<br/> Y (cadr PT)<br/> )<br/> (if (setq TMP (assoc Y LST_Y))<br/> (setq LST_Y (subst<br/> (append<br/> (list Y X)<br/> (cdr TMP)<br/> )<br/> TMP<br/> LST_Y<br/> )<br/> )<br/> (setq LST_Y (cons (list Y X) LST_Y))<br/> )<br/> ) ; 排序<br/> (setq LST_Y (mapcar<br/> '(lambda (E1)<br/> (cons (car E1) (vl-sort (cdr E1) '<))<br/> )<br/> LST_Y<br/> )<br/> )<br/> (setq LST_Y (vl-sort LST_Y '(lambda (E1 E2)<br/> (< (car E1) (car E2))<br/> )<br/> )<br/> )<br/> (setq i 0<br/> LSTL '()<br/> )<br/> (while (< i (length LST_Y))<br/> (setq LSTL (cons (list (car (nth i LST_Y)) (cadr (nth i LST_Y)) 0.0) LSTL))<br/> (setq i (+ 1 i))<br/> )<br/> (setq LST_Y (reverse LSTL)) ; 返回<br/> LST_Y<br/>)<br/>;;; =================================================================<br/>;;; 提炼 X 坐标,并排序 (由大到小)<br/>(defun TT-05 (LST_PT / e1 e2 i lst_x lstl pt tmp x y)<br/> (setq LST_X '())<br/> (foreach PT LST_PT<br/> (setq X (car PT)<br/> Y (cadr PT)<br/> )<br/> (if (setq TMP (assoc X LST_X))<br/> (setq LST_X (subst<br/> (append<br/> (list X Y)<br/> (cdr TMP)<br/> )<br/> TMP<br/> LST_X<br/> )<br/> )<br/> (setq LST_X (cons (list X Y) LST_X))<br/> )<br/> ) ; 排序<br/> (setq LST_X (mapcar<br/> '(lambda (E1)<br/> (cons (car E1) (vl-sort (cdr E1) '<))<br/> )<br/> LST_X<br/> )<br/> )<br/> (setq LST_X (vl-sort LST_X '(lambda (E1 E2)<br/> (< (car E1) (car E2))<br/> )<br/> )<br/> )<br/> (setq i 0<br/> LSTL '()<br/> )<br/> (while (< i (length LST_X))<br/> (setq LSTL (cons (list (car (nth i LST_X)) (nth (- (length (nth i LST_X)) 1) (nth i LST_X)) 0.0)<br/> LSTL<br/> )<br/> )<br/> (setq i (+ 1 i))<br/> )<br/> (setq LST_X (reverse LSTL)) ; 返回<br/> LST_X<br/>)<br/>;;; =================================================================<br/>;;; 提炼 Y 坐标,并排序 (由大到小)<br/>(defun TT-06 (LST_PT / e1 e2 i lst_y lstl pt tmp x y)<br/> (setq LST_Y '())<br/> (foreach PT LST_PT<br/> (setq X (car PT)<br/> Y (cadr PT)<br/> )<br/> (if (setq TMP (assoc Y LST_Y))<br/> (setq LST_Y (subst<br/> (append<br/> (list Y X)<br/> (cdr TMP)<br/> )<br/> TMP<br/> LST_Y<br/> )<br/> )<br/> (setq LST_Y (cons (list Y X) LST_Y))<br/> )<br/> ) ; 排序<br/> (setq LST_Y (mapcar<br/> '(lambda (E1)<br/> (cons (car E1) (vl-sort (cdr E1) '<))<br/> )<br/> LST_Y<br/> )<br/> )<br/> (setq LST_Y (vl-sort LST_Y '(lambda (E1 E2)<br/> (< (car E1) (car E2))<br/> )<br/> )<br/> )<br/> (setq i 0<br/> LSTL '()<br/> )<br/> (while (< i (length LST_Y))<br/> (setq LSTL (cons (list (car (nth i LST_Y)) (nth (- (length (nth i LST_Y)) 1) (nth i LST_Y)) 0.0)<br/> LSTL<br/> )<br/> )<br/> (setq i (+ 1 i))<br/> )<br/> (setq LST_Y (reverse LSTL)) ; 返回<br/> LST_Y<br/>)<br/>;;; =================================================================<br/>;;; 标注<br/>(defun TT-07 (LST_X LST_Y PT0 SC ppp / ent pt pt1 str tmp x y) ; 标注 X<br/> (foreach TMP LST_X<br/> (setq X (car TMP)<br/> Y (cadr TMP)<br/> PT (list X Y 0.0)<br/> STR (rtos (* SC (- X (car PT0))))<br/> )<br/> (if (and<br/> (/= (TT-09 X 4) (TT-09 (car Xlins) 4))<br/> (not (member (TT-09 X 4) Xlins))<br/> )<br/> (progn<br/> (setq X_LAST (max<br/> X<br/> X_LAST<br/> )<br/> PT1 (list X_LAST (- (cadr PT0) (* 1.0 SC)) 0.0) ; _标注点<br/> X_LAST (+ X_LAST (* 2 (getvar "dimtxt") (getvar "dimscale")))<br/> )<br/> (setq Xlins (cons (TT-09 X 4) Xlins))<br/> (setq Xzuih X_LAST)<br/>(princ "\n标注X坐标,坐标点") <br/>(princ PT) <br/> (vl-cmdf "_dimordinate" PT "x" "t" STR PT1) ;;标注负号<br/> ;;;; (vl-cmdf "_dimordinate" PT "x" "t" (rtos (abs (atof STR))) PT1) ;;不标注负号<br/> (setq ent (entlast))<br/> (TT-08 ent ppp PT0) ; 对齐坐标<br/> )<br/> )<br/> ) ; 标注 Y<br/> (foreach TMP LST_Y<br/> (setq Y (car TMP)<br/> X (cadr TMP)<br/> PT (list X Y 0.0)<br/> STR (rtos (* SC (- Y (cadr PT0))))<br/> )<br/> (if (and<br/> (/= (TT-09 Y 4) (TT-09 (car Ylins) 4))<br/> (not (member (TT-09 Y 4) Ylins))<br/> )<br/> (progn<br/> (setq Y_LAST (max<br/> Y<br/> Y_LAST<br/> )<br/> PT1 (list (- (car PT0) (* 1.0 SC)) Y_LAST 0.0) ; _标注点<br/> Y_LAST (+ Y_LAST (* 2 (getvar "dimtxt") (getvar "dimscale")))<br/> )<br/> (setq Ylins (cons (TT-09 Y 4) Ylins))<br/> (setq Yzuih Y_LAST)<br/>(princ "\n标注Y坐标,坐标点") <br/>(princ PT) <br/> (vl-cmdf "_dimordinate" PT "Y" "t" STR PT1) ;;标注负号 <br/> ;;;; (vl-cmdf "_dimordinate" PT "Y" "t" (rtos (abs (atof STR))) PT1) ;;不标注负号 <br/> (setq ent (entlast))<br/> (TT-08 ent ppp PT0) ; 对齐坐标</p><p> )<br/> )<br/> )<br/>)<br/>;;; =================================================================<br/>;;; 点坐标对齐<br/>(defun TT-08 (ent p0 PT0 / np14 p0x p0y p14x p14y p70) ; 点坐标对齐<br/> (setq ent (entget ent))<br/> (setq p70 (cdr (assoc 70 ent))<br/> p14x (car (cdr (assoc 14 ent)))<br/> p14y (cadr (cdr (assoc 14 ent)))<br/> )<br/> (setq p0x (car p0)<br/> p0y (cadr p0)<br/> )<br/> (cond<br/> ((= p70 38.0)<br/> (setq np14 (list p0x p14y 0.0))<br/> )<br/> ((= p70 102.0)<br/> (setq np14 (list p14x p0y 0.0))<br/> )<br/> (t<br/> (exit)<br/> )<br/> )<br/> (setq ent (subst<br/> (cons 14 nP14)<br/> (assoc 14 ent)<br/> ent<br/> )<br/> )<br/> (setq ent (subst<br/> (cons 10 PT0)<br/> (assoc 10 ent)<br/> ent<br/> )<br/> )<br/> (entmod ent)<br/> (princ)<br/>)<br/>;;; =================================================================<br/>;;; 四舍五入函数,ent:实数,n:小数点保留位数<br/>(defun TT-09 (ent n / fh)<br/> (if (>= ent 0.0)<br/> (setq FH +)<br/> (setq FH -)<br/> )<br/> (setq ent (/ (atof (itoa (fix (fh (* ent (expt 10 n)) 0.5)))) (expt 10 n)))<br/> ent<br/>)<br/>;;; =================================================================<br/>;;; 优化中心线点X坐标<br/>(defun TT-10 (ss xxx / ent ent1 i ptzhongxinx ptzhongxiny ssguol2 x1 x2 y1 y2)<br/> (setq ssguol2 '("ACAD_ISO04W100" "ACAD_ISO08W100"<br/> "CENTER" "CENTER2"<br/> "CENTERX2" "DASHDOT"<br/> "DASHDOT2" "DASHDOTX2"<br/> )<br/> ) ; 下面程序将中心线图层加入一个列表<br/> (setq ssguol2 (append<br/> SSguol2<br/> (TT-01 "ACAD_ISO04W100")<br/> (TT-01 "ACAD_ISO08W100")<br/> (TT-01 "CENTER")<br/> (TT-01 "CENTER2")<br/> (TT-01 "CENTERX2")<br/> (TT-01 "DASHDOT")<br/> (TT-01 "DASHDOT2")<br/> (TT-01 "DASHDOTX2")<br/> )<br/> ) ; 下面程序将选择集中随层的中心线加入一个列表<br/> (SETQ i 0<br/> PTzhongxinX '()<br/> PTzhongxinY '()<br/> )<br/> (while (< i (sslength ss))<br/> (setq ent (ssname ss i))<br/> (setq ent1 (entget ent))<br/> (if (or<br/> (and<br/> (member (cdr (assoc 8 ent1)) ssguol2)<br/> (/= (cdr (assoc 0 ent1)) "INSERT")<br/> (= (assoc 6 ent1) nil)<br/> )<br/> (member (cdr (assoc 6 ent1)) ssguol2)<br/> )<br/> (progn<br/> (setq X1 (car (cdr (assoc 10 ent1)))<br/> Y1 (cadr (cdr (assoc 10 ent1)))<br/> X2 (car (cdr (assoc 11 ent1)))<br/> Y2 (cadr (cdr (assoc 11 ent1)))<br/> )<br/> (if (= Y1 Y2)<br/> (progn<br/> (setq PTzhongxinX (cons (list X1 Y1 0.0) PTzhongxinX))<br/> (setq PTzhongxinX (cons (list X2 Y2 0.0) PTzhongxinX))<br/> )<br/> )<br/> (if (= X1 X2)<br/> (progn<br/> (setq PTzhongxinY (cons (list X1 Y1 0.0) PTzhongxinY))<br/> (setq PTzhongxinY (cons (list X2 Y2 0.0) PTzhongxinY))<br/> )<br/> )<br/> )<br/> )<br/> (SETQ i (+ 1 i))<br/> )<br/> (SETQ i 0)<br/> (while (< i (length PTzhongxinX))<br/> (if (member (nth i PTzhongxinX) xxx)<br/> (SETQ xxx (vl-remove (nth i PTzhongxinX) xxx))<br/> )<br/> (SETQ i (+ 1 i))<br/> )<br/> xxx<br/>)<br/>;;; =================================================================<br/>;;; 优化中心线点Y坐标<br/>(defun TT-11 (ss yyy / ent ent1 i ptzhongxinx ptzhongxiny ssguol2 x1 x2 y1 y2)<br/> (setq ssguol2 '("ACAD_ISO04W100" "ACAD_ISO08W100"<br/> "CENTER" "CENTER2"<br/> "CENTERX2" "DASHDOT"<br/> "DASHDOT2" "DASHDOTX2"<br/> )<br/> ) ; 下面程序将中心线图层加入一个列表<br/> (setq ssguol2 (append<br/> SSguol2<br/> (TT-01 "ACAD_ISO04W100")<br/> (TT-01 "ACAD_ISO08W100")<br/> (TT-01 "CENTER")<br/> (TT-01 "CENTER2")<br/> (TT-01 "CENTERX2")<br/> (TT-01 "DASHDOT")<br/> (TT-01 "DASHDOT2")<br/> (TT-01 "DASHDOTX2")<br/> )<br/> ) ; 下面程序将选择集中随层的中心线加入一个列表<br/> (SETQ i 0<br/> PTzhongxinX '()<br/> PTzhongxinY '()<br/> )<br/> (while (< i (sslength ss))<br/> (setq ent (ssname ss i))<br/> (setq ent1 (entget ent))<br/> (if (or<br/> (and<br/> (member (cdr (assoc 8 ent1)) ssguol2)<br/> (/= (cdr (assoc 0 ent1)) "INSERT")<br/> (= (assoc 6 ent1) nil)<br/> )<br/> (member (cdr (assoc 6 ent1)) ssguol2)<br/> )<br/> (progn<br/> (setq X1 (car (cdr (assoc 10 ent1)))<br/> Y1 (cadr (cdr (assoc 10 ent1)))<br/> X2 (car (cdr (assoc 11 ent1)))<br/> Y2 (cadr (cdr (assoc 11 ent1)))<br/> )<br/> (if (= Y1 Y2)<br/> (progn<br/> (setq PTzhongxinX (cons (list X1 Y1 0.0) PTzhongxinX))<br/> (setq PTzhongxinX (cons (list X2 Y2 0.0) PTzhongxinX))<br/> )<br/> )<br/> (if (= X1 X2)<br/> (progn<br/> (setq PTzhongxinY (cons (list Y1 X1 0.0) PTzhongxinY))<br/> (setq PTzhongxinY (cons (list Y2 X2 0.0) PTzhongxinY))<br/> )<br/> )<br/> )<br/> )<br/> (SETQ i (+ 1 i))<br/> )<br/> (SETQ i 0)<br/> (while (< i (length PTzhongxinY))<br/> (if (member (nth i PTzhongxinY) yyy)<br/> (SETQ yyy (vl-remove (nth i PTzhongxinY) yyy))<br/> )<br/> (SETQ i (+ 1 i))<br/> )<br/> yyy<br/>)<br/></p><p></p><p></p> 这位老大,我也有类似的一个,连思路都差不多。 <p>似乎对lisp感兴趣的人都编写过这个程序。</p><p>出现“未知命令”的时候大部分是在调用command时多了一个“”,不知道对不。</p> 要这么长吗? 怎么把圆弧过滤掉了? 这个我用了一下,还没有出现问题! 辛苦楼主,感谢楼主分享
页:
[1]