drawing number list

Discussion in 'AutoCAD' started by Chuck, Jul 22, 2003.

  1. Chuck

    Chuck Guest

    I have been trying, in vain, to write a lisp routine that would prompt the
    user for a drive letter then a directory and then would create or open a
    drawing list.txt document, read the last number on the list, add one more to
    it on the next line and then place the next number in the bottom right hand
    corner of the drawing. This would allow you to pick a button, then the lisp
    file would get you a drawing number (the next numerically), record it and
    then apply it to your drawing. I am new to lisp programming and am sort of
    baffled by the way the logical operators work. If someone could give me an
    example of how you would tackle this, it would help a great deal. Thanks.

    Chuck
     
    Chuck, Jul 22, 2003
    #1
  2. Chuck

    Adam B Guest

    chuck i fail to see your logic. why do you want to do this?
     
    Adam B, Jul 22, 2003
    #2
  3. Chuck

    Chuck Guest

    So everyone on our LAN would simply be able to press a button and the new
    drawing they are working on would be assigned the next drawing number in the
    current contract without having to go to a drawing register and select a
    drawing number or , as is often the case, with people too lazy to get up and
    get a drawing number they will be working merrily away only to find out
    later that two people have used the same number.
     
    Chuck, Jul 22, 2003
    #3
  4. Chuck

    Chuck Guest

    Here's what I've got. As you can see I'm a real amateur at this.
    I should probably take a course in this except the closest offering is an
    hour's drive each way for a night school class once a week.

    (defun c:dstamp ()
    (setq drvn (getstring "/nplease enter the drive name "))
    (setq dirn
    (getstring
    "/nplease enter the directory name include subdirectories separated by a
    / like this...dir/subdir "
    )
    )
    (setq filen (strcat drvn ":/" dirn "drawing numbers.txt"))
    (setq dn (open filen "w"))
    ((while (setq nextline (read-line dn))
    (setq dwgname (atof (read-line dn))
    (setq dwgname (+ 1 dwgname))
    (write-line (rtos dwgname) dn)
    (close dn)
    (setq a (getvar "textsize"))
    (setq x (/ a 2))
    (setq a (- (car (getvar "limmax")) a))
    (command "text" "j" "br" (list a x) "" "" dwgname)
    )
     
    Chuck, Jul 23, 2003
    #4
  5. Chuck

    Chuck Guest

    I've discovered that dwgname is a system variable and can't be used as an
    autolisp variable plus my brackets were incorrect. This is my latest
    attempt.

    (defun c:dstamp ()
    (setq drvn (getstring "/nplease enter the drive name "))
    (setq dirn
    (getstring
    "/nplease enter the directory name include subdirectories separated by a
    / like this...dir/subdir "
    )
    )
    (setq filen (strcat drvn ":/" dirn "drawing numbers.txt"))
    (setq dn (open filen "w"))
    (setq cval (read-line dn))
    (if (= cval " ") (write-line "1" dn))
    (while (setq nextline (read-line dn))
    (setq dname (atof (read-line dn)))
    )
    (setq dname (+ 1 dname))
    (write-line (rtos dname) dn)
    (close filen)
    (setq a (getvar "textsize"))
    (setq x (/ a 2))
    (setq a (- (car (getvar "limmax")) a))
    (command "text" "j" "br" (list a x) "" "" dname)
     
    Chuck, Jul 23, 2003
    #5
  6. Chuck

    Chuck Guest

    (defun c:dstamp ()
    (setq dp (getvar "DWGPREFIX")) ;returns the current drive and directory of
    the drawing
    (setq filen (strcat dp "drawing numbers.txt")) ;creates the file in the
    "dp" directory
    (setq dn (open filen "w")) ;this is where I start to get lost...open filen
    for writing....I assume you can also read from this file at this point?
    (setq cval (read-line dn))
    (if (not cval)
    (write-line "1" dn)
    (progn
    (while (setq dnumber (read-line dn))
    (setq dname (atof dnumber)) ;returns the nextline as a real
    (setq dnxet (+ 1 dname)) ;increments the real by one for the next drawing
    number
    (write-line (rtos dnext) dn) :writes the next drawing number to the file
    )
    (close dn) :close the file
    )
    (setq a (getvar "TEXTSIZE"))
    (setq x (/ a 2)) ;sets the vertical offset to TEXTSIZE/2
    (setq a (- (car (getvar "LIMMAX")) a)) ;sets the horizontal offset to
    LIMMAX-TEXTSIZE (bottom-right justified)
    (command "text" "j" "br" (list a x) "" "" dnumber) ;prints the dnumber at
    the pre-determined co-ordinates
    )
     
    Chuck, Jul 24, 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.