Stepping thur blocks

Discussion in 'AutoCAD' started by jwhitney, Dec 19, 2003.

  1. jwhitney

    jwhitney Guest

    The intent is to step through all the subentities in all the blocks in a dwg to set the object color to bylayer - in 2004 I can't get entget or entnext to go past the main object header. Getting very frustrated - can anyone offer suggestions?

    (setq bdef (entget (car (entsel)))) ;gets entity data on block)
    (setq en (entget (entnext (cdr (assoc -1 bdef))))) ;supposed
    ; to give the next entity in the block, instead gives the next
    ; object

    searched thru everything I can find on it - that code should work and does not. HELP!

    Jeff
     
    jwhitney, Dec 19, 2003
    #1
  2. How about a different approach:

    (setq *blocks* (vla-get-blocks
    (vla-get-activedocument
    (vlax-get-acad-object))))

    (vlax-for blck *blocks*
    (vlax-for ent blck
    (vl-catch-all-apply
    'vla-put-color
    (list ent acbylayer))
    )
    )


    --
    Ken Alexander
    Acad2000
    Windows2000 Prof.

    "We can't solve problems by using the same kind
    of thinking we used when we created them."
    --Albert Einstein

    blocks in a dwg to set the object color to bylayer - in 2004 I can't
    get entget or entnext to go past the main object header. Getting very
    frustrated - can anyone offer suggestions?
     
    Ken Alexander, Dec 19, 2003
    #2
  3. jwhitney

    Jeff Mishler Guest

    You must get the block definition, not the insert.

    (setq bname (cdr (assoc 2 (entget (car (entsel))))))
    (setq b_ent (entget (tblobjname "block" bname)))
    (setq en (entget (entnext (cdr (assoc -1 b_ent)))))

    HTH,
    Jeff

    a dwg to set the object color to bylayer - in 2004 I can't get entget or
    entnext to go past the main object header. Getting very frustrated -
    can anyone offer suggestions?
     
    Jeff Mishler, Dec 19, 2003
    #3
  4. jwhitney

    jwhitney Guest

    My obvious error (in hindsight) was trying to entnext from the insert, not the block definition (subtle difference!) Will go thru the tables to get the block and go from there. I had done it once - quite a while ago - and now remember I got there through the tables.

    The more I know, the more I know I don't know, in Rumsfeld-speak.

    Thanks to all who replied,
    Jeff
     
    jwhitney, Dec 19, 2003
    #4
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.