caoyin 发表于 2008-5-21 09:00:00
我测试仍然没问题,你可以测试一下 (command "_.boundary" "")在 acad2002上运行的情况,我用2009xd-xdcad 发表于 2008-5-21 11:30:00
本帖最后由 作者 于 2008-5-21 11:36:46 编辑 <br /><br /> <p></p><p>可惜我的2002版本总是出现问题,应该能更改吧?</p>xd-xdcad 发表于 2008-5-21 11:35:00
输入命令_.boundary,显示如图caoyin 发表于 2008-5-21 12:06:00
(defun c:JZ (/ err)<br/> (defun algion (msg / ss lst i vlalst boxlst<br/> x cor1 cor2 findboxpt newboxpt<br/> en1 en enlst y y2<br/> )<br/> (princ msg)<br/> (setq ss (ssget '((0 . "text"))))<br/> <font color="#ff0000">(if (not ss) (exit))</font><br/> (setq lst nil)<br/> (setq i 0)<br/> (repeat (sslength ss)<br/> (setq lst (cons (ssname ss i) lst))<br/> (setq i (1+ i))<br/> )<br/> (setq vlalst (mapcar 'vlax-ename->vla-object lst))<br/> (setq boxlst (mapcar '(lambda (x / cor1 cor2)<br/> (vla-GetBoundingBox x 'cor1 'cor2)<br/> (list (vlax-safearray->list cor1)<br/> (vlax-safearray->list cor2)<br/> )<br/> )<br/> vlalst<br/> )<br/> )<br/> (setq<br/> findboxpt (mapcar '(lambda (x)<br/> (polar (car x)<br/> (angle (car x) (cadr x))<br/> (/ (DISTANCE (car x) (cadr x)) 2.0)<br/> )<br/> )<br/> boxlst<br/> )<br/> )<br/> (setq newboxpt (mapcar '(lambda (x)<br/> (setq en1 (entlast))<br/> (vl-cmdf "_boundary" x "")<br/> (setq en (entlast))<br/> (if (not (equal en1 en))<br/> (progn<br/> (setq enlst (entget en))<br/> (setq lst (vl-remove-if-not<br/> '(lambda (y) (= (car y) 10))<br/> enlst<br/> )<br/> )<br/> (setq cor1 (vl-remove 10 (car lst))<br/> cor2 (vl-remove 10 (nth 2 lst))<br/> )<br/> (while (setq en1 (entnext en1))<br/> (entdel en1)<br/> )<br/> (polar cor1<br/> (angle cor1 cor2)<br/> (/ (DISTANCE cor1 cor2) 2.0)<br/> )<br/> )<br/> )<br/> )<br/> findboxpt<br/> )<br/> )<br/> (mapcar '(lambda (x y y2)<br/> (vla-move x (vlax-3d-point y) (vlax-3d-point y2))<br/> )<br/> vlalst<br/> findboxpt<br/> newboxpt<br/> )<br/> )<br/> (setq err (VL-CATCH-ALL-APPLY 'algion (list "\n师兄 选择单行文字: ")))<br/> (princ)<br/>)xd-xdcad 发表于 2008-5-21 13:36:00
非常抱歉,问题依旧sailorcwx 发表于 2008-5-21 14:03:00
<p>将1楼的程序中(setq newboxpt (mapcar '(lambda (x)</p><p>改成(setq newboxpt (mapcar '(lambda (x / en1 en)</p><p>就可以了</p>sailorcwx 发表于 2008-5-21 14:06:00
或者把(entdel en1)改成(vl-cmdf "erase" en1 "")应该都可以xd-xdcad 发表于 2008-5-21 14:26:00
sailorcwx发表于2008-5-21 14:06:00static/image/common/back.gif或者把(entdel en1)改成(vl-cmdf \"erase\" en1 \"\")应该都可以<p>这个方法可行,问题解决了,但出现了另外一个问题,执行命令后,按CTRL+Z,在恢复到原先的状态的同时,还会出现一个边框,</p>
sailorcwx 发表于 2008-5-21 15:49:00
<p>那你用一个command把你的程序包起来嘛</p>sailorcwx 发表于 2008-5-21 19:14:00
<p>我推荐的是这种改法</p><p>将1楼的程序中(setq newboxpt (mapcar '(lambda (x)</p><p>改成(setq newboxpt (mapcar '(lambda (x / en1 en)</p>