请尝试以下操作:
- ;; Restore Attribute Position ~ By Lee Mac ~ 12.12.2009
- (defun c:ResAtt (/ *error* BLK DOC ENT NPT OBJ UFLAG VEC)
- (vl-load-com)
- (setq doc (vla-get-ActiveDocument
- (vlax-get-acad-object)))
- (defun *error* (msg)
- (and uflag (vla-EndUndoMark doc))
- (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
- (princ (strcat "\n** Error: " msg " **")))
- (princ))
-
- (while
- (progn
- (setq ent (car (nentsel "\nSelect Attribute to Reset: ")))
- (cond ( (eq 'ENAME (type ent))
- (if (eq "AcDbAttribute"
- (vla-get-ObjectName
- (setq obj (vlax-ename->vla-object ent))))
-
- (if (eq :vlax-true (vla-get-LockPosition obj))
- (princ "\n** Invalid Attribute Type **")
- (progn
- (setq uflag (not (vla-StartUndoMark doc)))
- (vlax-for sub (vla-item
- (vla-get-Blocks doc)
- (vla-get-Name
- (setq blk (vla-ObjectIdtoObject doc (vla-get-OwnerID obj)))))
- (if (and (eq "AcDbAttributeDefinition" (vla-get-ObjectName sub))
- (apply (function eq)
- (mapcar (function strcase)
- (mapcar (function vla-get-TagString) (list obj sub)))))
-
- (setq vec (vlax-safearray->list
- (vlax-variant-value
- (vlax-get-property sub
-
- (if (eq acAlignmentLeft (vla-get-Alignment obj))
- 'InsertionPoint 'TextAlignmentPoint)))))))
- (if vec
- (progn
- (setq nPt (mapcar (function +) (vlax-safearray->list
- (vlax-variant-value
- (vla-get-InsertionPoint blk))) vec))
- (vlax-put-property obj
-
- (if (eq acAlignmentLeft (vla-get-Alignment obj))
-
- 'InsertionPoint 'TextAlignmentPoint)
- (vlax-3D-point nPt))))
-
- (setq uflag (vla-EndUndoMark doc))))
-
- (princ "\n** Object Must be an Attribute **"))))))
- (princ))
|