找回密码
 [加入论坛]
查看: 2166|回复: 2

[ZT] 尺寸合并,分解

[复制链接]
2443725 发表于 2004-5-11 20:14 | 显示全部楼层 |阅读模式
<b><BR></b>提供一个尺寸合并、分解的源程序,请各位指点意见……



在使用中会出现问题吗?


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<BR>;;;;;;;;;;尺寸合并 2004年4月;;;;;;;;;;;;<BR>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(defun c:ccb ()<BR>(set<I>var</I> "cmdecho" 0)<BR>(command "_.undo" "be")<BR>(princ "\n尺寸合并&lt;&lt;ver 1.0--by Rokin...&gt;&gt;.请选择要合并的尺寸:")<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>                                                                                                                                                                                                 (&lt; (car e1) (car e2)) ) ) ) <BR>);;end setq X坐标从小到大排序


(setq bb2<BR>                         (vl-sort bb<BR>                                                                                                 (<I>function</I> (lambda (e1 e2)<BR>                                                                                                                                                                                                 (&lt; (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尺寸一分为二&lt;&lt;ver 1.0--by Rokin...&gt;&gt;.\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:&quot;" 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>                                                                                                                                                                                                 (&lt; (car e1) (car e2)) ) ) ) <BR>);;end setq X坐标从小到大排序<BR>(setq bb2<BR>                         (vl-sort bb<BR>                                                                                                 (<I>function</I> (lambda (e1 e2)<BR>                                                                                                                                                                                                 (&lt; (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>                 ((&gt; (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>                 ((&lt; (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



来自明经社区!

swaywood 发表于 2004-5-11 20:27 | 显示全部楼层
好东西,先看看
回复 顶 踩

使用道具 举报

hpy 发表于 2004-5-12 04:16 | 显示全部楼层
先试一下,看好不好用。
回复 顶 踩

使用道具 举报

您需要登录后才可以回帖 登录 | [加入论坛]

本版积分规则

手机版|化工技术网- 赠人玫瑰 手有余香 ( 苏ICP备14035884号 )

GMT+8, 2026-12-1 16:03

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表