<b><BR></b>提供一个尺寸合并、分解的源程序,请各位指点意见……
在使用中会出现问题吗?
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<BR>;;;;;;;;;;尺寸合并 2004年4月;;;;;;;;;;;;<BR>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:ccb ()<BR>(set<I>var</I> "cmdecho" 0)<BR>(command "_.undo" "be")<BR>(princ "\n尺寸合并<<ver 1.0--by Rokin...>>.请选择要合并的尺寸:")<BR>(setq ss1 (ssget ":s" '((0 . "DIMENSION"))))<BR>(setq nam1 (ssname ss1 0)<BR> ent1 (entget nam1)<BR> pdim1_13 (cdr (assoc 13 ent1))<BR> pdim1_14 (cdr (assoc 14 ent1)))<BR>(setq ss2 (ssget ":s" '((0 . "DIMENSION"))))<BR>(setq nam2 (ssname ss2 0)<BR> ent2 (entget nam2)<BR> pdim2_13 (cdr (assoc 13 ent2))<BR> pdim2_14 (cdr (assoc 14 ent2)))<BR>(vl-load-com)<BR>(setq bb (list pdim1_13 pdim1_14 pdim2_13 pdim2_14))
(setq bb1<BR> (vl-sort bb<BR> (<I>function</I> (lambda (e1 e2) <BR> (< (car e1) (car e2)) ) ) ) <BR>);;end setq X坐标从小到大排序
(setq bb2<BR> (vl-sort bb<BR> (<I>function</I> (lambda (e1 e2)<BR> (< (cadr e1) (cadr e2)) ) ) )<BR>);;end setq Y坐标从小到大排序
(setq ang1 (angle pdim1_13 pdim1_14))
(setq bbb (cond ((= ang1 0) bb1)<BR> ((= ang1 pi) bb1)<BR> ((/= ang1 0) bb2)<BR> ((/= ang1 pi) bb2)))
;(setq ang2 (angle (nth 0 bbb) (nth 1 bbb))<BR>; ang3 (angle (nth 0 bbb) (nth 3 bbb)))
;(if (/= ang2 ang3)<BR>; (princ "\n不在同一直线,尺寸不能合并!")<BR>; (progn<BR> (setq ent1 (subst (cons 13 (nth 0 bbb)) (assoc 13 ent1) ent1))<BR> (setq ent1 (subst (cons 14 (nth 3 bbb)) (assoc 14 ent1) ent1))<BR> (entmod ent1)<BR> (command "erase" ss2 "")<BR>; );end progn<BR>;;);end if<BR>(command "_.undo" "e")<BR>(set<I>var</I> "cmdecho" 1)<BR>(princ));end defun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<BR>;;;;;;;;;;尺寸分解 2004年4月;;;;;;;;;;;;<BR>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<BR>(defun c:ccf ()<BR>(set<I>var</I> "cmdecho" 0)<BR>(command "_.undo" "be")<BR>(princ "\n尺寸一分为二<<ver 1.0--by Rokin...>>.\n请选择要分解的尺寸:")<BR>(setq ss1 (ssget ":s" '((0 . "DIMENSION"))))<BR>(setq point (getpoint "\n请点取分解点位置:"))
(setq nam1 (ssname ss1 0)<BR> ent1 (entget nam1)<BR> pdim1_13 (cdr (assoc 13 ent1))<BR> pdim1_14 (cdr (assoc 14 ent1)))
(command "copy" ss1 "<A target=_blank href="http://www.mjtd.com/bbs/'mailto:"" target="_blank" ><FONT color=#000000>" point "@0,0</FONT></A>")
(setq ss2 (entlast))<BR>(setq ent2 (entget ss2)<BR> pdim2_13 (cdr (assoc 13 ent2))<BR> pdim2_14 (cdr (assoc 14 ent2)))
(setq bb (list pdim1_13 pdim1_14))<BR>(setq bb1<BR> (vl-sort bb<BR> (<I>function</I> (lambda (e1 e2) <BR> (< (car e1) (car e2)) ) ) ) <BR>);;end setq X坐标从小到大排序<BR>(setq bb2<BR> (vl-sort bb<BR> (<I>function</I> (lambda (e1 e2)<BR> (< (cadr e1) (cadr e2)) ) ) )<BR>);;end setq Y坐标从小到大排序
(setq ang (angle pdim1_13 pdim1_14))
(setq bbb (if (or (= ang 0) (= ang pi)) bb1 bb2))<BR> (cond<BR> ((> (angle point (nth 0 bbb)) (angle (nth 1 bbb) (nth 0 bbb)))<BR> (setq cankaodian (polar point (+ (angle (nth 0 bbb) (nth 1 bbb)) (* pi 1.5)) 90000)))<BR> ((< (angle point (nth 0 bbb)) (angle (nth 1 bbb) (nth 0 bbb)))<BR> (setq cankaodian (polar point (+ (angle (nth 0 bbb) (nth 1 bbb)) (* pi 0.5)) 90000)))<BR> ((= (angle point (nth 0 bbb)) (angle (nth 1 bbb) (nth 0 bbb)))<BR> (setq cankaodian point))<BR> );cond<BR>(setq mid (inters pdim1_13 pdim1_14 point cankaodian))
(if (= (nth 0 bbb) pdim1_13)<BR>(setq ent1 (subst (cons 14 mid) (assoc 14 ent1) ent1))<BR>(setq ent1 (subst (cons 13 mid) (assoc 13 ent1) ent1))<BR>);end if<BR>(entmod ent1)
(if (= (nth 0 bbb) pdim1_13)<BR>(setq ent2 (subst (cons 13 mid) (assoc 13 ent2) ent2))<BR>(setq ent2 (subst (cons 14 mid) (assoc 14 ent2) ent2))<BR>);end if<BR>(entmod ent2)<BR>(command "_.undo" "e")<BR>(set<I>var</I> "cmdecho" 1)<BR>(princ));end defun
来自明经社区!
|