Program pause

Discussion in 'AutoCAD' started by michael montagne, Aug 30, 2004.

  1. I have a plot program that prints to an .eps file then runs that thru
    ghostscript to make a pdf. Worked well since release 2000 but with the
    Acad2005 upgrade, I have a problem. The program continues
    asynchronously without waiting for the eps file to be made. So, on
    large files, the pdf doesn't have any content. Background plotting is
    not enabled. Is there something else about plotting that I need to
    address? How bout getting my program to wait for the eps file to
    generate? I tried:

    While Dir(strfilename2) = ""
    DoEvents
    Debug.Print "Waiting for eps file"
    Wend

    But got no joy.


    -mjm
     
    michael montagne, Aug 30, 2004
    #1
  2. michael montagne

    MickyV Guest

    Michael

    I've done the same thing recently. My program creates the EPS, converts it to PDF with GhostScript, then deletes the EPS.

    I found that it was creating the EPS fine, but was deleting it before the PDF conversion was complete, which gave me an empty PDF file, so instead of using "Shell" to run the ghostscript call, I used the following function (runs the program syncroniously). Seemed to fix up my troubles.

    'Add these lines in the general declaration area (watch for wrapping)
    Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

    Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long

    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

    Private Const PROCESS_QUERY_INFORMATION = &H400
    Private Const STATUS_PENDING = &H103&

    'throw this function in
    Public Function ShellSync(action As String, WindowStyle As Integer) As Integer
    Dim hProcess As Long
    Dim ProcessId As Long
    Dim exitCode As Long

    ProcessId = Shell(action, WindowStyle)
    hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessId)

    Do
    Call GetExitCodeProcess(hProcess, exitCode)
    DoEvents: DoEvents
    Loop While exitCode = STATUS_PENDING

    Call CloseHandle(hProcess)

    ShellSync = ProcessId

    End Function

    Hopefully that will work for you as it did for me...

    Mick.
     
    MickyV, Aug 31, 2004
    #2
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.