VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PlotToDevice failing in ACAD 2005

7 REPLIES 7
Reply
Message 1 of 8
tacito
472 Views, 7 Replies

PlotToDevice failing in ACAD 2005

Hi,

my app permits to the users select multiple DWG files, inserting them into a MSHFLEXGRID.
After this the user can select a DWT file and store in a matrix (PC) all its AcadPlotConfigurations.
The user can select distinct Page Layout for each DWG file selected.
Then running the code below, each file is opened in ACAD and then printed using the specific Page Layout.

This was running very good in ACAD 2002. After migrate to ACAD 2005 only the first file is printed. The others DWG files return FALSE to the PlotToDevice command.

Is it missing some command ?
Does ACAD 2005 need anything extra to run ?

Obs: the DWT Page Layouts were created for MODELs and the files to be printed are using only the model space too.

Please, take a look in the code below

TIA,

Tácito Fieker
CADGRAPH

'################################
' PLOT SAMPLE
'################################

Dim PC() As AcadPlotConfiguration


Private Sub Plot_Click()

Dim Layout As AcadLayout
Dim LayoutBase As AcadLayout
Dim indice As Integer
Dim retorno As Boolean

Dim row As Integer

Dim j As Integer

' READ THE DWG FILES IN THE FLEXGRID
For row = 1 To MSHFlexGrid1.Rows - 1
retorno = False
MSHFlexGrid1.col = 0
MSHFlexGrid1.row = row

' OPEN A FILE
MSHFlexGrid1.col = 0
ThisDrawing.Application.Documents.Open (MSHFlexGrid1.Text)

' Get the Plot Configuration selected for this file
MSHFlexGrid1.col = 1
indice = BuscaPos(MSHFlexGrid1.Text)

On Error Resume Next

' Apply for the drawing
ThisDrawing.ActiveLayout.CopyFrom PC(indice)
ThisDrawing.ActiveLayout.RefreshPlotDeviceInfo

ThisDrawing.Plot.NumberOfCopies = 1

ThisDrawing.Plot.QuietErrorMode = False
retorno = ThisDrawing.Plot.PlotToDevice

MSHFlexGrid1.col = 3
If retorno = True Then
MSHFlexGrid1.CellBackColor = VBA.ColorConstants.vbGreen
Else
MSHFlexGrid1.CellBackColor = VBA.ColorConstants.vbRed
End If

ThisDrawing.Application.ActiveDocument.Close False

Next row

Next j

End Sub
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: tacito

I have a simular problem with PlotToDevice - see my post of
14-04-2005.
Stll no solution, so productivity is down with 99% with this.....


wrote in message news:4892277@discussion.autodesk.com...
Hi,

my app permits to the users select multiple DWG files, inserting them
into a MSHFLEXGRID.
After this the user can select a DWT file and store in a matrix (PC)
all its AcadPlotConfigurations.
The user can select distinct Page Layout for each DWG file selected.
Then running the code below, each file is opened in ACAD and then
printed using the specific Page Layout.

This was running very good in ACAD 2002. After migrate to ACAD 2005
only the first file is printed. The others DWG files return FALSE to
the PlotToDevice command.

Is it missing some command ?
Does ACAD 2005 need anything extra to run ?

Obs: the DWT Page Layouts were created for MODELs and the files to be
printed are using only the model space too.

Please, take a look in the code below

TIA,

Tácito Fieker
CADGRAPH

'################################
' PLOT SAMPLE
'################################

Dim PC() As AcadPlotConfiguration


Private Sub Plot_Click()

Dim Layout As AcadLayout
Dim LayoutBase As AcadLayout
Dim indice As Integer
Dim retorno As Boolean

Dim row As Integer

Dim j As Integer

' READ THE DWG FILES IN THE FLEXGRID
For row = 1 To MSHFlexGrid1.Rows - 1
retorno = False
MSHFlexGrid1.col = 0
MSHFlexGrid1.row = row

' OPEN A FILE
MSHFlexGrid1.col = 0
ThisDrawing.Application.Documents.Open (MSHFlexGrid1.Text)

' Get the Plot Configuration selected for this file
MSHFlexGrid1.col = 1
indice = BuscaPos(MSHFlexGrid1.Text)

On Error Resume Next

' Apply for the drawing
ThisDrawing.ActiveLayout.CopyFrom PC(indice)
ThisDrawing.ActiveLayout.RefreshPlotDeviceInfo

ThisDrawing.Plot.NumberOfCopies = 1

ThisDrawing.Plot.QuietErrorMode = False
retorno = ThisDrawing.Plot.PlotToDevice

MSHFlexGrid1.col = 3
If retorno = True Then
MSHFlexGrid1.CellBackColor =
VBA.ColorConstants.vbGreen
Else
MSHFlexGrid1.CellBackColor = VBA.ColorConstants.vbRed
End If

ThisDrawing.Application.ActiveDocument.Close False

Next row

Next j

End Sub
Message 3 of 8
Anonymous
in reply to: tacito

Have you turned _off_ background plotting?

--
R. Robert Bell


wrote in message news:4892277@discussion.autodesk.com...
Hi,

my app permits to the users select multiple DWG files, inserting them into a
MSHFLEXGRID.
After this the user can select a DWT file and store in a matrix (PC) all its
AcadPlotConfigurations.
The user can select distinct Page Layout for each DWG file selected.
Then running the code below, each file is opened in ACAD and then printed
using the specific Page Layout.

This was running very good in ACAD 2002. After migrate to ACAD 2005 only the
first file is printed. The others DWG files return FALSE to the PlotToDevice
command.

