尝试获取属性值的新方法,并在MLeader中使用它,但我在att中没有完全获取值。我在这里旋转轮子,有人能检查一下我是否正确获取了属性吗?完成下面的代码。
作为免责声明,我对AutoLISP非常陌生。希望编辑此函数以消除崩溃。
- (defun c:MLCALLOUT (/)
- (vl-load-com)
- (sssetfirst nil nil) ; Deselect everything if anything is selected
- (setq myMode (getvar "tilemode")) ; myMode=0 means we're in paper space
- (if (= myMode 0) (command ".mspace")) ; if in paper space, switch to model space
- (setq ss (ssget "_+.:E:S" '((0 . "INSERT,ARC,CIRCLE,*POLYLINE")))) ; get the entity
- (setq e (ssname ss 0)) ; get the entity's handle
- (setq p (cadr (cadddr (car (ssnamex ss)))))
- (setq curLyr (getvar "clayer"))
- (setq myScale (getvar "cannoscale")) ; get the annotation scale
- (setq myScale (atoi (substr myScale 3 (- (strlen myScale) 2)))) ;get the cannoscale
- (if (= myMode 0) (progn (command ".pspace")(setq p (list 0 0 0 )))) ; if we were in paper space, switch back
- (setq xT (cdr (assoc 0 (entget e))))
- ; AUD insert Callout Command
- (command "_AUDCALLOUTINSERT" e "" p)
-
- (setq xEnt (entlast))
- (setq myEnt xEnt)
- (setq insLyr (cdr (assoc 8 (entget xEnt))))
-
- ; Get the value of ATTRIBUTE1
- (setq blk (vlax-ename->vla-object myEnt))
- (setq tag "ATTRIBUTE1")
- (vl-some '(lambda ( att ) (if (= tag (strcase (vla-get-tagstring att))) (vla-get-textstring att)))
- (vlax-invoke blk 'getattributes)
- )
- (entdel xEnt) ; Delete the block entity from AUD Callout Command
- (command "-layer" "set" insLyr "") ; Set to callout layer
- ; Create multileader
- (setq PT1 (getpoint "\nPick start point of leader: "))
- (setq PT2 (getpoint PT1 "\nPick landing point: "))
- (command "._mleader" PT1 PT2 att)
- (command "-layer" "set" curLyr "") ; Restore previous layer
- )
|