explode to layer but...

Discussion in 'AutoCAD' started by JB, Dec 22, 2003.

  1. JB

    JB Guest

    I need to explode a block to the layer it is inserted on with the following
    requirements;

    Before I explode the block;
    The block is made up of a circle and a hatch.
    The circle is on layer 0 and is Color ByBlock
    The hatch is on Layer 0 and is Color 9
    The Block is inserted onto layer DETAIL
    Layer DETAIL is Color Green
    The Block is assigned a color (Red)

    After I explode the block;
    The Circle needs to be the assigned color (red) on Layer
    DETAIL
    The hatch needs to be Color 9 on Layer DETAIL

    The colors and layer names may vary from block to block.

    I do not want to have to select layers or colors just pick the command,
    select the block or blocks and press enter.

    I just don't know where to begin. A search has turned up similar routines
    but not exactly what I need.

    Thank You! Happy Hollidays!

    John B
     
    JB, Dec 22, 2003
    #1
  2. JB

    Joe Burke Guest

    John,

    Maybe this helps with where to begin. It's a combination of code and program
    outline.

    (setq ename (car (entsel "\nSelect block: ")))
    (setq elst (entget ename)) ;insert data list
    (setq blklay (cdr (assoc 8 elst))) ;block layer name
    (setq blkclr (cdr (assoc 62 elst))) ;block color if not "bylayer"
    (command "explode" ename)
    (setq ss (ssget "P")) ;selection set of the exploded objects
    (setq idx 0) ;initialize index counter
    (repeat (sslength ss)
    (setq ename (ssname ss idx))
    (setq elst (entget ename))
    ;; a series of "if" tests here - example:
    ;; (if (= 0 (cdr (assoc 62 elst))) ;object color is "byblock"
    ;; modify the object color to be what was assigned to the block
    ;; can be done with command, or entmod, or vlax-put...
    (setq idx (1+ idx)) ;increment index
    ) ;repeat

    I'll be away for the next week.
    Joe Burke
     
    Joe Burke, Dec 23, 2003
    #2
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.