- 积分
- 8930
- 明经币
- 个
- 注册时间
- 2008-12-10
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2012-9-3 23:30:21
|
显示全部楼层
本帖最后由 jh1005 于 2012-9-3 23:33 编辑
朽木大师 发表于 2012-9-3 22:29
不会修改,没看明白,我是菜菜
修改dt-Leader函数,看红色那句:
(defun dt-Leader ;动态引线
;对象/点 文字 颜色 图层 样式 字高
(ent str col lay sty gao / mspace i wenzi a b c d aa bb cc dd ee ff gg Leader m)
(if (and (= (getvar "tilemode") 0) (= (getvar "cvport") 1))
(setq mspace (vla-get-paperspace (vla-get-activedocument (vlax-get-acad-object))))
(setq mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
)
(setq i T)
(while i
(setq a (grread T 12 1) b (car a) c (cadr a)) ;;b=5移动,b=3左键,c=0右键,;;c=13回车,c=32空格
(cond ((= b 5) ;当鼠标移动时
(setq a (trans (cadr a) 1 0)) ;鼠标移动点
(cond
((= (type ent) 'LIST) (setq d ent)) ;固定点
((= (type ent) 'ENAME) (setq d (vlax-curve-getclosestpointto ent a))) ;a到对象ent的最近点)
)
(setq aa (car a) bb (cadr a) cc (caddr a)) ;提取 a 的x,y,z
(setq dd (car d) ee (cadr d) ff (caddr d)) ;提取 d 的x,y,z
;★创建引线★
(setq gg (vlax-make-safearray vlax-vbDouble '(0 . 5))) ;建立数字表
(vlax-safearray-fill gg (list dd ee ff aa (- (cadr a) 2) cc)) ;填满gg
(if (not Leader)
(progn
(setq m (vla-AddMText mspace (vlax-3d-point (list aa bb)) 0 str)) ;创建文字
(if col (vla-put-color m col))
(if lay (vla-put-layer m lay))
(if sty (vla-put-StyleName m sty))
(if gao (vla-put-height m gao))
(setq wenzi (vlax-make-safearray vlax-vbString '(1 . 9))) ;建立字符表
(vlax-safearray-fill wenzi '("TopLeft" "TopCenter" "TopRight" "MiddleLeft"
"MiddleCenter" "MiddleRight" "BottomLeft" "BottomCenter" "BottomRight")) ;填满wenzi
(vla-put-attachmentpoint m 7) ;更新文字的贴附点为7
(setq Leader (vla-AddLeader mspace gg m acLineWithArrow)) ;有箭头的线
(if col (vla-put-color Leader col))
(if lay (vla-put-layer Leader lay))
(if gao (vla-put-arrowheadsize Leader gao))
(vla-put-ArrowheadType Leader acArrowDot)
)
)
(vla-put-insertionpoint m (vlax-3d-point (list aa (- (cadr a) 1.5)))) ;更新文字插入点
(vla-put-coordinates Leader gg) ;更新引线插入点
(vla-put-verticaltextposition Leader 1) ;引线自动判断方向
)
((= b 3) (setq i nil)) ;左键结束while
) ;end_cond
) ;end_while
(princ)
)
|
|