Automatic Attribute Numbering

Discussion in 'AutoCAD' started by John Georgiev, May 12, 2004.

  1. I have posted this yesterday in the general AutoCAD group, but was advised
    to post it here, so there is the problem:
    I have drawings which content one block with one attribute in it, and this
    block is copied many times. The only attribute in this block is 5 digit
    number. Is it possible to find a tool which is doing the same work as the
    one in Express Tools (Automatic Text Numbering) but for block like described
    above? Also when the work is done manually is it possible to check this
    practicular attribute for value repetitions (it should not repeat, but
    mistakes can happen). So far I made routine, which is doing it without a
    list - in the moment you
    click on the attribute it giving him a number, then you click the next -it
    giving the next number etc. In the beginning you are giving starting number
    and increment. The problem which killing this routine is that if you by
    mistake make click at non-attribute object or on empty space, this brakes
    the
    operation and you have to start again from the point the wrong click happen.
    I will like to create a list first and then renumber all blocks at once in
    order they was selected, but for now I can't make it work with attributes.
    It seems my Lisp knowledge is not good enough to handle this problem.

    Thanks
    John
     
    John Georgiev, May 12, 2004
    #1
  2. John Georgiev

    Rudy Tovar Guest

    Anything is possible.

    But to have someone just make it for you, well that's another story.

    I do believe that someone posted an example of this quite some time ago.

    So I would do a search on self-incrementing block.

    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi
     
    Rudy Tovar, May 12, 2004
    #2
  3. John Georgiev

    Rudy Tovar Guest

    Tony Tanzillo or Frank O. posted this sometime ago. Returns the tag, and
    value, but could be modified to return the 'entityname', by which you could
    edit the attribute value, instead of having to use the command line. Next
    you could structure it to create the loop to do whatever you'd like.

    (defun getattributes (ent / lst r)
    (if (= (cdr (assoc 0 (setq lst (entget ent)))) "INSERT")
    (if (= (cdr (assoc 66 lst)) 1)
    (while (and
    (setq ent (entnext ent))
    (not (= (cdr(assoc 0 lst)) "SEQEND"))
    )
    (if (= (cdr (assoc 0 (setq lst (entget ent)))) "ATTRIB")
    (setq r (cons (cons (cdr (assoc 2 lst)) (cdr (assoc 1 lst))) r))
    )
    )
    )
    )
    (reverse r)
    )

    ;Then simply add this loop to only accept 'E' for [E]xit.

    (defun c:test (/ loop e)
    (setq loop t)
    (while loop
    (initget "e")
    (setq e (entsel "\nSelect Block or [E]xit: "))
    (if (or (= e "E") (= e "e"))
    (setq loop nil)
    (progn
    (if (= (type e) 'LIST)
    (progn
    (prompt "\nDo what ever...")
    )
    )
    )
    )
    )
    (princ)
    )
    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi
     
    Rudy Tovar, May 12, 2004
    #3
  4. <clip>


    I use this:

    ; return a list of all attribs in EntNam in form:
    ; (("TAG" "value" <Entity name: ......>) ...)
    ;
    (defun ALE_GetAttribs (EntNam / EntDat OutLst)
    (while
    (/=
    "SEQEND"
    (DXF 0 (setq EntDat (entget (setq EntNam (entnext EntNam)))))
    )
    (setq OutLst
    (cons
    (list (DXF 2 EntDat) (DXF 1 EntDat) (DXF -1 EntDat))
    OutLst
    )
    )
    )
    )

    (defun DXF (code elist)
    (cdr (assoc code elist))
    )


    Example:

    Command: (setq EntNam (car (entsel)))

    Select objects: <Entity name: 40084c40>

    Command: (setq AttLst (ALE_GetAttribs EntNam))
    (("ITEM_QTY" "1" <Entity name: 40084c58>)
    ("ITEM_DESCR" "S/S Plate" <Entity name: 40084c50>)
    ("ITEM_NO" "42012" <Entity name: 40084c48>))

    To get a value:
    Command: (DXF "ITEM_QTY" AttLst)
    ("1" <Entity name: 40084c58>)

    To put a value:
    Command: (setq AttInf (DXF "ITEM_QTY" AttLst))
    ("1" <Entity name: 40084c58>)

    Command: (entmod (list (cons -1 (cadr Attinf)) (cons 1 "NewValue")))
    ((-1 . <Entity name: 40084c58>) (1 . "NewValue"))

    Command: (entupd (cadr Attinf))
    <Entity name: 40084c58>

    Example to filter attribs:

    (setq AttNms '("ITEM_QTY" "ITEM_NO"))

    ; put a null string in all AttNms:
    (foreach ForElm AttNms
    (entmod (list (cons -1 (caddr (assoc ForElm AttLst))) (cons 1 "")))
    )


    --
    ________________________________________________

    Marc'Antonio Alessi
    http://xoomer.virgilio.it/alessi
    (strcat "NOT a " (substr (ver) 8 4) " guru.")
    ________________________________________________
     
    Marc'Antonio Alessi, May 13, 2004
    #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.