mdemco Posted January 30, 2009 Posted January 30, 2009 I have a routine that plots my sheet sets for home plans. The issue is there is a timer function in the program to *I think* pause the process to give time for the PDF to be created. The issue is the timer never functions properly and so I get my desired print but the program stalls. If I let it sit for 5-10 minutes I get the runtime error and the chance to debug. But, I dont have that kind of time so I have to CTRL-ALT-DLT to close Acad and then load it back up. Is there any way to interrupt the function after the print is obtained? Like a cancel command? I cant figure out what is wrong with the code and I constantly need the print fucntion. Any Ideers??? Quote
CarlB Posted January 30, 2009 Posted January 30, 2009 Comment out/delete the pauses in the code & see if it still works. The pauses may be a holdover needed for earlier versions. The usual method to stop a lisp is the "esc" key. Quote
Lee Mac Posted January 30, 2009 Posted January 30, 2009 If you are still stuck after Carl's suggestions - post the LISP and we'll take a look for ya Quote
mdemco Posted January 30, 2009 Author Posted January 30, 2009 Public Sub pauseTimer(PauseTime As Single) '*** Timer for pausing during PDF printing for file copy from c:\pdftemp directory Dim Start As Single Start = Timer ' Set start time. Do While Timer DoEvents ' Yield to other processes Loop End Sub This is where Debug takes me, I will post the whole thing in a minute Quote
Lee Mac Posted January 30, 2009 Posted January 30, 2009 I may be talking out of my a*se but that looks like VBA instead of LISP Quote
mdemco Posted January 30, 2009 Author Posted January 30, 2009 Right you are sir it is in VB, there are both on here and I must have mixed it up. I zipped the VB code and linked it, I have very little VB experience though, I can see what it is trying to do but dont understand why it gets stuck?? PlotCode.zip Quote
dbroada Posted January 30, 2009 Posted January 30, 2009 Public Sub pauseTimer(PauseTime As Single) '*** Timer for pausing during PDF printing for file copy from c:\pdftemp directory Dim Start As Single Start = Timer ' Set start time. Do While Timer DoEvents ' Yield to other processes Loop End Sub This is where Debug takes me, I will post the whole thing in a minute I would comment out the Do While part first. Some timer routines have problems these days as the processors are too fast for them and they get confused. DoEvents is a do nothing command that allows the processor to scan other parts of the computer rather than continuing with the job in hand. You can normally get VBA routines to stop with the Pause|Break key, possibly in conjunction with the shift or ctrl key. Quote
mdemco Posted January 30, 2009 Author Posted January 30, 2009 To coment it out I just put *** before the line of code correct? Then I need to save the change and re-run to see if it affects it? I am not going to cause any issues with the code because I can just reverse it right? EDIT I blocked off the whole timer section of code as well as the command under Public Sub where it refers ot he timer and it still printed and then froze and crashed the program after it prompted for the name of the file it was creating. It sat for about two minutes after and then crashed. Quote
Lee Mac Posted January 30, 2009 Posted January 30, 2009 Just looking at the code, (and I know nothing about VB.. whatsoever) I would assume that you use ' for a comment - would I be right Dave? Quote
dbroada Posted January 30, 2009 Posted January 30, 2009 Lee is correct - an apostrophe will comment out a line if you are running this through the VBA editor in AutoCAD you can step through the code using the F8 key. You can also set breakpoint using the (I think) F9 key. Quote
Lee Mac Posted January 30, 2009 Posted January 30, 2009 You can also set breakpoint using the (I think) F9 key. F9 is correct Quote
mdemco Posted January 30, 2009 Author Posted January 30, 2009 Public Sub PDFCurrentBrochure() '*** PDFs current 8.5 x 11 brochure Dim sSeries As String, sPlanName As String, sFoundation As String, sVersion As String Dim abSeries As String, abFoundation As String Dim oPlot As AcadPlot Dim plotLayouts(0) As String Dim vLayoutList As Variant Dim sLayout As String Dim layoutsList(0) As String Dim checkLayout As AcadLayout Dim layoutFoundation As String, layoutSeries As String Dim thisLayout As Variant Dim checkBrochure As String Dim MyData As DataObject Dim finalPdfPath As String Dim finalPdfFile As String Dim finalPdfPathFile As String Dim plotFileExt As String Dim tempAcrobatPathFile As String Dim tempPath As String Dim paperSize As String Dim pc3Current As String On Error GoTo ErrorHandler pc3Current = "Adobe PDF.pc3" paperSize = "Letter" tempPath = "c:\pdftemp" Set oPlot = ThisDrawing.Plot Set MyData = New DataObject plotFileExt = "pdf" finalPdfPath = ThisDrawing.Path finalPdfPath = finalPdfPath + "\Brochures" tempAcrobatPathFile = tempPath + "\" + ThisDrawing.Name tempAcrobatPathFile = Replace(tempAcrobatPathFile, "dwg", plotFileExt) tempAcrobatPathFile = Replace(tempAcrobatPathFile, "9.7", "9") ' Doug put a single quote ' in front of this entire line when I tell you If Dir(finalPdfPath, vbDirectory) = "" Then MkDir finalPdfPath End If sSeries = getDrawingProperty("currentSeries") sPlanName = getDrawingProperty("propPlanName") sFoundation = getDrawingProperty("currentFoundation") sVersion = getDrawingProperty("propVersion") abFoundation = getShortName(sFoundation) abSeries = getShortName(sSeries) For Each checkLayout In ThisDrawing.Layouts checkBrochure = getLayoutPart(checkLayout.Name, 0) If checkBrochure = "Bro" Then layoutFoundation = getLayoutPart(checkLayout.Name, 1) If layoutFoundation = abFoundation Then layoutSeries = getLayoutPart(checkLayout.Name, 2) If layoutSeries = abSeries Then plotLayouts(0) = checkLayout.Name checkLayout.CanonicalMediaName = GetCanonicalFromLocale(paperSize, pc3Current) checkLayout.StyleSheet = "Brochure.ctb" checkLayout.ConfigName = pc3Current checkLayout.PlotRotation = ac0degrees checkLayout.PlotType = acExtents Exit For End If End If End If Next If plotLayouts(0) "" Then finalPdfFile = sSeries + "- " + sPlanName + "- " + sFoundation + "- " + sVersion + "- Brochure." + plotFileExt finalPdfPathFile = finalPdfPath + "\" + finalPdfFile If Dir(finalPdfPathFile, vbDirectory) "" Then Kill finalPdfPathFile End If layoutsList(0) = CStr(plotLayouts(0)) vLayoutList = layoutsList oPlot.SetLayoutsToPlot vLayoutList oPlot.PlotToDevice pc3Current While Dir(finalPdfPathFile, vbDirectory) = "" Name tempAcrobatPathFile As finalPdfPathFile Wend If Dir(tempPath, vbDirectory) = "" Then MkDir tempPath ElseIf Dir(tempPath + "\*.pdf", vbDirectory) "" Then Kill tempPath + "\*.*" End If End If Exit Sub ErrorHandler: pauseTimer (1) Resume Next End Sub So this is the code, what is the reason here at the end it runs this "pausetimer"? Quote
mdemco Posted January 30, 2009 Author Posted January 30, 2009 Public Sub pauseTimer(PauseTime As Single) '*** Timer for pausing during PDF printing for file copy from c:\pdftemp directory Dim Start As Single Start = Timer ' Set start time. Do While Timer DoEvents ' Yield to other processes Loop End Sub Here is the pause timer where the debug takes me too, it stops on the Do while timer line... Quote
Lee Mac Posted January 30, 2009 Posted January 30, 2009 Public Sub PDFCurrentBrochure() '*** PDFs current 8.5 x 11 brochure Dim sSeries As String, sPlanName As String, sFoundation As String, sVersion As String Dim abSeries As String, abFoundation As String Dim oPlot As AcadPlot Dim plotLayouts(0) As String Dim vLayoutList As Variant Dim sLayout As String Dim layoutsList(0) As String Dim checkLayout As AcadLayout Dim layoutFoundation As String, layoutSeries As String Dim thisLayout As Variant Dim checkBrochure As String Dim MyData As DataObject Dim finalPdfPath As String Dim finalPdfFile As String Dim finalPdfPathFile As String Dim plotFileExt As String Dim tempAcrobatPathFile As String Dim tempPath As String Dim paperSize As String Dim pc3Current As String On Error GoTo ErrorHandler pc3Current = "Adobe PDF.pc3" paperSize = "Letter" tempPath = "c:\pdftemp" Set oPlot = ThisDrawing.Plot Set MyData = New DataObject plotFileExt = "pdf" finalPdfPath = ThisDrawing.Path finalPdfPath = finalPdfPath + "\Brochures" tempAcrobatPathFile = tempPath + "\" + ThisDrawing.Name tempAcrobatPathFile = Replace(tempAcrobatPathFile, "dwg", plotFileExt) tempAcrobatPathFile = Replace(tempAcrobatPathFile, "9.7", "9") ' Doug put a single quote ' in front of this entire line when I tell you If Dir(finalPdfPath, vbDirectory) = "" Then MkDir finalPdfPath End If sSeries = getDrawingProperty("currentSeries") sPlanName = getDrawingProperty("propPlanName") sFoundation = getDrawingProperty("currentFoundation") sVersion = getDrawingProperty("propVersion") abFoundation = getShortName(sFoundation) abSeries = getShortName(sSeries) For Each checkLayout In ThisDrawing.Layouts checkBrochure = getLayoutPart(checkLayout.Name, 0) If checkBrochure = "Bro" Then layoutFoundation = getLayoutPart(checkLayout.Name, 1) If layoutFoundation = abFoundation Then layoutSeries = getLayoutPart(checkLayout.Name, 2) If layoutSeries = abSeries Then plotLayouts(0) = checkLayout.Name checkLayout.CanonicalMediaName = GetCanonicalFromLocale(paperSize, pc3Current) checkLayout.StyleSheet = "Brochure.ctb" checkLayout.ConfigName = pc3Current checkLayout.PlotRotation = ac0degrees checkLayout.PlotType = acExtents Exit For End If End If End If Next If plotLayouts(0) "" Then finalPdfFile = sSeries + "- " + sPlanName + "- " + sFoundation + "- " + sVersion + "- Brochure." + plotFileExt finalPdfPathFile = finalPdfPath + "\" + finalPdfFile If Dir(finalPdfPathFile, vbDirectory) "" Then Kill finalPdfPathFile End If layoutsList(0) = CStr(plotLayouts(0)) vLayoutList = layoutsList oPlot.SetLayoutsToPlot vLayoutList oPlot.PlotToDevice pc3Current While Dir(finalPdfPathFile, vbDirectory) = "" Name tempAcrobatPathFile As finalPdfPathFile Wend If Dir(tempPath, vbDirectory) = "" Then MkDir tempPath ElseIf Dir(tempPath + "\*.pdf", vbDirectory) "" Then Kill tempPath + "\*.*" End If End If Exit Sub ErrorHandler: pauseTimer (1) Resume Next End Sub So this is the code, what is the reason here at the end it runs this "pausetimer"? One question: Whos Doug? Quote
Lee Mac Posted January 30, 2009 Posted January 30, 2009 Why not just comment out the whole error handler (eradicating the timer) and see what the error is that keeps taking you to the error handler in the first place. Excuse my inexperience with VBA, but I tend to stutter... I mean LISP. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.