wait for file creation

Discussion in 'AutoCAD' started by spencer1971, Jul 2, 2004.

  1. spencer1971

    spencer1971 Guest

    I have posted below a bit of code that is part of a pdf creation lsp that automatically makes a pdf with the dwgname and a rev attribute from the titleblock as its filename.

    I have got it working by adding the delay befopre the renaming happens to allow for the pdf to be created but it is a bit hit and miss depending on the speed of the machine it is run on.

    Any suggestions on a better way, I have tried to wait for the file to be recognised using various doslib commands but I think the file is there as soon as the pdfcreator starts to make it, but it is still open so the lisp just crashes... Sorry if this is a bit confusing (and long) for a friday afternoon but i think ive run out of ideas..


    (defun c:pdf-rev ( / newfile tabname dname dname1 dpref pdfoldname pdfnewname )
    (setq oldtile (getvar "tilemode"))
    (setvar "tilemode" 0)
    (command "plot" "y" "" "PDFcreator" "A3" "m" "l" "n" "e" "1:2" "c" "y" "a3.ctb" "y" "n" "n" "n" "n" "n" "y")
    (dos_waitcursor T)
    (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"))
    (command "delay" 8000)
    (dos_delete pdfnewname)
    (dos_rename pfdoldname pdfnewname)
    (dos_waitcursor)
     
    spencer1971, Jul 2, 2004
    #1
  2. spencer1971

    ECCAD Guest

    Spence,
    You might want to try replacing the:
    (command "delay" 8000)
    With:
    (while (not (findfile ".....")))
    or some such.
    Bob
     
    ECCAD, Jul 2, 2004
    #2
  3. spencer1971

    BillZ Guest

    Why not just name the file to what you want when you plot it?

    Or am I way off here.


    Bill
     
    BillZ, Jul 2, 2004
    #3
  4. spencer1971

    spencer1971 Guest

    I have already tried that Bob but I think the file exists as soon as the creator starts so the lisp tries to change the name as its being created. , I believe there is a way to check if a file is read-only, this may work, do you know the command for checking this (its something ive seen on this NG but have searched to no avail)
     
    spencer1971, Jul 5, 2004
    #4
  5. spencer1971

    ECCAD Guest

    Yes,
    I seem to remember you can check the attrib's of a file by
    using DOSLib..

    (dos_attrib [filespec [bits]])
    Parameters
    filespec
    The desired file or files. filespec can contain wildcard characters ("*" and "?"). If filespec is not supplied, it is assumed to be *.*.

    bits
    A bit-coded integer identifying the desired file attributes to set. Specify more than one file attribute by adding the following bit values:

    0
    Normal

    1
    Read-only

    2
    Hidden

    4
    System

    8
    Archive



    Returns
    An association list containing the filenames and the attribute bits if successful.

    nil on error.

    Example
    Command: (dos_attrib "c:\\program files\\autocad 2002\\*.dwg")

    (("Drawing1.dwg" . 8) ("Drawing2.dwg" . 8))

    -------- from the help file..

    Bob
     
    ECCAD, Jul 5, 2004
    #5
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.