delet block if... (cont.)

Discussion in 'AutoCAD' started by jclaidler, May 18, 2004.

  1. jclaidler

    jclaidler Guest

    The code below cycles thru all blocks in a drawing, and erases all non-attributed blocks. I'm trying to add code to look in a specific directory, and if the block name is there, it will not delete it. But I can't get it to work.

    Any suggestions ??


    (foreach n lt1 (setq ss (ssget "X" (list (cons 0 "INSERT")(cons 66 1))))(setq newTBinsert (strcat newTBdir newTB ".dwg"))
    (if (not (tblsearch "block" newTB))(progn
    (command "erase" ss "")(command "-layer" "s" "0" "")(command "-insert" newTBinsert "0,0,0" "" "" "") )) )
     
    jclaidler, May 18, 2004
    #1
  2. Have a look at the code I posted in your thread
    titled "list files in directory" on 05/12/2004. Simply
    switch the <then> and <else> expressions in the
    if statement.
     
    Jason Piercey, May 18, 2004
    #2
  3. jclaidler

    jclaidler Guest

    Is this the code you were referring to ??

    (foreach n lt1

    (setq ss (ssget "X" (list (cons 0 "INSERT")(cons 66 1))))

    (if ss (progn
    (setq i 0)
    (repeat (sslength ss)
    (vla-delete (vlax-ename->vla-object (ssname ss i)))
    (setq i (1+ i))
    )
    )

    (princ)

    )

    )
     
    jclaidler, May 18, 2004
    #3
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.