Jump to content

Recommended Posts

Posted

Hi I was wondering if anyone had a script or lisp routine that

can change the layer of blocks I have drawn up to layer '0'

 

basically I have a quite a few blocks in a folder that I need to change thier from layer 'detail' to layer '0'

 

I know i can do it manually but there are hundreds of blocks , so it will take me for ever

 

I would appreciate any help

 

thanks

Posted

Dadgad, i don't think Lee lisp will work for this situation.

 

OP, am i correct in thinking that you want change all blocks in you drawing that are on layer "detail" to layer "0"

if so a simple script will work.

 

ssx  block * layer detail
chprop p  la 0  
qsave 

Posted
Dadgad, i don't think Lee lisp will work for this situation.

 

OP, am i correct in thinking that you want change all blocks in you drawing that are on layer "detail" to layer "0"

if so a simple script will work.

 

ssx  block * layer detail
chprop p  la 0  
qsave 

 

Yeah, looks like you are right, I figured Lee probably had something that would do it, but just looked, and nothing jumped out at me.

Your succinct little script looks like a real good fit though! :beer:

  • 3 months later...
Posted

Just saw this, so I'm guessing you've already done it manually.

 

Sounds like your blocks are all in a folder, they are dwg files, right? You can use 3 common apps to generate your script. First, use the windows command window to get a list of the files. Second, paste it into Excel and add other columns with the commands you want to run...open, zoom extents, chprop, purge detail layer, qsave, close, etc. Use a CONCATENATE funtion to string them all together. Copy paste the concatenate results into Notepad and save as a script (.scr) Then run the script in AutoCAD.

 

I do this to write scripts that adjust images, update block attributes, insert blocks, etc. Might not be worth your time unless you'll use it again and again.

  • 2 weeks later...
Posted

Jasenc,

I've been using this lisp routine by CAREN LINDSEY for years. It works a treat.

 

;****************************************************************************************
;    UPDATE BLOCK LAYER (updblkly.lsp)
;    PRE-INSERTED BLOCK DEFINITION CLEAN-UP UTILITY
;
;    This routine is especially usefull to redefine pre-inserted blocks whose
;    colors and layers need to be changed to layer 0 and color BYLAYER.
;
;       This routine allows the user to update the layer of
;    all entities within a block to a single layer (exam: layer=0)
;    without the user having to explode the symbol.  By default the color of
;    all entities are changed to BYLAYER. The routine changes the original
;    definition of the block within the current drawing.
;
;    To use this routine the user is asked to specify a single
;    layer to place all entities of a selected block(s).
;
;    The user is next prompted to select one or more blocks to update. The routine
;    then redefines all entities of the block to the layer specified.
;
;    When the user regenerates the drawing she/he will find that all
;    occurances of the block have been redefined.  This is because the
;    original definition of the block is changed!!!
;
;    IF YOU FIND THIS ROUTINE USEFUL PLEASE E-MAIL ME AT lindseycc@aol.com
;       by CAREN LINDSEY, June 1993
;****************************************************************************************
;

;INTERNAL ERROR HANDLER
(defun err-ubc (s)                ; If an error (such as CTRL-C) occurs
                       ; while this command is active...
   (if (/= s "Function cancelled")
         (princ (strcat "\nError: " s))
   )
   (setq *error* olderr)            ; Restore old *error* handler
   (princ)
);err-ubc

(DEFUN C:UDL (/ BLK CBL CBL2 C ACL ALY L NLY NCL YN)

   (setq olderr *error* *error* err-ubc)
       (while (null L)
       (setq L (strcase (getstring "\nEnter new layer name: ")))
       (cond
           ((= L "")(setq L nil))
           ((null (tblsearch "LAYER" L))
               (princ (strcat "\nLayer " L " does not exists!"))
               (initget "YES yes NO no")
               (setq yn (strcase (getstring "\nCreate new layer (y/n)? ")))
               (if (= yn "Y")(command ".layer" "m" L "")(setq L nil)))
       );cond
   );while

   (PROMPT "\nPick blocks to update. ")
   (SETQ SS (SSGET '((0 . "INSERT"))))
   (SETQ K 0)
   (WHILE (< K (SSLENGTH SS))
           (setq CBL (tblsearch "BLOCK" (CDR (ASSOC 2 (ENTGET (SETQ BLK (SSNAME SS K)))))))
           (SETQ CBL2 (CDR (ASSOC -2 CBL)))
       (WHILE (BOUNDP 'CBL2)
           (SETQ EE (ENTGET CBL2))

           ;Update layer value
            (SETQ NLY (CONS 8 L))
           (SETQ ALY (ASSOC 8 EE))
           (SETQ NEWE (SUBST NLY ALY EE))
           (ENTMOD NEWE)

           (SETQ CBL2 (ENTNEXT CBL2))
       );end while
       (ENTUPD BLK)
       (SETQ K (1+ K))
   );end while
   (setq *error* olderr)
   (princ)
);end updblkly

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