edit block by name?

Discussion in 'AutoCAD' started by MiD-AwE, Jan 19, 2005.

  1. MiD-AwE

    MiD-AwE Guest

    Is it possible to do a DDATTE on a block that is already in a drawing but call it by name instead of manually selecting it.

    I'm currently inserting the block and then using (COMMAND "DDATTE" "" "LAST")

    Here is an example:

    (DEFUN C:ISSL ()
    (COMMAND "INSERT" "SSL" "7'3 17/32,81'3 15/16" "" "" "")
    (COMMAND "" "" "" "" "" "" "" "" "" "")
    (COMMAND "DDATTE" "" "LAST")
    )

    Thank you.
     
    MiD-AwE, Jan 19, 2005
    #1
  2. MiD-AwE

    Jim Claypool Guest

    (defun editblk (blkname / ss)
    (if (setq ss (ssget "x" (list (cons 0 "INSERT") (cons 2 blkname))))
    (command "DDATTE" (ssname ss 0))
    (alert (strcat "No block " blkname " found"))
    )
    (princ)
    )

    Use (editblk "SSL")
    NOTE: If there are more that one SSL block this will only edit the first one
    in the selection set, so if that is a possibility, you need to account for
    it.
     
    Jim Claypool, Jan 19, 2005
    #2
  3. MiD-AwE

    MiD-AwE Guest

    Thanks, it works great.

    I'm actually using it in my lisp commands as :

    (DEFUN C:ISSL ()
    (COMMAND "INSERT" "SSL" "7'3 17/32,81'3 15/16" "" "" "")
    (COMMAND "" "" "" "" "" "" "" "" "" "")
    (editblk "SSL")
    )

    And I just added your :

    (defun editblk (blkname / ss)
    (if (setq ss (ssget "x" (list (cons 0 "INSERT") (cons 2 blkname))))
    (command "DDATTE" (ssname ss 0))
    (alert (strcat "No block " blkname " found"))
    )
    (princ)
    )

    to my acad.lsp

    Thanks again.
     
    MiD-AwE, Feb 11, 2005
    #3
  4. MiD-AwE

    Jim Claypool Guest

    Why not just

    (defun C:ISSL ()
    (setq attdia (getvar "attdia"))
    (setvar "attdia" 1)
    (COMMAND "INSERT" "SSL" "7'3 17/32,81'3 15/16" "" "" "")
    (setvar "attdia" attdia)
    )
     
    Jim Claypool, Feb 11, 2005
    #4
  5. MiD-AwE

    MiD-AwE Guest

    I'm using it for many blocks. This is just one example.
    And it's two lines of code less x (about a few hundred). Much less typing and I feel that you first method is fine how it is.

    Thank you.
     
    MiD-AwE, Feb 16, 2005
    #5
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.