VVA Posted June 7, 2010 Share Posted June 7, 2010 ;;;------------------------------------------------------------------------------------------------------------------------------- ;;; CopyBlock - ROUTINE TO COPIES THE SELECTED BLOCK WITH A NEW NAME ;;; Work (i HOPE) with dynamic block ;;; Created by Vladimir Azarko (VVA) 2010-06-02 (azarko@yandex.ru) ;;; Credits to Tony Tanzillo, Joe Burke and Vishal Gonsalves for sharing their lisp copyblock.lsp ;;; http://discussion1.autodesk.com/forums/thread.jspa?messageID=6182594 ;;; http://discussion.autodesk.com/forums/thread.jspa?threadID=767010 ;;; posted http://forum.dwg.ru/showthread.php?t=36419 ;;;------------------------------------------------------------------------------------------------------------------------------- Any suggestion is welcomed CopyBlock-VVA.lsp Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 7, 2010 Share Posted June 7, 2010 Interesting approach Vladimir, I must say. I wouldn't have thought to create a temporary document to house the block definition so that you could change its name. I probably would have created a new Block Definition with the new name, and then just used CopyObjects to copy everything contained in the old definition into the new one... but nice code all the same. Lee Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 7, 2010 Share Posted June 7, 2010 Perhaps in Vanilla it might look like this - (standard blocks only of course): (defun CopyBlock ( old new / tdef ) ;; © Lee Mac ~ 07.06.10 (if (setq tdef (tblsearch "BLOCK" old)) (progn (entmake (subst (cons 2 new) (assoc 2 tdef) tdef)) (mapcar 'entmake (mapcar 'entget (GetObj (tblobjname "BLOCK" old)))) (entmake (list (cons 0 "ENDBLK") (cons 8 "0"))) ) ) new ) (defun GetObj ( e ) (if (setq e (entnext e)) (cons e (GetObj e))) ) (defun c:test ( / ent old new ) ;; © Lee Mac ~ 07.06.10 (if (and (setq ent (ssget "_+.:S:E:L" '((0 . "INSERT")))) (setq ent (entget (ssname ent 0))) (progn (while (progn (setq new (getstring t (strcat "\nNew Block Name <Copy of "(setq old (cdr (assoc 2 ent))) ">: ") ) ) (cond ( (eq "" new) (setq new (strcat "Copy of " old)) nil) ( (or (not (snvalid new)) (tblsearch "BLOCK" new)) (princ "\n** Block Name Not Valid **") ) ) ) ) new ) ) (if (CopyBlock old new) (entmod (subst (cons 2 new) (assoc 2 ent) ent)) (princ "\n** Block Copy Failed **") ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Guest kruuger Posted June 7, 2010 Share Posted June 7, 2010 please see attachment how the amateur (Me) play with this. i like your idea with DCL. i think that only one thing is missing. Check to see if block is an Xref. kruuger Block Clone.lsp Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 7, 2010 Share Posted June 7, 2010 Very cool Vladimir! I'm sure it will be useful to many. BTW Lee, your new block will not be annotative if original was. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 7, 2010 Share Posted June 7, 2010 BTW Lee, your new block will not be annotative if original was. Yeah, it won't process Dynamic blocks either - "standard blocks only"... Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 7, 2010 Share Posted June 7, 2010 Yeah, it won't process Dynamic blocks either - "standard blocks only"... Just putting the information out there for the world.:wink: Quote Link to comment Share on other sites More sharing options...
VVA Posted June 8, 2010 Author Share Posted June 8, 2010 ... to create a temporary document to house the block definition so that you could change its name. ...Lee Yeah, it won't process Dynamic blocks either - "standard blocks only"... Because of the dynamic blocks I did. This idea, I spied a Vishal Gonsalves (see the references in # 1) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 8, 2010 Share Posted June 8, 2010 I noticed - a nice idea all the same. Quote Link to comment Share on other sites More sharing options...
alanjt Posted November 4, 2010 Share Posted November 4, 2010 Had a use for this today and just wanted to say thanks; saved me a little legwork. 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.