Jump to content

block updating


masterfal

Recommended Posts

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

 

 

 

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...