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

plotToFile from VB make HDD Full

1 REPLY 1
Reply
Message 1 of 2
Anonymous
346 Views, 1 Reply

plotToFile from VB make HDD Full

Hi All

I Don't know What wrong. When i plottofile it make my HDD Full. i have
attached LvPlot Image also. Please help

{code}
Private Sub CmdPrint_Click()

Dim i As Long
Dim AcDoc As AcadDocument
' On Error GoTo CmdPrint_Click_Error


Dim lay As AcadLayout
Dim x As Long
Dim MediaNames As Variant

Dim nName As Variant
Dim siz As Variant
Dim n As Long

For i = 1 To LvPlot.ListItems.Count
Header ' this is just for create object and Set AcadDoc =
AcadApp.ActiveDocument
AcadDoc.SetVariable "BACKGROUNDPLOT", 0
Set AcDoc = AcadApp.ActiveDocument
AcadDoc.Application.Documents.Open LvPlot.ListItems(i).Tag & "\" &
LvPlot.ListItems(i).SubItems(1)
Set AcadDoc = AcadApp.ActiveDocument

NextJump:
For x = 0 To AcadDoc.Layouts.Count
If AcadDoc.Layouts(x).Name = LvPlot.ListItems(i).SubItems(2) Then '
checking if layout name is match
AcadDoc.ActiveLayout = AcadDoc.Layouts(x)
AcadDoc.Application.ZoomExtents ' ZoomAll

AcadDoc.ActiveLayout.RefreshPlotDeviceInfo
AcadDoc.ActiveLayout.StyleSheet = LvPlot.ListItems(i).SubItems(7)
'Plot Style Table
AcadDoc.ActiveLayout.ConfigName = LvPlot.ListItems(i).SubItems(3)
'Printer

AcadDoc.ActiveLayout.RefreshPlotDeviceInfo
MediaNames = Layout.GetCanonicalMediaNames()

For n = LBound(MediaNames) To UBound(MediaNames)
nName = Layout.GetLocaleMediaName(MediaNames(n))

If nName = LvPlot.ListItems(i).SubItems(4) Then
AcadDoc.ActiveLayout.CanonicalMediaName =
MediaNames(n) 'Paper Size
Exit For
End If
Next

AcadDoc.ActiveLayout.PlotType = acExtents
AcadDoc.ActiveLayout.PlotRotation = 0
'LvPlot.ListItems(i).SubItems(8) 'Plot Rotation
AcadDoc.ActiveLayout.CenterPlot = True
AcadDoc.ActiveLayout.StandardScale = acScaleToFit
AcadDoc.ActiveLayout.RefreshPlotDeviceInfo

Call AcadDoc.Plot.PlotToFile(Replace(AcadDoc.FullName, "dwg",
LvPlot.ListItems(i).SubItems(2)), LvPlot.ListItems(i).SubItems(3))
''======================================= When Plot start , It not
end==========================================
End If
Next x




If i < LvPlot.ListItems.Count Then
If LvPlot.ListItems(i + 1).SubItems(1) = LvPlot.ListItems(i).SubItems(1)
Then
i = i + 1
GoTo NextJump
End If
End If
AcadDoc.Close True, LvPlot.ListItems(i).Tag & "\" &
LvPlot.ListItems(i).SubItems(1)
AcadDoc.SetVariable "BACKGROUNDPLOT", 1
Next i

On Error GoTo 0
Exit Sub

CmdPrint_Click_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
CmdPrint_Click of Form FrmPlotSetting"

End Sub
{\code}
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

Hi All,

I find the Mistake

Thanks.


"Amrit" wrote in message
news:6295712@discussion.autodesk.com...
Hi All

I Don't know What wrong. When i plottofile it make my HDD Full. i have
attached LvPlot Image also. Please help

{code}
Private Sub CmdPrint_Click()

Dim i As Long
Dim AcDoc As AcadDocument
' On Error GoTo CmdPrint_Click_Error


Dim lay As AcadLayout
Dim x As Long
Dim MediaNames As Variant

Dim nName As Variant
Dim siz As Variant
Dim n As Long

For i = 1 To LvPlot.ListItems.Count
Header ' this is just for create object and Set AcadDoc =
AcadApp.ActiveDocument
AcadDoc.SetVariable "BACKGROUNDPLOT", 0
Set AcDoc = AcadApp.ActiveDocument
AcadDoc.Application.Documents.Open LvPlot.ListItems(i).Tag & "\" &
LvPlot.ListItems(i).SubItems(1)
Set AcadDoc = AcadApp.ActiveDocument

NextJump:
For x = 0 To AcadDoc.Layouts.Count
If AcadDoc.Layouts(x).Name = LvPlot.ListItems(i).SubItems(2) Then '
checking if layout name is match
AcadDoc.ActiveLayout = AcadDoc.Layouts(x)
AcadDoc.Application.ZoomExtents ' ZoomAll

AcadDoc.ActiveLayout.RefreshPlotDeviceInfo
AcadDoc.ActiveLayout.StyleSheet = LvPlot.ListItems(i).SubItems(7)
'Plot Style Table
AcadDoc.ActiveLayout.ConfigName = LvPlot.ListItems(i).SubItems(3)
'Printer

AcadDoc.ActiveLayout.RefreshPlotDeviceInfo
MediaNames = Layout.GetCanonicalMediaNames()

For n = LBound(MediaNames) To UBound(MediaNames)
nName = Layout.GetLocaleMediaName(MediaNames(n))

If nName = LvPlot.ListItems(i).SubItems(4) Then
AcadDoc.ActiveLayout.CanonicalMediaName =
MediaNames(n) 'Paper Size
Exit For
End If
Next

AcadDoc.ActiveLayout.PlotType = acExtents
AcadDoc.ActiveLayout.PlotRotation = 0
'LvPlot.ListItems(i).SubItems(8) 'Plot Rotation
AcadDoc.ActiveLayout.CenterPlot = True
AcadDoc.ActiveLayout.StandardScale = acScaleToFit
AcadDoc.ActiveLayout.RefreshPlotDeviceInfo

Call AcadDoc.Plot.PlotToFile(Replace(AcadDoc.FullName, "dwg",
LvPlot.ListItems(i).SubItems(2)), LvPlot.ListItems(i).SubItems(3))
''======================================= When Plot start , It not
end==========================================
End If
Next x




If i < LvPlot.ListItems.Count Then
If LvPlot.ListItems(i + 1).SubItems(1) = LvPlot.ListItems(i).SubItems(1)
Then
i = i + 1
GoTo NextJump
End If
End If
AcadDoc.Close True, LvPlot.ListItems(i).Tag & "\" &
LvPlot.ListItems(i).SubItems(1)
AcadDoc.SetVariable "BACKGROUNDPLOT", 1
Next i

On Error GoTo 0
Exit Sub

CmdPrint_Click_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
CmdPrint_Click of Form FrmPlotSetting"

End Sub
{\code}

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

Post to forums  

Autodesk Design & Make Report

”Boost