REPLACE.LSP - (Block Replace) - (c) 1990 Richard D. Howard
all rights reserved - no warranty, express or implied
The included files may be used and copied for non-profit
purposes only. If you wish to include any of the files in a
commercial program, contact the author.
---------------
REPLACE, replaces selected blocks with a specified block,
retaining all of the original properties. REPLACE handles blocks
with attribute data correctly, and can optionally allow entry of
new attributes at runtime. This makes REPLACE ideal for updating
blocks whose definition has changed (AutoCAD does not updates the
attributes in such instances). When replacing attributes, REPLACE
actually erases the old block and substitutes the new one
retaining as much of the former data as possible. The two fields
that are definately modified are "entity name", and "handle
number" (because the block really is new). If you require these
to remain the same, don't use REPLACE. If no attributes are
present, REPLACE simply updates the name attached to the original
block insert. This retains ALL the inserts data, including the
entity name and handle.
Does the new block have the same attributes and tags as the old block? If so, I'd think you'd just be able to redefine the block.
Try this one from here:
http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Amends/td-p/806704/page/2 (http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Amends/td-p/806704/page/2)
No, the lisp in the post is by Richard D. Howard and will keep attributes if the name is the same
Long time no see there Mojo! Welcome back stranger. :)
(defun c:attsync2 (/ _name _gettatts _lst atts e name ss)
(defun _lst (ss / e n out)
(setq n -1)
(if (= (type ss) 'pickset)
(while (setq e (ssname ss (setq n (1+ n)))) (setq out (cons (vlax-ename->vla-object e) out)))
)
)
(defun _attpositions (block / att result)
(foreach att (vlax-invoke block 'getattributes)
(setq result (cons (list (vla-get-handle att)
(vlax-get att 'insertionpoint)
(vlax-get att 'textalignmentpoint)
)
result
)
)
)
)
(defun _name (b)
(cond ((vlax-property-available-p b 'effectivename) (vla-get-effectivename b))
((vlax-property-available-p b 'name) (vla-get-name b))
)
)
(if (and (setq e (car (entsel "\nSelect block to sync: ")))
(setq name (_name (vlax-ename->vla-object e)))
(setq ss (ssget "_x" (list (cons 0 "insert"))))
)
(progn (foreach x (_lst ss) (and (eq (_name x) name) (setq atts (cons (_attpositions x) atts))))
(command "._attsync" "_s" e "_yes")
(foreach x (apply 'append atts)
(if (and (setq e (handent (car x))) (setq e (vlax-ename->vla-object e)))
(progn (vl-catch-all-apply 'vlax-put (list e 'insertionpoint (cadr x)))
(vl-catch-all-apply 'vlax-put (list e 'textalignmentpoint (caddr x)))
)
)
)
)
)
(princ)
)
I tried to post earlier today but couldn't get to the swamp... glad to see its working again. :)
Hello Mark! thanks! Good to be back. Can you send me my password for my original account to verticalmojo@gmail? seems that when I try to reset it sends it to the @swamp.org email I used to use and I'm not sure if it exists and if it did I wouldn't have a clue how to get into it. No rush, just when you get a chance... Thanks!
The profile for VerticalMojo has been updated successfully.
You are correct, my mistake, I misunderstood your request.Perhaps I could have explained my request better, so I'm sure that I am to blame for that! :laugh:
Not the prettiest thing but give it a try :laugh: Keep in mind this only looks at the insertion points and tries to place them in the original location found.
Try that. :)
Thank ronjonp
Something I've been looking for. :-) :-) :-) :-)
Danke ronjonp
Sowas habe ich schon lange gesucht.
Super Thank you this works Perfectly :) :) :):)
The best Lisp in my collection