ucmeflyby Posted April 10, 2009 Share Posted April 10, 2009 I have several .dwg's or "maps". On these maps I have a block that I am in need of redefining. So far I have created a separate .dwg for the block that meets my new requirements. Upon inserting the "new" block and using either the attsync or battman commands to update all the "old" blocks... the old blocks lose all sense of direction, flipping and mirroring about. From everything that I have been able to find today, this is a know problem. What I have not found is a suggested method to fix this problem. Ideally I would like to leave the "old" blocks alone mostly, and simply add new (blank) tags or fields to them. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 11, 2009 Share Posted April 11, 2009 Does "blockreplace" help at all? (Express I think) Quote Link to comment Share on other sites More sharing options...
ucmeflyby Posted April 11, 2009 Author Share Posted April 11, 2009 Lee Mac, Blockreplace does not seem to work. The old blocks do not have the new attributes, though they do have the new block name. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 11, 2009 Share Posted April 11, 2009 You could try this, I altered an old routine I made ;; Block Replacement by Lee McDonnell (defun c:brep (/ bdef blk brep ss doc spc newblk att attLst insatt attName i j) (vl-load-com) (setq bdef (getvar "INSNAME")) (while (not blk) (setq blk (getstring t (strcat "\nSpecify Block to be Inserted <" bdef ">: "))) (cond ((eq "" blk) (setq blk bdef)) ((and (snvalid blk) (tblsearch "BLOCK" blk))) ((and (snvalid blk) (findfile (strcat blk ".dwg"))) (command "_.insert" blk) (command)) (T (setq blk nil bdef "")))) (if (setq brep (car (entsel "\nSelect Block to be Replaced: "))) (progn (if (setq ss (ssget "X" (list (cons 0 "INSERT") (cons 2 (cdr (assoc 2 (entget brep)))) (if (getvar "CTAB")(cons 410 (getvar "CTAB")) (cons 67 (- 1 (getvar "TILEMODE"))))))) (progn (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)) spc (if (zerop (vla-get-activespace doc)) (if (= (vla-get-mspace doc) :vlax-true) (vla-get-modelspace doc) (vla-get-paperspace doc)) (vla-get-modelspace doc)) i 0 j 0) (vla-EndUndoMark doc) (vla-StartUndoMark doc) (foreach ent (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex ss))) (setq newblk (vla-insertblock spc (vla-get-InsertionPoint ent) blk (vla-get-xscalefactor ent) (vla-get-yscalefactor ent) (vla-get-zscalefactor ent) (vla-get-rotation ent))) (if (eq :vlax-true (vla-get-HasAttributes ent)) (progn (setq att (entnext (vlax-vla-object->ename ent))) (while (not (eq "SEQEND" (cdadr (entget att)))) (setq attLst (cons (cons (cdr (assoc 2 (entget att))) (cdr (assoc 1 (entget att)))) attLst) att (entnext att))) (if (eq :vlax-true (vla-get-HasAttributes newblk)) (progn (setq insatt (entnext (vlax-vla-object->ename newblk))) (while (not (eq "SEQEND" (cdadr (entget insatt)))) (setq attName (cdr (assoc 2 (entget insatt)))) (if (assoc attName attLst) (entmod (subst (cons 1 (cdr (assoc attName attLst))) (assoc 1 (entget insatt)) (entget insatt)))) (setq insatt (entnext insatt)))) (princ "\n<!> Inserted Block Doesn't have Attributes <!>")))) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-delete (list ent))) (setq i (1+ i)) (setq j (1+ j)))) (princ (strcat "\n" (itoa j) " Blocks Replaced" (if (zerop i) "." (strcat (itoa i) " were on a Locked Layer!")))) (vla-EndUndoMark doc)) (princ "\n<!> No Blocks Found <!>"))) (princ "\n<!> Replacement Block not Valid <!>")) (princ)) Quote Link to comment Share on other sites More sharing options...
ucmeflyby Posted April 11, 2009 Author Share Posted April 11, 2009 I will not be able to try it until I get back to my office on Monday. I will give it a go and see what happens. Thank you. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 11, 2009 Share Posted April 11, 2009 I will not be able to try it until I get back to my office on Monday. I will give it a go and see what happens. Thank you. Working on a bank holiday - you are devoted... No Problems - it is untested, so we shall see how it goes! Lee Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 11, 2009 Share Posted April 11, 2009 Ahh, btw this is a completely "VL" version of the LISP ~ just thought I'd stick to one or the other, instead of messing around with DXF tables... [color=#8b4513][color=Navy];; Block Replacement by Lee McDonnell (defun c:brep (/ bdef blk brep ss doc spc newblk att attLst attTg i j) (vl-load-com) (setq bdef (getvar "INSNAME")) ;; Get Block to be Inserted (while (not blk) (setq blk (getstring t (strcat "\nSpecify Block to be Inserted <" bdef ">: "))) (cond ((eq "" blk) (setq blk bdef)) ((and (snvalid blk) (tblsearch "BLOCK" blk))) ((and (snvalid blk) (findfile (strcat blk ".dwg"))) (command "_.insert" blk) (command)) (T (setq blk nil bdef "")))) ;; Get Block to be Replaced (if (and (setq brep (car (entsel "\nSelect Block to be Replaced: "))) (= "INSERT" (cdadr (entget brep)))) (progn (if (setq ss (ssget "X" (list (cons 0 "INSERT") (cons 2 (cdr (assoc 2 (entget brep)))) (if (getvar "CTAB") (cons 410 (getvar "CTAB")) (cons 67 (- 1 (getvar "TILEMODE"))))))) (progn (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)) spc (if (zerop (vla-get-activespace doc)) (if (= (vla-get-mspace doc) :vlax-true) (vla-get-modelspace doc) (vla-get-paperspace doc)) (vla-get-modelspace doc)) i 0 j 0) (vla-EndUndoMark doc) (vla-StartUndoMark doc) ;; Replace Block (foreach ent (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex ss))) (setq newblk (vla-insertblock spc (vla-get-InsertionPoint ent) blk (vla-get-xscalefactor ent) (vla-get-yscalefactor ent) (vla-get-zscalefactor ent) (vla-get-rotation ent))) ;; Replace Attributes (if (eq :vlax-true (vla-get-HasAttributes ent)) (progn (foreach att (vlax-safearray->list (vlax-variant-value (vla-getAttributes ent))) (setq attLst (cons (cons (vla-get-TagString att) (vla-get-TextString att)) attLst))) (if (eq :vlax-true (vla-get-HasAttributes newblk)) (progn (foreach att (vlax-safearray->list (vlax-variant-value (vla-getAttributes newblk))) (if (setq attTg (assoc (vla-get-TagString att) attLst)) (vla-put-TextString att (cdr attTg))))) (princ "\n<!> Inserted Block Doesn't have Attributes <!>")))) ;; Delete Original (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-delete (list ent))) (setq i (1+ i)) (setq j (1+ j))) (setq attLst nil)) (princ (strcat "\n" (itoa j) " Blocks Replaced" (if (zerop i) "." (strcat (itoa i) " were on a Locked Layer!")))) (vla-EndUndoMark doc)) (princ "\n<!> No Blocks Found <!>"))) (princ "\n<!> Replacement Block not Valid <!>")) (princ))[/color] [/color] Quote Link to comment Share on other sites More sharing options...
ucmeflyby Posted April 13, 2009 Author Share Posted April 13, 2009 Good Morning. I have tried the lsp you provided. It does work, but it has the same effect as the previous methods. There are two files attached to this post: "SERVICE.DWG" is the new block, & "MapSample.dwg" is a small portion of one of my maps that need updating. So far any attempt to replace the old "service" block with the new causes the fore mentioned nastiness. MapSample.dwg SERVICE.DWG Quote Link to comment Share on other sites More sharing options...
ucmeflyby Posted April 21, 2009 Author Share Posted April 21, 2009 I haven't had much luck with my mirroring problem over the last week or so. Are there any new ideas floating around here? The last method I tried involved moving all the affected text off to the side (extent) of the drawing and (re)mirroring it to return it to normal. The text remains mirrored, so no luck. Thank you. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 21, 2009 Share Posted April 21, 2009 I can't see what could cause the problems with my LISP - I merely take the insertion point, scale and rotation of the original block and put all those values in the new block - simple as. Quote Link to comment Share on other sites More sharing options...
skipsophrenic Posted April 22, 2009 Share Posted April 22, 2009 Is the UCS set to world in both of the drawings, and are you drawing to the same coordinates in both? Quote Link to comment Share on other sites More sharing options...
ucmeflyby Posted May 5, 2009 Author Share Posted May 5, 2009 skipsophrenic, I've just now seen your recommendation. I will have to check. Quote Link to comment Share on other sites More sharing options...
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.