home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Share Gallery 1
/
share_gal_1.zip
/
share_gal_1
/
GR
/
GR505.ZIP
/
LSP.EXE
/
BLKUPD.LSP
< prev
next >
Wrap
Lisp/Scheme
|
1989-09-06
|
3KB
|
73 lines
; BLKUPD.LSP
;
; by Mark W. Stayton [72140,365]
;
; This routine will re-insert blocks with attributes into a drawing that
; contains earlier versions of blocks with the same name. Developed as a
; result of cosmetic changes to blocks in an existing application that
; required older drawings to be updated with the new blocks.
;
; NOTE: This won't change the insertion point, style (including justification)
; or height of the attribute text entities if they've been changed from
; those of the originally inserted block.
; List of Block Names (with Attributes) to be Updated
; Block names in this list must be all upper case
(setq block_list '("BLOCK1" "BLOCK2" "BLOCK3" "BLOCKN")) ; Change this list to the block names
; you're updating.
; Return contents of entity field "num"
; (from the AutoLISP Release 9.0 Programmer's Reference Manual, Pg. 73)
(defun fld (num)
(cdr (assoc num d))
)
; Block Update Procedure
(defun C:BLKUPD(/ sset sslen loaded i newblk first)
(setvar "CmdEcho" 0)
(princ "\nUpdating blocks...")
(setq sset (ssget "X" '((66 . 1)))) ; Get all blocks with attributes
(setq sslen (sslength sset)) ; Number of entities in selection set
(setq loaded nil) ; Initialize set of duplicate blocks
(command "RegenAuto" "Off") ; Don't regen until we're done updating
(setq i 0) ; Initialize counter
(setq first T)
(while (< i sslen)
(setq e (ssname sset i)) ; Get a block entity
(setq d (entget e)) ; Get the block's attribute subentity
(if (and (member (fld 2) block_list) ; Is the block name in the list?
(not (member (fld 2) loaded)) ; Has it been loaded already?
)
(progn ; No,
(setq newblk (fld 2)) ; so get the block name to reload
(command "Insert" (strcat newblk "="))
(command)
(if first ; If it's the first block updated,
(progn ; then create the "loaded" list
(setq loaded (list newblk))
(setq first nil)
)
(setq loaded (cons newblk loaded)) ; If not the first, then add it to the list
)
)
)
(setq i (1+ i)) ; Increment the counter
)
(command "RegenAuto" "On") ; We're done, so regen the drawing
(if (null loaded) ; Send the appropriate message
(princ "\nNo matching blocks found")
(princ "\nBlock update completed")
)
(setvar "CmdEcho" 1)
(prin1) ; and exit clean
)