Jump to content

Recommended Posts

Posted

Hi

Is there a way to restore a attribute which has been moved, to its original (default) location?

Thanks

Posted (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 by Lee Mac
  • Like 1
Posted
Hi,

 

ATTSYNC command ?

 

Haha - nice one Gile... but I had fun anyway :)

Posted

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...