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

Block rename lisp

3 REPLIES 3
Reply
Message 1 of 4
Joe.Gio
1036 Views, 3 Replies

Block rename lisp

Hi,

Does anyone have a lisp that will rename blocks from a list in the lisp?

The list would contain old block names and the new names. Not every drawing would contain the same blocks which is why I'd like to have a list. I haven't been able to find anything existing yet that works for me.

Thanks.

3 REPLIES 3
Message 2 of 4
Sea-Haven
in reply to: Joe.Gio

Its not rocket science just have a list, text file etc oldblock newblock. 

 

-rneame oldblock newblock will fail if oldblock does not exist. So simple answer is check 1st does block exist before try rename.

 

Just use a (foreach blkname lst

I would suggest a list like ((oldname newname)(oldname newname).... use the (nth 0 blkname) & (nth 1 blkname)

 

 

 

 

returns T if exists. 

(tblsearch "BLOCK" "bbb")  returns T if exists. 
((0 . "BLOCK") (2 . "bbb") (70 . 0) (10 0.0 0.0 0.0) (-2 . <Entity name: 3f4f6f90>))

so now -rename 

 

Message 3 of 4
Joe.Gio
in reply to: Sea-Haven

Hi sea.haven,

 

Thanks for the help. Unfortunately I don't really know how to put lisps together, I'm not the most switched on person when it comes to coding and haven't been able to get my head around it. I can only do very minor updates and tweaks to existing lisps. Do you have any references you could point me to that might help me put this one together? I tried researching some of your code but couldn't find anything that would help me put it together.

Thanks.

Message 4 of 4
Sea-Haven
in reply to: Joe.Gio

Ok just copy and paste this to command line it will write a txt file of all your blocks, just change the directory to where you want to save it. I have added the comma so you need to add the new name ie oldname,newname just a few to test post file and a dwg.

 

(setq fo (open "d:\\acadtemp\\blocks.txt" "w"))
(vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
  (write-line (strcat (vla-get-name blk) ",") fo)
(princ (vla-get-name blk))
)
(close fo)

to command  

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

Post to forums  

Autodesk Design & Make Report

”Boost