Check for read only status of PDF prior to autopublish

Check for read only status of PDF prior to autopublish

rbillingsUBUHX
Explorer Explorer
512 Views
8 Replies
Message 1 of 9

Check for read only status of PDF prior to autopublish

rbillingsUBUHX
Explorer
Explorer

I think this should be possible

There is nothing worse then publishing a 40 page drawing and getting an error because some one has it open.

It sounds like it could be a simple script/macro to run prior to running auto publish.

Any thoughts?

 

Mabey a post for VBA?

0 Likes
513 Views
8 Replies
Replies (8)
Message 2 of 9

maratovich
Advisor
Advisor

The solution is to disable Avast.

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 3 of 9

rbillingsUBUHX
Explorer
Explorer

 

Thanks, but it has nothing to do with Virus software.

This is a network environment with multiple users

Example is another users has the file open. I need to check if the PDF I am going to over write is read only before running the Autopublish command.

0 Likes
Message 4 of 9

pendean
Community Legend
Community Legend
So you want to intercept closing your file (that triggers autopublish) to find out of the same name PDF is open?
And what would the solution be if it found the PDF to be open? Interrupt your file closing?
Or send an email to the person that has the PDF open?
Or create a new filew ith a different name? How would your colleagues know to open the different file name after that, since you appear to only want the same exact file name to remain all the time?

Bigger picture you might be skipping over: how do you folks avoid grabbing the wrong PDF in the life of a project or even track changes if you continuously overwrite files with the same exact name all the time? I'm curious as your solution seems to be more of a workflow issue since it appears you all open each others PDFs all the time and they might not quite understand a change your request seems to trigger.

Think it through, ask your colleagues, work up a game plan, come plan then flesh out your request in more detail.

HTH
0 Likes
Message 5 of 9

rbillingsUBUHX
Explorer
Explorer

Currently we manually run autopublish.

"autopublish" from the commandline/button

This is to force proper naming and file location.

Problem is when you run the autopublish command it does not do a "read only" check before stepping thru all a layout tabs to create the file. The error comes at the end of the process. I would like to kill the command at the start and not waste the time trying to publish if cannot save the file.

By default it isn't easy to see "who" has the PDF file open so we have to send an office wide email to get out of the PDF so it can be updated.

 

0 Likes
Message 6 of 9

john.uhden
Mentor
Mentor

@pendean 

A very good point about the file naming.

Albeit one should sort the the dates of multiple files.

But at our office the rules may sometimes create redundancy, but the rule is stricter.  We must prefix the file with one character for the type of file plus the date written as YYMMDD which is based on the latest revision, not the date of the plot.  That way anyone in the office can decipher the correct file to be printing or sending.  Though that method wouldn't necessarily relieve the OP's problem in that one might create the PDF at 9 am, then someone opens it at 9:30 but one of the layouts needed one additional tweak, so the 9:31 publish is caboshed at the end.  A workaround would be to publish it to a TEMP folder and then move it to its proper location when available.  Of course everyone must buy into the scheme and never open a TEMP file.  But they could call the originator and ask if he wanted it moved up... teamwork.

John F. Uhden

0 Likes
Message 7 of 9

Sea-Haven
Mentor
Mentor

You would have to run some form of precheck open each layout and get all pdfs etc and look at wether their open, I dont know if the pdf will reflect its open by someone else for Autocad the dwl can come into play. You may need a C# type program there may be a owner set to a file that is open, above my pay grade.

 

I did find this based around excel vba may be able to convert to VL lisp. if returns open then stop publish.

 

Sub TestFileOpened()
    Dim filesArray As Variant
    filesArray = Array("myexcel.xlsx")
    Dim fileLocation As String
    fileLocation = "D:\Acadtemp\"
    Dim message As String
    
    For Each file In filesArray
        If IsFileOpen(fileLocation & file) Then
            message = message & vbNewLine & "File '" & file & "' is open!"
        Else
          message = message & vbNewLine & "File '" & file & "' is closed!"
        End If
    Next file
    
    MsgBox message
    
End Sub

Function IsFileOpen(filename As String)
    Dim filenum As Integer, errnum As Integer
    
    On Error Resume Next
    filenum = FreeFile()
    
    Open filename For Input Lock Read As #filenum
    Close filenum
    errnum = Err
    On Error GoTo 0
    
    Select Case errnum
        Case 0
            IsFileOpen = False
        Case 70
            IsFileOpen = True
        Case Else
            Error errnum
    End Select
End Function

 

 

 

0 Likes
Message 8 of 9

pendean
Community Legend
Community Legend
@john.uhden In total agreement here, your office system is the one most offices follow (as does ours) with minor variations. I can only imagine the nightmare of multi-version PDFs out there all with the same exact name all the time that others open to reference. Yikes!
0 Likes
Message 9 of 9

john.uhden
Mentor
Mentor

@pendean 

Amen!  Here in NJ there are a number of agencies (including the NJDEP) that accept digitally signed PDFs.  God forbid you send the wrong one.

John F. Uhden

0 Likes