lisp help - searching for blocks

Discussion in 'AutoCAD' started by molokaiboy, Jul 8, 2004.

  1. molokaiboy

    molokaiboy Guest

    I have a routine that inserts in a block at a certain insertion point if block A is found. I also need it to look for block B.
    If Block A is found, it will insert it in at 0,0,0. If block B is also found, it will insert it in at 0,20,0. Below is a snip of the code I am using. Basically, I would need to have it search for both blocks. Both blocks would exist in drawings.

    (if(tblsearch "block" TBB)
    (command "-layer" "S" "notes" "" "" "-insert" "CDA_CHANGE.dwg" "16.000,2.375" "" "" "0")


    TIA

    Collin
     
    molokaiboy, Jul 8, 2004
    #1
  2. molokaiboy

    T.Willey Guest

    Use the tblsearch function to asign two variables, one for each block name. Then use a (cond... statement for your insert function.

    Tim
     
    T.Willey, Jul 8, 2004
    #2
  3. molokaiboy

    molokaiboy Guest

    Do you have a sample of this?

    Collin
     
    molokaiboy, Jul 8, 2004
    #3
  4. molokaiboy

    T.Willey Guest

    (setq blk1 (tblsearch "block" "blockname1here"))
    (setq blk2 (tblsearch "block" "blockname2here"))
    (cond
    ((and blk1 blk2); if both blocks are in drawing
    (insert function here)
    )
    ((and blk1 (not blk2)); if only block 1 is in drawing
    (insert function here)
    )
    ((and (not blk1) blk2); if only block 2 is in drawing
    (insert function here)
    )
    )

    Hope that helps
    Tim
     
    T.Willey, Jul 8, 2004
    #4
  5. molokaiboy

    molokaiboy Guest

    I think that will work. Also, I wanted to add an error trap. If neither of these blocks existed, have a message show up. Can you assist on this too?

    TIA
    Collin
     
    molokaiboy, Jul 8, 2004
    #5
  6. molokaiboy

    T.Willey Guest

    Just add another test in the (cond statement

    ((and (not blk1) (not blk2))
    (alert message here)
    )

    No need to start a new one, just add this like the others.

    Tim
     
    T.Willey, Jul 8, 2004
    #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.