Jump to content
masterfal

block updating

Recommended Posts

masterfal

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)
) 

 

 

 

 

Share this post


Link to post
Share on other sites
Grrr

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)) )
  )
)

 

Share this post


Link to post
Share on other sites
masterfal

Cheers Grrr!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×