Jump to content

Recommended Posts

Posted

;)

 

Hi Guys,

 

Someone knows a Lisp used to replace a internal block(s) of a folder with dwg many files.

 

Eg: The specific folder has a "n" files with A3 formats blocks using the same attributes and tags, so, if it's necessary do a correction in a little detail in this format, it's necessary to replace it, one by one on all of these files.

 

Thanks in advance...

Posted

To clarify you want to totally replace the block with another but keep atribute values or just update various attributes of the block.

 

The 1st step is to post a dwg or maybe two before-after.

Posted

if you to keep all the attribute values, then its easy.

1.) Create a Wblock for your new block.

2.) Save it in a directory you commonly used (for your convenience).

3.) Add that directory path to your Support File Search Path in Autocad Options.

4.) Just be sure that the basepoint of your new block and your old block are the same.

5.) Create a script.

6.) Install script pro.

7.) Run script pro, select your drawings & script then run.

 

Note: test this with 1 drawing first.

CMDECHO
0
ATTREQ
0
-insert
[color=red]YOUR_NEW_BLOCK_NAME[/color]
0,0,0
1.0
1.0
0.0
-blockreplace
[color=red]YOUR_OLD_BLOCK_NAME[/color]
[color=red]YOUR_NEW_BLOCK_NAME[/color]
y
erase
l

zoom
e
CMDECHO
1
ATTREQ
1
;

 

been doing this procedure for about 2 years now in 200-600 drawings.

Posted
To clarify you want to totally replace the block with another but keep atribute values or just update various attributes of the block.

 

The 1st step is to post a dwg or maybe two before-after.

 

Bigal, the best way it's keep the attribute values for all dwg files because every page has your specific title or a specific detail. After the alteration/correction block it will be replaced in all files in that folder with your previous information.

 

Thanks...

Posted
if you to keep all the attribute values, then its easy.

1.) Create a Wblock for your new block.

2.) Save it in a directory you commonly used (for your convenience).

3.) Add that directory path to your Support File Search Path in Autocad Options.

4.) Just be sure that the basepoint of your new block and your old block are the same.

5.) Create a script.

6.) Install script pro.

7.) Run script pro, select your drawings & script then run.

 

Note: test this with 1 drawing first.

 

been doing this procedure for about 2 years now in 200-600 drawings.

 

 

Thanks ttray33y I'll try it!...

Posted
Thanks ttray33y I'll try it!...

 

You're Welcome.

Posted

I use this, by Lee-Mac - Works every time!

 

Thank you Lee.

 

;-----------------------------------------------------------------------------------------------------------------
;http://www.cadtutor.net/forum/archive/index.php/t-52973.html
;-----------------------------------------------------------------------------------------


(defun ReDef (block / *error* oc spc doc block)
 (vl-load-com)
 ;; © Lee Mac 2010

 (defun *error* (msg)
   (and oc (setvar 'CMDECHO oc))
   (or	(wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **"))
   )
   (princ)
 )

 (setq	spc
 (if
   (or
     (eq AcModelSpace
	 (vla-get-ActiveSpace
	   (setq doc
		  (vla-get-ActiveDocument
		    (vlax-get-acad-object)
		  )
	   )
	 )
     )
     (eq :vlax-true (vla-get-MSpace doc))
   )
    (vla-get-ModelSpace doc)
    (vla-get-PaperSpace doc)
 )
 )

 (setq oc (getvar 'CMDECHO))
 (setvar 'CMDECHO 0)

 (if (setq block (findfile block))
   (progn
     (vla-delete
(vla-insertblock
  spc
  (vlax-3D-point '(0. 0. 0.))
  block
  1.
  1.
  1.
  0.
)
     )
     (vl-cmdf "_.attsync" "_N" (vl-filename-base block))
   )
 )

 (setvar 'CMDECHO oc)
 (princ)
)

;;Call like this:

;;(Redef "C:\\MyFolder\\MyBlock.dwg")

Posted

I also use the LISP above by Lee, however i think, it only works if your new and old block shares the same name.

redefine and replace are 2 different term, i believe.

Posted
I also use the LISP above by Lee, however i think, it only works if your new and old block shares the same name.

redefine and replace are 2 different term, i believe.

 

My apologies, I didn't read the whole thread.

 

Note to self: Always read the thread! :D

 

Cheers,

Posted
My apologies, I didn't read the whole thread.

 

Note to self: Always read the thread! :D

 

Cheers,

You dont have to apologies my friend, there was nothing wrong with the post you made, I only explain how Mr.Lee's LISP works.

Posted

Thanks to all, I'll use both of them!... Thanks again!!!...

 

 

:)

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...