这是我最近发现并稍加修改的一个惯例;然而,我仍然无法找到替代第#6行的方法,使用NENTSEL将属性标记传递到函数中,而不需要用户输入。
- (defun widedit (/ aDoc x attent uwd option tag blk bn)
- (vl-load-com)
- (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
- (if (and (setq x (car (nentsel "\nSelect attribute: ")))
- (eq "ATTRIB" (cdr (assoc 0 (entget x))))
- (setq attent (vlax-ename->vla-object x))
-
- ;; Display Current Text Width Factor
- (princ (strcat "\nCurrent Width is <" (rtos (vla-get-scalefactor attent) 2)"> "))
-
- ;; Set width to 0.7
- (setq uwd 0.7)) ;(getreal "\nEnter new width: ")))
-
- (progn
- (initget "Y N")
- (setq option "N")
- ;(cond ((getkword "\nApply width to all Attribute of the same block? [Yes/no] <N>: "))( "N" )))
- (if (eq option "N")
- (vla-put-scalefactor attent uwd)
- (progn
- (setq tag (vla-get-tagstring attent))
- (setq Blk
- (vla-ObjectIdToObject aDoc
- (vla-get-OwnerId attent)
- )
-
- Bn (vla-get-effectivename blk)
- )
- (vlax-for itm (vla-item (vla-get-blocks aDoc) bn)
- (if
- (and (eq (vla-get-objectname itm) "AcDbAttributeDefinition")
- (eq (vla-get-tagstring itm) tag)
- )
- (vla-put-scalefactor itm uwd)
- )
- )
- (vlax-for layout (vla-get-layouts aDoc)
- (vlax-for i (vla-get-block layout)
- (if (and
- (eq (vla-get-objectname i) "AcDbBlockReference")
- (eq (Vla-get-hasAttributes i) :Vlax-true)
- (eq (vla-get-effectivename i) bn))
-
- (foreach itm (vlax-invoke i 'GetAttributes)
- (if (eq (vla-get-tagstring itm) tag)
- (vla-put-scalefactor itm uwd))))))
- )
- ) ;; end if
- ) ;; end progn
- (vl-some
- '(lambda (j) (if (null (eval (car j))) (princ (cadr j))
- ))
- '((x "\n<<None Selected>>")
- (attent "\n<<Selected object not an Attribute>>")
- (uwd "\n<<No Width value>>"))
- )
- )
- (princ)
- ) ;; end defun
|