;一个动态生成序号球的小程序 ;点击零件上的点,序号球(圆,号码)及引线末端随鼠标动态移动。可连续生成,号码自增。本例序号球大小尤其适用于英制机械图纸。 (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)))) (vla-put-coordinates leo sa) ) (setq sn (1+ sn)) (setq ct (getstring "\nContinue<N>?")) (if (= (strcase ct) "N")(setq sn nil)) ) ) 一个不错的程序,但有一个BUG,大家讨论一下,就是当半径r等于整数时,如果打开捕捉后移动鼠标,移动r个单位后出错退出,错误:“Automation 错误。 点表无效”。也就是说如果sa中的两顶点坐标成一点时,(vla-put-coordinates leo sa)是通不过的,为什么?
|