6
21
15
初来乍到
; File Name: FIXBLOCK.LSP ; Description: Puts all of a blocks sub-entities on layer 0 with color and ; linetype set to BYBLOCK. The block, itself, will remain on ; its' original layer. ; ;*******************************************************************************(defun d_FixBlock (/ eBlockSel ; Block selection lInsertData ; Entity data sBlockName ; Block name lBlockData ; Entity data eSubEntity ; Sub-entity name lSubData ; Sub-entity data iCount ; Counter ) ;; Redefine error handler (setq d_#error *error* *error* d_FB_Error ) ;_ end setq ;; Set up environment (setq #SYSVARS (#SaveSysVars (list "cmdecho"))) (setvar "cmdecho" 0) (command "._undo" "_group") ;; Get block from user and make sure it's an INSERT type (if (setq eBlockSel (entsel "\nSelect block to change :")) (progn (if (setq lInsertData (entget (car eBlockSel))) (if (= (cdr (assoc 0 lInsertData)) "INSERT") (setq sBlockName (cdr (assoc 2 lInsertData))) (progn (alert "Entity selected is not a block!") (exit) ) ;_ end progn ) ;_ end if (progn (alert "Invalid Block Selection!") (exit) ) ;_ end progn ) ;_ end if ;; Get block info from the block table (setq lBlockData (tblsearch "BLOCK" sBlockName) eSubEntity (cdr (assoc -2 lBlockData)) ) ;_ end setq ;; Make sure block is not an Xref (if (not (assoc 1 lBlockData)) (progn (princ "\nProcessing block: ") (princ sBlockName) (princ "\nUpdating blocks sub-entities. . .") ;; Parse through all of the blocks sub-entities (while eSubEntity (princ " .") (setq lSubData (entget eSubEntity)) ;; Update layer property (if (assoc 8 lSubData) (progn (setq lSubData (subst (cons 8 "0") (assoc 8 lSubData) lSubData ) ;_ end subst ) ;_ end setq (entmod lSubData) ) ;_ end progn ) ;_ end if ;; Update the linetype property (if (assoc 6 lSubData) (progn (setq lSubData (subst (cons 6 "BYBLOCK") (assoc 6 lSubData) lSubData ) ;_ end subst ) ;_ end setq (entmod lSubData) ) ;_ end progn (entmod (append lSubData (list (cons 6 "BYBLOCK")))) ) ;_ end if ;; Update the color property (if (assoc 62 lSubData) (progn (setq lSubData (subst (cons 62 0) (assoc 62 lSubData) lSubData ) ;_ end subst ) ;_ end setq (entmod lSubData) ) ;_ end progn (entmod (append lSubData (list (cons 62 0))))