Jump to content

Recommended Posts

Posted

'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:

 

xGhsA.png

 

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!

  • 10 months later...
Posted

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

Untitled.jpg

Posted

Is this LUA? It looks a lot like it but it has small differences.

Posted

no...this is Visual Basic for Applications (VBA)

Posted

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...

Posted

Do you mean, you can automate AutoCAD using LUA?

Can you please post a sample code...:D

Posted (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 by Tuns
Posted

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.

Posted

This is how you do a if condition in VB...nothing wrong there...

Posted

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.

Posted

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!

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...