hicoffee 发表于 2008-2-15 10:14:00

动态生成序号球(vla-put-coordinates的用法)

<p><font face="宋体" size="2">;一个动态生成序号球的小程序 <br/>;点击零件上的点,序号球(圆,号码)及引线末端随鼠标动态移动。可连续生成,号码自增。本例序号球大小尤其适用于英制机械图纸。</font></p><p><font color="#007700">(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">defun c</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">:</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">test </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">() <br/>&nbsp;&nbsp;(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">vl</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">load</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">com</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">) <br/>&nbsp;&nbsp;(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">setq h </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">(* (</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">getvar </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#dd0000" style="FONT-SIZE: 10pt;">"dimscale"</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">)(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">getvar </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#dd0000" style="FONT-SIZE: 10pt;">"dimtxt"</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">)) <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">r h <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sn 1</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">) <br/>&nbsp;&nbsp;(while </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">sn <br/>&nbsp;&nbsp;&nbsp;&nbsp;</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">setq p0 </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">getpoint </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#dd0000" style="FONT-SIZE: 10pt;">"\nPick Insert Point:"</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">)) <br/>&nbsp;&nbsp;&nbsp;&nbsp;(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">setq loop t</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">) <br/>&nbsp;&nbsp;&nbsp;&nbsp;(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">command </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#dd0000" style="FONT-SIZE: 10pt;">"circle" </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">p0 r</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">) <br/>&nbsp;&nbsp;&nbsp;&nbsp;(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">setq ceo </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">vlax</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">ename</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-&gt;</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">vla</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">object </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">entlast</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">))) <br/>&nbsp;&nbsp;&nbsp;&nbsp;(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">vl</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">cmdf </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#dd0000" style="FONT-SIZE: 10pt;">"text" "j" "m" </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">p0 h 0 </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">itoa sn</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">) </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#dd0000" style="FONT-SIZE: 10pt;">""</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">) <br/>&nbsp;&nbsp;&nbsp;&nbsp;(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">setq teo </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">vlax</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">ename</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-&gt;</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">vla</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">object </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">entlast</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">))) <br/>&nbsp;&nbsp;&nbsp;&nbsp;(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">command </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#dd0000" style="FONT-SIZE: 10pt;">"leader" </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">p0 </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">polar p0 </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">(/ </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">pi 4</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">) </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">0.1</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">)&nbsp;&nbsp;</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#dd0000" style="FONT-SIZE: 10pt;">"" "" "n"</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">) <br/>&nbsp;&nbsp;&nbsp;&nbsp;(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">setq le </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">entlast</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">)) <br/>&nbsp;&nbsp;&nbsp;&nbsp;(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">setq leo </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">vlax</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">ename</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-&gt;</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">vla</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">object le</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">)) <br/>&nbsp;&nbsp;&nbsp;&nbsp;(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">setq p1 </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">vlax</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">curve</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">getstartpoint le</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">)) <br/>&nbsp;&nbsp;&nbsp;&nbsp;(while </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">loop <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">setq p </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">grread T</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">)) <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">setq k </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">car p</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">) <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">p </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">cadr p</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">)) <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(if (= </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">k 3</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">)(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">setq loop nil</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">)) <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">vla</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">put</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">center ceo </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">vlax</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">3d</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">point p</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">)) <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">vla</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">put</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">textalignmentpoint teo </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">vlax</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">3d</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">point p</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">)) <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">vla</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">update ceo</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">) <br/>&nbsp;&nbsp;&nbsp;&nbsp;(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">setq sl </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">(</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">vlax</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">make</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">safearray vlax</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">-</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">vbdouble </font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#007700" style="FONT-SIZE: 10pt;">'</font><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;">(0 . 5))) <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(setq sa (vlax-safearray-fill sl (append p1 (polar p (angle p p1) r)))) <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(vla-put-coordinates leo sa) <br/>&nbsp;&nbsp;&nbsp;&nbsp;) <br/>&nbsp;&nbsp;&nbsp;&nbsp;(setq sn (1+ sn)) <br/>&nbsp;&nbsp;&nbsp;&nbsp;(setq ct (getstring "\nContinue&lt;N&gt;?")) <br/>&nbsp;&nbsp;&nbsp;&nbsp;(if (= (strcase ct) "N")(setq sn nil)) <br/>&nbsp;&nbsp;) <br/>)</font></p><p><font face="宋体,verdana, Airal,Helvetica,Geneva" color="#0000bb" style="FONT-SIZE: 10pt;"><br/><font color="#000000">&nbsp;&nbsp;&nbsp; 一个不错的程序,但有一个BUG,大家讨论一下,就是当半径r等于整数时,如果打开捕捉后移动鼠标,移动r个单位后出错退出,错误:“Automation 错误。 点表无效”。也就是说如果sa中的两顶点坐标成一点时,(vla-put-coordinates leo sa)是通不过的,为什么?</font></font><!--Element not supported - Type: 8 Name: #comment--></p>

ZZXXQQ 发表于 2008-2-15 13:04:00

本帖最后由 作者 于 2008-2-15 13:10:57 编辑

LEADER的起点和终点不能是一点。这样试试

(defun c:test ()
(vl-load-com)
(setq h (* (getvar "dimscale")(getvar "dimtxt"))
      r h
       sn 1)
(while sn
    (setq p0 (getpoint "\nPick Insert Point:"))
    (setq loop t)
    (command "circle" p0 r)
    (setq ceo (vlax-ename->vla-object (entlast)))
    (vl-cmdf "text" "j" "m" p0 h 0 (itoa sn) "")
    (setq teo (vlax-ename->vla-object (entlast)))
    (command "leader" p0 (polar p0 (/ pi 4) 0.1)"" "" "n")
    (setq le (entlast))
    (setq leo (vlax-ename->vla-object le))
    (setq p1 (vlax-curve-getstartpoint le))
    (while loop
      (setq p (grread T))
      (setq k (car p)
            p (cadr p))
      (if (= k 3)(setq loop nil))
      (vla-put-center ceo (vlax-3d-point p))
      (vla-put-textalignmentpoint teo (vlax-3d-point p))
      (vla-update ceo)
    (setq sl (vlax-make-safearray vlax-vbdouble '(0 . 5)))
       (setq sa (vlax-safearray-fill sl (append p1 (polar p (angle p p1) r))))
       (if (> (distance (polar p (angle p p1) r) p0) 0.0) (vla-put-coordinates leo sa))
    )
    (setq sn (1+ sn))
    (setq ct (getstring "\nContinue<N>?"))
    (if (= (strcase ct) "N")(setq sn nil))
)
)

;这是纯LISP
(defun c:test (/ h r sn p0 ceo teo leo p1 k p)
(setq h (getvar "dimscale")
       h (* (if (= h 0) 1 h) (getvar "dimtxt"))
       r h sn 1)
(while (setq p0 (getpoint "\nPick Insert Point:"))
(command "circle" p0 r)
(setq ceo (entget (entlast)))
(command "text" "j" "m" p0 h 0 (itoa sn) "")
(setq teo (entget (entlast)))
(command "leader" p0 (polar p0 (/ pi 4) 0.1)"" "" "n")
(setq leo (entget (entlast)))
(setq p1 (cdr (assoc 10 leo)) k 1)
(while (/= k 3)
   (setq p (grread T))
   (setq k (car p) p (cadr p))
   (setq ceo (subst (cons 10 p) (assoc 10 ceo) ceo))
   (entmod ceo)
   (setq teo (subst (cons 11 p) (assoc 11 teo) teo))
   (entmod teo)
   (setq p (polar p (angle p p1) r))
   (setq leo (subst (cons 10 p) (assoc 10 (reverse leo)) leo))
   (if (> (distance p p0) 0.0) (entmod leo))
)
(setq sn (1+ sn))
)
(princ)
)

hicoffee 发表于 2008-2-15 13:38:00

<font color="#0000bb">是的,但我想知道是不是vla-put-coordinates函数不能接受同一点组成的数组结构?</font>

ZZXXQQ 发表于 2008-2-15 16:24:00

<p>不是vla-put-coordinates函数的问题是LEADER实体生成问题</p>

hicoffee 发表于 2008-2-15 16:31:00

明白,也就是说在实体生成的过程中出错了,谢谢。

h_fog 发表于 2017-9-20 21:16:36

绝世好文,不得不顶

305341043 发表于 2023-3-23 19:33:16

学习了

Klein 发表于 2023-3-23 21:07:58

grread学习了
页: [1]
查看完整版本: 动态生成序号球(vla-put-coordinates的用法)