Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Redefining multiple blocks within drawing

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
860 Views, 5 Replies

Redefining multiple blocks within drawing

I have a lisp routine that uploads all the blocks contained within a specific folder and inserts or redefines all blocks of the same name within the current drawing.
My problem is that when I run the routine I prompts me that it can't fine the folder?
I created a folder called "blocks" and is located straight onto my C:\..........but it still doesn't work. Am I missing something in the lisp routine?

;FUNCTION TO UPDATE ALL BLOCKS WITHIN A DRAWING
;FROM A SPECIFIC DIRECTORY

(defun c:bup()
(SETVAR "cmdecho" 0)
(setq sst (ssget "X" (list (cons 0 "INSERT"))))
(setq c1 0)
(progn
(if sst
(progn
(repeat (sslength sst)
(setq el (entget (ssname sst c1))
c1 (+ 1 c1)
)
(setq blk (cdr (assoc 2 el)))
(setq blk (strcat blk"=c:\\Blocks" blk ))
(command "insert" blk)
(command)
)

)
)
)
(command "regen")
(SETVAR "cmdecho" 1)
(setq cnt (itoa c1))
(setq answer (strcat cnt " blocks were redefined"))
(PRINC answer)
(princ)
)
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

If it's a short named folder like that, why not simply add it to the AutoCAD
search path, OPTIONS>FILES... .

--
Dean Saadallah
http://www.pendean.com
LT Express Utilities
http://www.pendean.com/ltexpress
Expanded Links Pages
http://www.pendean.com/lt/links.htm
--
Message 3 of 6
Anonymous
in reply to: Anonymous

On 24.03.2003 11:42 deandepetra wrote:


> (setq blk (strcat blk "=c:\\Blocks" blk ))
>

(setq blk (strcat blk"=c:\\Blocks\\" blk ))



and Dean's proposal with the supportpath shouldn't be ignored, too...
that would reduce your input to

(setq blk (strcat blk "="))

hth

--
ruul
Message 4 of 6
civ_engineer
in reply to: Anonymous

Did you ever get this to work? I have a drawing with blocks in it that I need to redefined with blocks from another single drawing.  I was hoping to drag/drop using design center but it ignores duplicates.

I'm in Civil 3D 2012.. is there a tool to do this now?

Message 5 of 6
KristofDeRho
in reply to: Anonymous

Lisp works fine, but it expects the same number of blocks in the drawing and in the redefine folder.


Is it possible to have less blocks in the redefine folder. For example the drawing has blocks "tree", "pole" and "manhole" while I only want to redefine the "manhole" and "tree" block (only these are in the \\blocks\\ folder)....

 

If I run this lisp it stops working because it can't find the "pole" block in the redefine-folder.

 

I'm not a genius if it comes to Lisps.

 

thanks in advance.

Message 6 of 6
hmsilva
in reply to: KristofDeRho


@KristofDeRho wrote:

Lisp works fine, but it expects the same number of blocks in the drawing and in the redefine folder.


Is it possible to have less blocks in the redefine folder. For example the drawing has blocks "tree", "pole" and "manhole" while I only want to redefine the "manhole" and "tree" block (only these are in the \\blocks\\ folder)....

 

If I run this lisp it stops working because it can't find the "pole" block in the redefine-folder.

 

I'm not a genius if it comes to Lisps.

 

thanks in advance.


Perhaps something like this

 

(defun c:bup ( / BLK C1 CNT EL OLD_ECHO SST)
  (setq old_echo (getvar 'CMDECHO))
  (SETVAR "cmdecho" 0)
  (setq sst (ssget "X" (list (cons 0 "INSERT"))))
  (if sst
    (progn
      (setq c1 0
	    cnt	0
      )
      (repeat (sslength sst)
	(setq el  (entget (ssname sst c1))
	      c1  (+ 1 c1)
	      blk (cdr (assoc 2 el))
	)
	(if (and (findfile (strcat "c:\\Blocks\\" blk ".dwg"))
	  (setq blk (strcat blk "=c:\\Blocks\\" blk ))
		 )
	  (progn
	    (command ".insert" blk)
	    (command)
	    (setq cnt (1+ cnt))
	  )
	)
      )
    )
    (command "regen")
  )
  (SETVAR "cmdecho" old_echo)
  (prompt (strcat "\n" (itoa cnt) " blocks were redefined"))
  (princ)
)

 

HTH

Henrique

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost