todi Posted September 4, 2012 Posted September 4, 2012 'Begin plot proccess Do While iCurrPage <= iEndPage For i = 0 To lstPages.Size - 1 'Retrieves an page object for plot data aquisition Set area = lstPages.getListItem(Int(i)) If area.PageNumber = iCurrPage Then 'Marks the plot area based on calculated element coordinates Call AcadApp.ActiveDocument.ActiveLayout.SetWindowToPlot(area.StartPosition, area.EndPosition) 'Plot the marked area Call AcadApp.ActiveDocument.ActiveLayout.GetWindowToPlot(area.StartPosition, area.EndPosition) 'Configures the marked area for window plot type AcadApp.ActiveDocument.ActiveLayout.PlotType = acWindow 'Scales the area of impression to fit the page AcadApp.ActiveDocument.ModelSpace.Layout.StandardScale = acScaleToFit 'Number of copies for one page AcadApp.ActiveDocument.Plot.NumberOfCopies = iQntCopy [color="red"]'Plot Call AcadApp.ActiveDocument.Plot.PlotToDevice 'Resume if an error occurs On Error Resume Next 'Increment the page counter iCurrPage = iCurrPage + 1[/color] End If Next i Loop Hello guys, So, I have some problems with the code painted in red color. Everytime I'm trying to print more than 1 page the following error occurs: It says: "The method 'PlotToDevice' of 'IAcadPlot' object failed" It's like the printer has occupied with the last task, so I supressed the error using "On Error Resume Next", but this failed again, because only the first page is printed and the others are ignored. I'm looking for help! How can I solve this? Is have some tricks to do this correctly? Thanks for all your answers! Quote
iDeeW Posted July 25, 2013 Posted July 25, 2013 I'm having the exact same error...?! Any ideas...Thank you Public Sub PlotPreview() If MsgBox("Preview", vbYesNo) = vbYes Then ThisDrawing.Plot.DisplayPlotPreview acFullPreview Else ThisDrawing.Plot.DisplayPlotPreview acPartialPreview End If End Sub Quote
Tuns Posted July 30, 2013 Posted July 30, 2013 Is this LUA? It looks a lot like it but it has small differences. Quote
iDeeW Posted July 30, 2013 Posted July 30, 2013 no...this is Visual Basic for Applications (VBA) Quote
Tuns Posted July 30, 2013 Posted July 30, 2013 Oh. Sorry my mistake. The only thing I can think of that could be wrong with his is he sets i = 0 and at the end he puts iCurrPage = iCurrPage + 1 when he didn't define it as iCurrPage the first time. For i = 0 To lstPages.Size - 1 should be For iCurrPage = 0 To lstPages.Size - 1 at least this is how it would work in LUA. I'm just giving my thoughts based on that since they look so similar I figured they'd function about the same. I'm probably wrong though... Quote
iDeeW Posted July 30, 2013 Posted July 30, 2013 Do you mean, you can automate AutoCAD using LUA? Can you please post a sample code... Quote
Tuns Posted July 30, 2013 Posted July 30, 2013 (edited) iCurrPage = iCurrPage + 1 Should change that to i = i + 1 Since you call it "i" at the beginning. Do you mean, you can automate AutoCAD using LUA?Can you please post a sample code... Man I wish... I'd be all over that... I'm sure you could do it somehow since its the 21st century and all, but IF it could be done it would look almost exactly like what you already have. Public Sub PlotPreview() If MsgBox("Preview", vbYesNo) = vbYes Then ThisDrawing.Plot.DisplayPlotPreview acFullPreview Else ThisDrawing.Plot.DisplayPlotPreview acPartialPreview End If End Sub would be something like Public Sub PlotPreview() If MsgBox("Preview", vbYesNo) = vbYes Then ThisDrawing Plot DisplayPlotPreview acFullPreview Else ThisDrawing Plot DisplayPlotPreview acPartialPreview End End in LUA. There would be more in it if I did it the right way but since it doesn't matter I just kinda gave you an idea. Edited July 30, 2013 by Tuns Quote
Tuns Posted July 30, 2013 Posted July 30, 2013 I could be wrong but I just noticed this. Tell me if it works. Public Sub PlotPreview() If MsgBox("Preview", vbYesNo) = vbYes Then ThisDrawing.Plot.DisplayPlotPreview acFullPreview Else ThisDrawing.Plot.DisplayPlotPreview acPartialPreview End If End Sub The way I see it is you put the if then statement in the wrong spot so when you put the "end if" it didn't have an if then statement to end. Am I wrong in saying this? Because sometimes depending on the scripting language you use it doesn't even matter where it goes. Quote
iDeeW Posted July 30, 2013 Posted July 30, 2013 This is how you do a if condition in VB...nothing wrong there... Quote
Tuns Posted July 30, 2013 Posted July 30, 2013 Is there a reason why the if then statement isn't in the same place as the end function for it? I'm curious as to why it would be like that. Do you know? If not I don't mind. Quote
iDeeW Posted July 30, 2013 Posted July 30, 2013 http://www.techonthenet.com/excel/formulas/if_then.php Quote
Tuns Posted July 30, 2013 Posted July 30, 2013 Public Sub PlotPreview() If MsgBox("Preview", vbYesNo) = vbYes Then ThisDrawing.Plot.DisplayPlotPreview acFullPreview ElseIf MsgBox("Preview", vbYesNo) = vbNo Then ThisDrawing.Plot.DisplayPlotPreview acPartialPreview End If End Sub Will that work? I changed yours based on that link you showed me. Also that link is an awesome website thanks for that! Quote
Tuns Posted July 30, 2013 Posted July 30, 2013 http://support.microsoft.com/kb/304070 http://dailydoseofexcel.com/archives/2011/09/01/odbc-microsoft-access-driver-is-not-a-valid-path/ Those two links have information on that error. See if either of them help. It looks like it's not a script error but a file/driver error. 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.