copy and increment attributes

Discussion in 'AutoCAD' started by chall73, Mar 23, 2005.

  1. chall73

    chall73 Guest

    I am searching for a way to copy blocks with attributes that increments one of the fields as you copy it. We have equipment tags that are sequential numbered and would like to be able to copy that block without editing the fields. I have tried searching for answer but the only one that I have found is to purchase software. I am very new to lisp routines and I am not sure where to start

    Thanks
     
    chall73, Mar 23, 2005
    #1
  2. chall73

    ECCAD Guest

    I think I can help.
    If you will attach the equipment tag 'block' insert,
    and let me know 'which' attribute you want to
    increment, I'll generate a little Lisp program that
    will prompt you to pick the Equipment Tag..once
    picked, extract the attribute, increment the value,
    and ask where you want the 'new' equipment tag
    placed (probably just drag one in..), insert it, and
    fill in all the attributes (from values of the last tag, plus
    incremented value for equipment number).
    Hows that sound. ?

    Bob
     
    ECCAD, Mar 23, 2005
    #2
  3. chall73

    Nick Pirkl Guest

    Chall73, I use a little routine for room numbering. The following code is
    in my custom menu:

    [Room Number ]^C^C(setq BNR (GETINT "Beginning Number: "));\MULTIPLE;RMNO;

    Once you select "room number" from the pulldown menu it asks for the
    beginning number to use when inserting the blocks.

    The following coding is in my MYMENU.MNL file (Main lisp file that loads
    with each drawing):

    (defun c:RMNO ()
    (setq a (itoa bnr))
    (command "insert" "box" "s" f pause 0 a)
    (setq bnr (+ 1 bnr)))

    The routine takes the initial value, and passes it on to the insert command
    as the variable "a". After insertion it adds 1 to the value. The
    "Multiple" command in the menu restarts the lisp routine while using the new
    value for "a". Yours might look something like this:

    Menu item or Toolbar button:
    [Equipment Tag]^C^C(setq BNR (GETINT "Beginning Number:
    "));\MULTIPLE;equip_tag;


    Lisp routine:
    (defun c:equip_tag ()
    (setq a (itoa bnr))
    (command "-insert" "equip-tag" "s" 1 pause 0 "" a)
    (setq bnr (+ 1 bnr)))

    I checked this and it works just fine. After all the help Bob gave me, I
    had to try and return the favor for somebody else.

    Nick
     
    Nick Pirkl, Mar 23, 2005
    #3
  4. chall73

    Nick Pirkl Guest

    Or you could try this:

    Toolbar Button Macro:
    ^C^C(setq etype (getstring "Equipment Type: ") BNR (GETINT "Beginning
    Number: "));\\MULTIPLE;equip_tag;

    And the following lisp routine:
    (defun c:equip_tag ()
    (setq a (itoa bnr))
    (command "-insert" "equip-tag" "s" 1 pause 0 etype a)
    (setq bnr (+ 1 bnr)))


     
    Nick Pirkl, Mar 23, 2005
    #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.