See the top rated post in this thread. Click here

Results 1 to 3 of 3

Thread: Check if PDF is open, Delete if not...

  1. #1
    I could stop if I wanted to
    Join Date
    2001-10
    Location
    Defragging the internets.
    Posts
    329
    Login to Give a bone
    0

    Default Check if PDF is open, Delete if not...

    I'm trying to modify our PDF plotting routine. This is what I'm trying to do:

    Check if PDF exist
    Delete PDF
    If PDF can't be deleted, I need an alert window to close pdf.
    If alert window is closed and PDF still exist, show alert window
    once the PDF is closed it would then be deleted and continue to make a new pdf.

    Here is part of the code I'm trying to work with:

    Code:
    (setq pdfsave (strcat (getvar "dwgprefix") SSDN ".pdf"));;sets the pdf name, SSDN is Ctab
    
    (if 
      (findfile (strcat (getvar "dwgprefix") SSDN ".pdf"))
        (vl-file-delete (strcat (getvar "dwgprefix") SSDN ".pdf"))
          (While
            (findfile (strcat (getvar "dwgprefix") SSDN ".pdf"))
              (progn
                (alert "Please Close PDF")
                 (vl-file-delete (strcat (getvar "dwgprefix") SSDN ".pdf"))
              );;progn
          );;while
    );;if
    Any help would be great,
    Chris

  2. #2
    All AUGI, all the time Tharwat's Avatar
    Join Date
    2010-06
    Posts
    871
    Login to Give a bone
    1

    Default Re: Check if PDF is open, Delete if not...

    Hi,
    The function vl-file-delete returns true if the target file has been deleted otherwise returns nil.
    NOTE: You don't need to copy and paste the same path of the file and since you already assigned that path to a variable then just use the variable.

    Hope this what you are after.
    Code:
    (setq pdfsave (strcat (getvar "dwgprefix") SSDN ".pdf"))
    
    (if pdfsave
      (while (not (vl-file-delete pdfsave))
        (alert "PDF is already opened or used by any program, close PDF to continue.")
        )
     )

  3. #3
    I could stop if I wanted to
    Join Date
    2001-10
    Location
    Defragging the internets.
    Posts
    329
    Login to Give a bone
    0

    Default Re: Check if PDF is open, Delete if not...

    Thanks,
    I'll try that.

    While I was waiting, I came up with this:
    Code:
    ;;;added to check to see if PDF is open
    (vl-file-delete (strcat (getvar "dwgprefix") SSDN ".pdf"))
    (setq Meflags (getvar "qaflags" ))
    (setvar "qaflags" 0)
    (setq pdf1 nil)
    (setq pdf1 (findfile (strcat (getvar "dwgprefix") SSDN ".pdf")));;;nil
    (vl-file-delete (strcat (getvar "dwgprefix") SSDN ".pdf"))
    (while  pdf1
    (progn
    (alert "please close PDF to continue")
    (vl-file-delete (strcat (getvar "dwgprefix") SSDN ".pdf")))
    (setq pdf1 (findfile (strcat (getvar "dwgprefix") SSDN ".pdf")))
    (vl-file-delete (strcat (getvar "dwgprefix") SSDN ".pdf")))
    (setvar "qaflags" Meflags)
    ;;;Now to plot...
    Last edited by framedNlv; 2019-03-14 at 04:57 PM.

Similar Threads

  1. Delete files from Working Folder when Undoing the check out.
    By Wish List System in forum Inventor Wish List
    Replies: 0
    Last Post: 2011-10-21, 12:46 PM
  2. Can't open or delete files
    By capstone in forum AutoCAD General
    Replies: 7
    Last Post: 2011-06-20, 03:02 PM
  3. Check in and Delete working copy
    By awarren in forum Vault - General
    Replies: 1
    Last Post: 2009-02-03, 09:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •