Hi,
I created a LispFunction in C# to print mutiple layout out as PDF. it works fine in AutoCAD.
then I create a script (.scr) to run this LispFunction, a bat file to call AcCoreConsole and this script file, and run it from DOS command line, it also works just fine
after that, I create a C# exe, use Process to call AcCoreConsole, use the same parameter in my bat file in Process, it hang at 3rd layout, right before the line of code below:
LayoutManager.Current.CurrentLayout = layoutToPrint;
first 2 layout print out as PDF successfully.
Anybody had the same problem before?
Thank you
Wes
AutoCAD 2016, .Net 4.5.2
Solved! Go to Solution.
Solved by wesbird. Go to Solution.
Hi
You say that it times out when it tries to print the third pdf.
A couple of things to try:
LayoutManager.Current.CurrentLayout = layoutToPrint;
how is the layoutToPrint value derived?
hope this helps.
rgds
BK
Hi, BKSpurgeon,
Sorry I didnot make it very in my first post.
I did not have problem to print multiple DWG file, I have problem to print multiple layout of one DWG file.
I tried another DWG file, it hang at 4th layout.
layoutToPrint is the name of layout to print out.
Thank you
Wes
Hi, FRFR1426,
I set BACKGROUNDPLOT to 0 in my code.
Here is the code I used to run AcCoreConsole, which I learned here or swamp. might be the trouble come from?
public void Run_Process(string FileName, ACCResult ccr) { using (Process process = new Process()) { process.StartInfo = CreateProcessStartInfo(FileName); process.Start(); if (!process.WaitForExit(_ProcessInfo.MaxTime)) { ccr.Status = ACCStatusCode.Timeout; process.CloseMainWindow(); if (!process.WaitForExit(2000)) { process.Kill(); } } else { string output = process.StandardOutput.ReadToEnd(); output = output.Replace("\0", "").Replace("\r\n", "").Replace("\b", ""); string err = process.StandardError.ReadToEnd(); if (!string.IsNullOrEmpty(err)) output += Environment.NewLine + BPLog.ERROR_MARK + err; ccr.OutPut = output; } } }
What's _ProcessInfo.MaxTime?
Thank, FRFR1426
_ProcessInfo.MaxTime was 10,000, then I change to 100,000. neither works.
later yesterday, I change the code from
if (!process.WaitForExit(_ProcessInfo.MaxTime)) { ccr.Status = ACCStatusCode.Timeout; process.CloseMainWindow(); if (!process.WaitForExit(2000)) { process.Kill(); } }
to
process.WaitForExit(_ProcessInfo.MaxTime);
then it works.
I'm not good at this one. good it works.
Thanks
Wes
It seems that the process you're starting is returning before the processing of the PDF is done. You should check what's happening with a tool like Process Explorer.
Anyway, a timeout of 10 000 ms (10 secondes) was definitely too short for this kind of operation.
Calling WaitForExit with a timeout has no sense if you're not checking the return value. If your calling program does not have to wait, just don't use WaitForExit.
Can't find what you're looking for? Ask the community or share your knowledge.