alexb119 Posted December 12, 2009 Posted December 12, 2009 Hi Is there a way to restore a attribute which has been moved, to its original (default) location? Thanks Quote
Lee Mac Posted December 12, 2009 Posted December 12, 2009 (edited) Please try this: ;; 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)) Edited December 31, 2019 by Lee Mac 1 Quote
Lee Mac Posted December 12, 2009 Posted December 12, 2009 Hi, ATTSYNC command ? Haha - nice one Gile... but I had fun anyway Quote
alexb119 Posted December 12, 2009 Author Posted December 12, 2009 Thank you Lee Mac and Gile. Gile's is of course more practical (although i have to use it inside a function and we'll see about those user responses it wants), Lee Mac's way was more instructional. Thank you both. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.