masterfal Posted December 3, 2018 Share Posted December 3, 2018 Hi All, I have a lisp routine I use for updating blocks which prompts me for the block name or if use ? it lets you click on the block you want to update. How can I remove the prompt for block name, so first up it asks you to choose/click block instead of typing name? Would be good if they could be swapped so using ? prompts you for the block name otherwise if its easier would be happy if the prompt for block name was completely removed ;Block redefinition - for batch scripts ;replaces <BLKNAME> with a new version of the block saved in <BLKNAME>.DWG ;(DWG file must be on search path) ; ; (defun C:BUP ( / blkname cmde ss) (setq cmde (getvar "cmdecho")) (setvar "cmdecho" 0) (setq blkname (getstring "\nBlock name ('?' to pick): ")) ; rem ;added 7/2013 (if (and blkname (= blkname "?"))(progn ; rem (prompt "\nPick a block:") (setq ss (ssget ":S" '((0 . "INSERT")))) (if ss (setq blkname (cdr(assoc 2 (entget(ssname ss 0)))))) (princ blkname) )) ; rem ;-- (if (tblsearch "block" blkname) (progn ; (command "._-insert" (strcat blkname "=") "_y" nil "_regen") ; breaks scripts... (command "._-insert" (strcat blkname "=") "_y" "@") (while (= (logand (getvar "CMDACTIVE") 1) 1)(command "")) ; for scripts (entdel (entlast)) (command "_regen") (princ (strcat "\nBlock " (strcase blkname) " redefined.")) ) (princ "Block not found.") ) (setvar "cmdecho" cmde) (prin1) ) Quote Link to comment Share on other sites More sharing options...
Grrr Posted December 3, 2018 Share Posted December 3, 2018 Maybe something like: ;Block redefinition - for batch scripts ;replaces <BLKNAME> with a new version of the block saved in <BLKNAME>.DWG ;(DWG file must be on search path) ; ; (defun C:BUP ( / blkname cmde ) (if (setq blkname (PickBlock (setvar 'errno 0))) (progn (setq cmde (getvar "cmdecho")) (setvar "cmdecho" 0) ; (command "._-insert" (strcat blkname "=") "_y" nil "_regen") ; breaks scripts... (command "._-insert" (strcat blkname "=") "_y" "@") (while (= (logand (getvar "CMDACTIVE") 1) 1)(command "")) ; for scripts (entdel (entlast)) (command "_regen") (princ (strcat "\nBlock " (strcase blkname) " redefined.")) (setvar "cmdecho" cmde) ) ) (princ) ) ; (PickBlock (setvar 'errno 0)) (defun PickBlock ( e ) (cond ( (not e) e ) ( (or (and (= 7 (getvar 'errno)) (princ "\nMissed") (setvar 'errno 0)) (not (setq e (car (entsel "\nPick block: ")))) (and (/= "INSERT" (cdr (assoc 0 (setq e (entget e))))) (princ "\nIvalid object")) ) (PickBlock (/= 52 (getvar 'errno))) ) ( (cdr (assoc 2 e)) ) ) ) Quote Link to comment Share on other sites More sharing options...
masterfal Posted December 7, 2018 Author Share Posted December 7, 2018 Cheers Grrr!! 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.