Copyblock3 fix bug so scale works

Copyblock3 fix bug so scale works

allanthebruce
Advocate Advocate
192 Views
2 Replies
Message 1 of 3

Copyblock3 fix bug so scale works

allanthebruce
Advocate
Advocate

Hi There, 

The below lisp works well but wanting the the scale option to work for me, it automatically picks 1 when I use the option.

 

appreacte anyone that can help me on this one.

Thanks

Allan

 

;VVA

;make a copy of a block with a new name

;select block to copy

;enter new name unless anonymous block, then new name = ols name less *

;pick insertion point

(defun C:CopyBlock3 (/ *error* OldBlockName NewBlockName

rewind BlockName Info BlockInfo ent_name ent_info)

(defun *error* (Msg)

(cond

((or (not Msg)

(member Msg '("console break"

"Function cancelled"

"quit / exit abort"))))

((princ (strcat "\nError: " Msg)))

) ;cond

(princ)

) ;end error

(sssetfirst)

(setq OldBlockName (entsel "\nSelect Block to copy: "))

(while

(or

(null OldBlockName)

(/= "INSERT" (cdr (assoc 0 (entget (car OldBlockName)))))

)

(princ "\nSelection was not a block - try again...")

(setq OldBlockName (entsel "\nSelect Block to copy: "))

)

;block name

(setq OldBlockName (strcase (cdr (assoc 2 (entget (car OldBlockName))))))

(princ (strcat "\nSelected block name: " OldBlockName))

(if (= "*" (substr OldBlockName 1 1))

(setq NewBlockName (substr OldBlockName 2))

(setq NewBlockName (getstring T "\nEnter new block name: "))

)

(setq rewind T)

(while (setq Info (tblnext "BLOCK" rewind))

(setq BlockName (strcase (cdr (assoc 2 Info))))

(if (= OldBlockName BlockName)

(setq BlockInfo Info)

)

(setq rewind nil)

)

(if BlockInfo

(progn

(setq ent_name (cdr (assoc -2 BlockInfo)))

;header definition:

(entmake (list '(0 . "BLOCK")

(cons 2 NewBlockName)

'(70 . 2)

(cons 10 '(0 0 0))

)

)

;body definition:

(entmake (cdr (entget ent_name)))

(while (setq ent_name (entnext ent_name))

(setq ent_info (cdr (entget ent_name)))

(entmake ent_info)

)

;footer definition:

(entmake '((0 . "ENDBLK")))

(command "-INSERT" NewBlockName pause "1" "1" "0")

)

)

(*Error* nil)

(princ)

) ;end

0 Likes
193 Views
2 Replies
Replies (2)
Message 2 of 3

marko_ribar
Advisor
Advisor

Change this line :

(command "-INSERT" NewBlockName pause "1" "1" "0")

To :

(command "-INSERT" NewBlockName "\\" "\\" "\\" "0")

 

BTW. You must manually enter scale factors when routine comes to this line...

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 3 of 3

allanthebruce
Advocate
Advocate

Thanks mate! Legend!!

0 Likes