defining a block in a lisp and check if the block is already defined in the drawing

Discussion in 'AutoCAD' started by Laura, Jul 21, 2003.

  1. Laura

    Laura Guest

    I've a lisaproutine that requires a certain block defined in the drawing. A
    solution was inserting the block into the drawing and erasing it
    immediately.
    I used erase and ten "last". The problem is when the insertion point is
    outside view it erases a different "last" object.

    (defun insertblock ()
    (defun inserting (BLOCK scale / BASEPOINT)
    (setq BASEPOINT (list 0 0 0))
    (command "-insert" BLOCK "s" 1 BASEPOINT "")
    (princ)
    ) ; end inserting

    (inserting "CERTAINBLOCK" 1)
    (command "erase" "last" "")
    (princ)
    ) ; end insertblock

    1. The first question is how can I erase that last inserted block?

    2. The second question is, how can I see that the block is already defined
    in the drawing.
    The following is not working.

    (if (tblsearch "block" CERTAINBLOCK )
    (go further with lisp) ; block exist
    (insert block and go further with lisp) ; block doesn't exist
    ) ; end if


    Thanks,

    Laura
     
    Laura, Jul 21, 2003
    #1
  2. Laura

    gert Guest

    1)
    use (entlast) instead of "_last"

    mfg
     
    gert, Jul 21, 2003
    #2
  3. Laura

    Laura Guest

    Great. That is working !

    Thanks.

    laura




     
    Laura, Jul 21, 2003
    #3
  4. Laura

    Laura Guest

    I forgot the " ". But why do your use "(not....." in it?

    (defun c:blocksearch ()

    (if (tblsearch "block" "Myblock")
    (alert "myblock exist")
    (alert "myblock doesn't exist")
    ) ; end if
    ); end defun

    This is working. Thank you very much.

    Greetings

    Laura
     
    Laura, Jul 21, 2003
    #4
  5. Laura

    gert Guest

    i use not, so i do not have an else option in the if-function and after the if i can go on with the lisp, because now the block is defined in the dwg.
    mfg

    Laura wrote:


    I forgot the " ". But why do your use "(not....." in it? (defun c:blocksearch () (if (tblsearch "block" "Myblock") (alert "myblock exist") (alert "myblock doesn't exist") ) ; end if ); end defun This is working. Thank you very much. Greetings Laura "gert" <> schreef in bericht news:...



    i guess this should work 2) (if (not (tblsearch "block" "MYBLOCK")) (progn insert the block and delete it ) ) now the rest of your lisp mfg Laura wrote:



    I've a lisaproutine that requires a certain block defined in the drawing.



    A



    solution was inserting the block into the drawing and erasing it immediately. I used erase and ten "last". The problem is when the insertion point is outside view it erases a different "last" object. (defun insertblock () (defun inserting (BLOCK scale / BASEPOINT) (setq BASEPOINT (list 0 0 0)) (command "-insert" BLOCK "s" 1 BASEPOINT "") (princ) ) ; end inserting (inserting "CERTAINBLOCK" 1) (command "erase" "last" "") (princ) ) ; end insertblock 1. The first question is how can I erase that last inserted block? 2. The second question is, how can I see that the block is already



    defined



    in the drawing. The following is not working. (if (tblsearch "block" CERTAINBLOCK ) (go further with lisp) ; block exist (insert block and go further with lisp) ; block doesn't exist ) ; end if Thanks, Laura
     
    gert, Jul 21, 2003
    #5
  6. Laura

    Laura Guest

    I thought so, but wanted a awnser to the problem anyway :)

    I'll keep it in mind.

    thanks

    Laura
     
    Laura, Jul 22, 2003
    #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.