Is it missing some command ?
Does ACAD 2005 need anything extra to run ?

Obs: the DWT Page Layouts were created for MODELs and the files to be
printed are using only the model space too.

Please, take a look in the code below

TIA,

Tácito Fieker
CADGRAPH

'################################
' PLOT SAMPLE
'################################

Dim PC() As AcadPlotConfiguration


Private Sub Plot_Click()

Dim Layout As AcadLayout
Dim LayoutBase As AcadLayout
Dim indice As Integer
Dim retorno As Boolean

Dim row As Integer

Dim j As Integer

' READ THE DWG FILES IN THE FLEXGRID
For row = 1 To MSHFlexGrid1.Rows - 1
retorno = False
MSHFlexGrid1.col = 0
MSHFlexGrid1.row = row

' OPEN A FILE
MSHFlexGrid1.col = 0
ThisDrawing.Application.Documents.Open (MSHFlexGrid1.Text)

' Get the Plot Configuration selected for this file
MSHFlexGrid1.col = 1
indice = BuscaPos(MSHFlexGrid1.Text)

On Error Resume Next

' Apply for the drawing
ThisDrawing.ActiveLayout.CopyFrom PC(indice)
ThisDrawing.ActiveLayout.RefreshPlotDeviceInfo

ThisDrawing.Plot.NumberOfCopies = 1

ThisDrawing.Plot.QuietErrorMode = False
retorno = ThisDrawing.Plot.PlotToDevice

MSHFlexGrid1.col = 3
If retorno = True Then
MSHFlexGrid1.CellBackColor = VBA.ColorConstants.vbGreen
Else
MSHFlexGrid1.CellBackColor = VBA.ColorConstants.vbRed
End If

ThisDrawing.Application.ActiveDocument.Close False

Next row

Next j

End Sub
Message 4 of 8
Anonymous
in reply to: tacito

That did the trick for me.
Both plot and publish has to be turned off.
Wunderfull those new things everytime.....:)



"R. Robert Bell" wrote in message
news:4892940@discussion.autodesk.com...
Have you turned _off_ background plotting?

--
R. Robert Bell


wrote in message news:4892277@discussion.autodesk.com...
Hi,

my app permits to the users select multiple DWG files, inserting them
into a
MSHFLEXGRID.
After this the user can select a DWT file and store in a matrix (PC)
all its
AcadPlotConfigurations.
The user can select distinct Page Layout for each DWG file selected.
Then running the code below, each file is opened in ACAD and then
printed
using the specific Page Layout.

This was running very good in ACAD 2002. After migrate to ACAD 2005
only the
first file is printed. The others DWG files return FALSE to the
PlotToDevice
command.

Is it missing some command ?
Does ACAD 2005 need anything extra to run ?

Obs: the DWT Page Layouts were created for MODELs and the files to be
printed are using only the model space too.

Please, take a look in the code below

TIA,

Tácito Fieker
CADGRAPH

'################################
' PLOT SAMPLE
'################################

Dim PC() As AcadPlotConfiguration


Private Sub Plot_Click()

Dim Layout As AcadLayout
Dim LayoutBase As AcadLayout
Dim indice As Integer
Dim retorno As Boolean

Dim row As Integer

Dim j As Integer

' READ THE DWG FILES IN THE FLEXGRID
For row = 1 To MSHFlexGrid1.Rows - 1
retorno = False
MSHFlexGrid1.col = 0
MSHFlexGrid1.row = row

' OPEN A FILE
MSHFlexGrid1.col = 0
ThisDrawing.Application.Documents.Open (MSHFlexGrid1.Text)

' Get the Plot Configuration selected for this file
MSHFlexGrid1.col = 1
indice = BuscaPos(MSHFlexGrid1.Text)

On Error Resume Next

' Apply for the drawing
ThisDrawing.ActiveLayout.CopyFrom PC(indice)
ThisDrawing.ActiveLayout.RefreshPlotDeviceInfo

ThisDrawing.Plot.NumberOfCopies = 1

ThisDrawing.Plot.QuietErrorMode = False
retorno = ThisDrawing.Plot.PlotToDevice

MSHFlexGrid1.col = 3
If retorno = True Then
MSHFlexGrid1.CellBackColor =
VBA.ColorConstants.vbGreen
Else
MSHFlexGrid1.CellBackColor = VBA.ColorConstants.vbRed
End If

ThisDrawing.Application.ActiveDocument.Close False

Next row

Next j

End Sub
Message 5 of 8
tacito
in reply to: tacito

Robert,

including the command: ThisDrawing.SetVariable "BACKGROUNDPLOT", 0
solved the problem.

Thanks,
Tacito Fieker
Message 6 of 8
Anonymous
in reply to: tacito

Glad I could help both of you.

--
R. Robert Bell


wrote in message news:4893700@discussion.autodesk.com...
Robert,

including the command: ThisDrawing.SetVariable "BACKGROUNDPLOT", 0
solved the problem.

Thanks,
Tacito Fieker
Message 7 of 8
rvelozo
in reply to: tacito

I had the same error having the return value as false. So I ran a error routine until the printer is free again. This is how I got around it. Hope it helps:

On Error GoTo ErrorHandler
Finished = ThisDrawing.Plot.PlotToDevice(DeviceName)

Exit Sub
ErrorHandler:
Select Case Err.Number ' Evaluate error number.
Case -2147467259 ' Printer busy
Case Else
End Select
Resume
End Sub
Message 8 of 8
icyzola
in reply to: tacito

This solution works with AC2012 also and made my day. Thanks to everybody.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost