pause/wait

Discussion in 'AutoCAD' started by spencer1971, Jun 14, 2004.

  1. spencer1971

    spencer1971 Guest

    The bottom 5 lines of this lsp seem to be wrong, Can someone point out what the code should be,
    t is supposed to wait for a pdf file to be created befor renaming it.
    I can get it to work by delaying by 10 seconds but really would like a shorter delay and to keep checking until file is created.

    Any suggestions.


    (defun c:pdf-rev ( / newfile)
    (command "plot" "y" "" "PDFcreator" "A3" "m" "l" "n" "e" "1:2" "c" "y" "a3.ctb" "y" "n" "n" "n" "n" "n" "y")
    (blocksearch)
    (setq tabname (getvar "ctab"))
    (setq dname (getvar "dwgname"))
    (setq dname1 (substr dname 1 (- (strlen dname) 4)))
    (setq dpref (strcat "C:/My Documents/PLOTFILES/"))
    (setq pfdoldname (strcat dpref dname1 " " tabname " (1)" ".pdf"))
    (setq pdfnewname (strcat dpref dname1 "_" newfile ".pdf"))
    (While (not (findfile pfdoldname))
    (command "DELAY" 100)
    )
    (dos_rename pfdoldname pdfnewname)
    )

    thanks

    Spencer
     
    spencer1971, Jun 14, 2004
    #1
  2. Try this Spencer,

    (defun WAIT (SECS / D SECS TM HRS MINS ET ST)
    (setq D (getvar "CDATE"))
    (setq TM (rtos (- D (fix D))2 10))
    (setq HRS (* 60 60 (atof (substr TM 3 2))))
    (setq MINS (* 60 (atoi (substr TM 5 2))))
    (setq ST (+ HRS MINS (atoi (substr TM 7 2))(/ (atof (substr TM 9 4)) 10000)))
    (setq TM 0)
    (while (> SECS TM)
    (setq D (getvar "CDATE"))
    (setq TM (rtos (- D (fix D))2 10))
    (setq HRS (* 60 60 (atof (substr TM 3 2))))
    (setq MINS (* 60 (atoi (substr TM 5 2))))
    (setq ET (+ HRS MINS (atoi (substr TM 7 2))(/ (atof (substr TM 9 4)) 10000)))
    (setq TM (- ET ST))
    )
    )

    For a ten second delay, call the function as follows;

    (wait 10)

    Hope that helps.
     
    Richard-Willis, Jun 14, 2004
    #2
  3. spencer1971

    spencer1971 Guest

    I have not been clear with my query I apologise.

    I do not want a set delay length, I want the lsp to keep checking for the pdf file until it is created then rename it.
     
    spencer1971, Jun 14, 2004
    #3
  4. My apologies, try the following then;

    (while (not (findfile "filename.pdf)))
    (wait 2)

    I would still suggest using the (wait) function, this will provide time for your pc to close the pdf file.
     
    Richard-Willis, Jun 14, 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.