Exploding blocks with autolisp

Discussion in 'AutoCAD' started by tkennedy, Nov 29, 2006.

  1. tkennedy

    tkennedy Guest

    I have been trying to write a lisp routine that will explode all the
    blocks (including nested blocks) in a drawing, ignoring any xrefs. I am
    fairly new to lisp, and I have run out of ideas to try. If anyone can
    help me with this I would greatly appreciate it.

    TJ
     
    tkennedy, Nov 29, 2006
    #1
  2. Show us what you have so far.
     
    Michael Bulatovich, Nov 30, 2006
    #2
  3. Perhaps a little more backround information would help. I work for an
    engineering firm, and we receive background drawings from the architect
    that we xref into our drawings. It has become increasingly dificult to
    use their drawings without editing the somewhat, so we are trying to
    create a lisp routine to do the editing for us. What we need to do is
    get set everthing to bylayer for color, remove all unnecessary xrefs,
    and set all layers to a specific color. As for exploding the blocks, it
    is dificult for us to freeze the layers we dont need in our drawings if
    there are blocks in the arch. backgrounds. For example, if the
    architect has a standard room block, we cant use our express tools to
    freeze the furniture, it will freeze the entire block (usualy on layer
    0). Granted, we will run into the same problem if everything in the
    block is on the same layer, but that is rare.

    As for what I have so far, I have this:

    (defun c:test ()
    (setq ss (ssget "x" '((0 . "insert")))
    c 0)
    (repeat (sslength ss)
    (command ".explode" (ssname ss c))
    (setq c (1+ c)))
    )

    I dont have any of the layer or xref commands in yet, but those I know
    how to do and will add them later when I get this part working.
     
    Maintenancedude2000, Nov 30, 2006
    #3
  4. That should explode every block in the drawing, unless they've on locked
    and/or frozen layers.

    Some of the express tools used to have Options prompt which can affect what
    gets turned off. Do you get an Options prompt with whatever you're using?
     
    Michael Bulatovich, Nov 30, 2006
    #4
  5. I am using layfrz, which does have some options, but that is not usualy
    a problem. Something I forgot to mention is that we need everything to
    be by layer for color, so we can set it to the color we want in our
    drawings. We do this to make everything plot with a light lineweight.
    If a line in a block is set to any color but by layer, we cant change
    it in our drawing. If I explode all the blocks, I can then use change
    to make everything by layer. The routine I have will explode the bound
    xref I have in the drawing, then stop. When I run it again, it
    explodeds most of the blocks, than prints
    "Select object:"
    "Command: 94"
    to the command line.
     
    Maintenancedude2000, Nov 30, 2006
    #5
  6. Thanks everyone for your help, I think I have a routine put together
    that will do what I need.
     
    Maintenancedude2000, Dec 1, 2006
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.