Would you be so kind

Discussion in 'AutoCAD' started by The Cad Man, Oct 6, 2004.

  1. The Cad Man

    The Cad Man Guest

    Can someone help me update this if they are boared. Instead of querying for
    a block name, I need to make it use the block "24x36", instead of asking for
    new attribute value I need it to insert a value using a set variable, and
    instead of asking which attribute I want to change I want to define it.

    Basically, I want to change the way this ae.lsp routine works so it doesn't
    query.
    Here's what I want (kinda):

    (setq blkname (don't query, just use 24x36 here))
    (setq newatt (strcase (no query, wan't to make this date[date is already
    defined])
    (setq att1 (again no query, I want it to change the date tag))

    Here's the ae.lsp routine

    (defun C:ae ()
    (setvar "cmdecho" 0)
    (setq I 0)
    (setq blkname (getstring "\nEnter the name of block to update: "))
    (setq newatt (strcase(getstring "\nEnter new atrribute value: ")))
    (setq att1 (strcase(getstring "\nEnter the name of the attribute to change:
    ")))
    (setq sset (ssget "x" (list (cons 2 blkname))))
    (if (= sset nil)(setq l 0)
    (setq l (sslength sset)))
    (repeat l
    (setq stop 1)
    (setq name (ssname sset I))
    (while (= stop 1)
    (setq name1 (entget (entnext name)))
    (setq ATT (cdr (assoc 2 name1)))
    (if (= att att1)(setq go 1))
    (setq name (cdr (assoc -1 name1)))

    (while (= go 1)
    (setq d (assoc 1 name1))
    (setq d2 (cons 1 newatt))
    (setq d1 (subst d2 d name1))
    (entmod d1)
    (setq go nil)
    (setq stop nil)
    )
    )
    (setq i (1+ i))
    )
    (command "_zoom" "all")
    (princ)
    (princ)
    );


    THANKS A MILL FOR ANYONE WILLING TO HELP!!!!!
     
    The Cad Man, Oct 6, 2004
    #1
  2. The Cad Man

    Paul Turvill Guest

    (setq blkname "24x36")
    (setq newatt date) ;;where date is a variable containing the correct date in
    the proper format
    (seta att1 <<string or variable containing the date tag>>)

    You can (setq ...) any variable to a constant value as shown above; or you
    can simply substitute the actual values or strings directly in the LISP code
    that uses it.
    ___
     
    Paul Turvill, Oct 6, 2004
    #2
  3. The Cad Man

    stephen4444 Guest

    (defun C:ae ()
    (setvar "cmdecho" 0)
    (setq I 0)
    (setq blkname "24x36")
    (setq a (menucmd "m=$(edtime,$(getvar,tdupdate), month dd yyyy h:mm am/pm)"))
    (setq newatt (strcat a ))
    (setq att1 "DATE")
    ;(setq blkname (getstring "\nEnter the name of block to update: "))
    ;(setq newatt (strcase(getstring "\nEnter new atrribute value: ")))
    ;(setq att1 (strcase(getstring "\nEnter the name of the attribute to change: ")))
    (setq sset (ssget "x" (list (cons 2 blkname))))
    (if (= sset nil)(setq l 0)
    (setq l (sslength sset)))
    (repeat l
    (setq stop 1)
    (setq name (ssname sset I))
    (while (= stop 1)
    (setq name1 (entget (entnext name)))
    (setq ATT (cdr (assoc 2 name1)))
    (if (= att att1)(setq go 1))
    (setq name (cdr (assoc -1 name1)))

    (while (= go 1)
    (setq d (assoc 1 name1))
    (setq d2 (cons 1 newatt))
    (setq d1 (subst d2 d name1))
    (entmod d1)
    (setq go nil)
    (setq stop nil)
    )
    )
    (setq i (1+ i))
    )
    ;(command "_zoom" "all")
    ;(princ)
    (princ)
    );
     
    stephen4444, Oct 6, 2004
    #3
  4. The Cad Man

    stephen4444 Guest

    Here's another version that works too...

    (defun C:ae ()
    (setvar "cmdecho" 0)
    (setq I 0)

    (setq blkname "24x36")
    (setq cdate (rtos (getvar "cdate") 2 6)
    cdate
    (strcat
    (cdr (assoc (substr cdate 5 2)
    '(("01" . "JAN")
    ("02" . "FEB")
    ("03" . "MAR")
    ("04" . "APR")
    ("05" . "MAY")
    ("06" . "JUN")
    ("07" . "JUL")
    ("08" . "AUG")
    ("09" . "SEP")
    ("10" . "OCT")
    ("11" . "NOV")
    ("12" . "DEC"))))
    " "
    (substr cdate 7 2)
    ", "
    (substr cdate 1 4)
    ));setq
    (setq newatt (strcat "Date: " cdate))
    (setq att1 "DATE")

    ;(setq blkname (getstring "\nEnter the name of block to update: "))
    ;(setq newatt (strcase(getstring "\nEnter new atrribute value: ")))
    ;(setq att1 (strcase(getstring "\nEnter the name of the attribute to change: ")))

    (setq sset (ssget "x" (list (cons 2 blkname))))
    (if (= sset nil)(setq l 0)
    (setq l (sslength sset)))
    (repeat l
    (setq stop 1)
    (setq name (ssname sset I))
    (while (= stop 1)
    (setq name1 (entget (entnext name)))
    (setq ATT (cdr (assoc 2 name1)))
    (if (= att att1)(setq go 1))
    (setq name (cdr (assoc -1 name1)))

    (while (= go 1)
    (setq d (assoc 1 name1))
    (setq d2 (cons 1 newatt))
    (setq d1 (subst d2 d name1))
    (entmod d1)
    (setq go nil)
    (setq stop nil)
    )
    )
    (setq i (1+ i))
    )
    (command "regenall")
    (command "_zoom" "all")
    (princ)
    );
     
    stephen4444, Oct 6, 2004
    #4
  5. The Cad Man

    The Cad Man Guest

    Thank you everyone...that accomplished exactly what I needed to ;)
     
    The Cad Man, Oct 6, 2004
    #5
  6. The Cad Man

    The Cad Man Guest

    If you still are boared and have some time on your hands, I need this
    routine to accomplish the same thing with these additional variables and
    tags. THANK YOU ALL SO MUCH FOR YOUR HELP!!!!! This goes pretty far beyond
    my skills autolisp.

    Variable's I've already set Tag

    Fname Filename
    aecprojname Jobnumber

    The exist. routine:

    (defun C:attup ()
    (setvar "cmdecho" 0)
    (setq I 0)
    (setq date (itoa (fix (getvar "cdate"))))(setq date1(strcat(substr date 5
    2)"/"(substr date 7 2)"/"(substr date 1 4)))
    (setq blkname "24 x 36")
    (setq newatt date1)
    (setq att1 "DATE")
    (setq sset (ssget "x" (list (cons 2 blkname))))
    (if (= sset nil)(setq l 0)
    (setq l (sslength sset)))
    (repeat l
    (setq stop 1)
    (setq name (ssname sset I))
    (while (= stop 1)
    (setq name1 (entget (entnext name)))
    (setq ATT (cdr (assoc 2 name1)))
    (if (= att att1)(setq go 1))
    (setq name (cdr (assoc -1 name1)))

    (while (= go 1)
    (setq d (assoc 1 name1))
    (setq d2 (cons 1 newatt))
    (setq d1 (subst d2 d name1))
    (entmod d1)
    (setq go nil)
    (setq stop nil)
    )
    )
    (setq i (1+ i))
    )(command "_regen"));
     
    The Cad Man, Oct 6, 2004
    #6
  7. The Cad Man

    Paul Turvill Guest

    Now that you've seen how it's done, I'd think you should be able to figure
    it out for yourself; it's not all that difficult to just substitute a
    constant string or value for a (getxxx ...) function.
    ___
     
    Paul Turvill, Oct 6, 2004
    #7
  8. The Cad Man

    The Cad Man Guest

    My problem, how do I loop the program to do the same thing for other
    variables. I barely understand what its doing now...maybe some help to
    undertand what is is doing right now...pleassssseeeee....
     
    The Cad Man, Oct 6, 2004
    #8
  9. The Cad Man

    The Cad Man Guest

    Let me know if this is close please....

    (setq l (sslength sset)))
    (repeat l
    (setq stop 1)
    (setq name (ssname sset I))
    (while (= stop 1)
    (setq name1 (entget (entnext name)))
    (setq ATT (cdr (assoc 2 name1)))
    (if (= att att1)(setq go 1))
    (setq name (cdr (assoc -1 name1)))

    All this is simply to set the block as a variable?


    (while (= go 1)
    (setq d (assoc 1 name1)) ;;;;;sets d as
    proposed tag value?
    (setq d2 (cons 1 newatt));;;;;;sets d2 as
    the existing attribute tag name?
    (setq d1 (subst d2 d name1));;;;;;sets d1 to
    right value?
    (entmod d1);;;;motifies the actual value?
    (setq go nil);;;;puts it in action?
    (setq stop nil);;;;ends the action?
    )
    )
    (setq i (1+ i))
    )(command "_regen"));
     
    The Cad Man, Oct 6, 2004
    #9
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.