muck Posted January 25, 2010 Share Posted January 25, 2010 AutoCAD 2010 I am having problems with the following code that I have written to plot drawings using existing page setups. The batch routine reads a drawing list in file c:/VBdwgFilelist.txt to create the batch loop. It uses FitLayoutCanon2870GE11x17 for the page setup name. The routine stops at the Plot.DisplayPlotPreview acFullPreview ThisDrawing.Plot.PlotToDevice. Can anyone tell me what I am doing wrong? I think I need to reset the objects since I am in a loop for different drawings but I could be wrong. I don't know how to reset objects in vba. Can anyone help? thank you, Private Sub PlotRoutine() Me.hide If batchloopcount = 0 Then Dim lstName As String Dim PlotConfigurations As AcadPlotConfigurations Dim Plot As AcadPlot Dim Activelayout As AcadLayout End If Set PlotConfigurations = ThisDrawing.PlotConfigurations Set Plot = ThisDrawing.Plot Set Activelayout = ThisDrawing.Activelayout Activelayout.RefreshPlotDeviceInfo lstName = "FitLayoutCanon2870GE11x17" 'lstName = "FitLayoutCanon2870GELetter" 'lstName = ComboBox1.Value lstName = ComboBox1.Value If lstName = "" Then lstName = "FitLayoutCanon2870GE11x17" Activelayout.CopyFrom PlotConfigurations.Item(lstName) 'lstname.value is the user selected Page Setup Activelayout.RefreshPlotDeviceInfo ThisDrawing.Regen acAllViewports 'Plot.DisplayPlotPreview acFullPreview ThisDrawing.Plot.PlotToDevice 'Me.Show End Sub Private Sub CommandButton8_Click() Me.hide 'On Error GoTo FileError Dim TheDrawingname As String AutoCAD.Documents.Close batchloopcount = 0 Open "c:/VBdwgFilelist.txt" For Input As #6 ' Open file for input. Do While Not EOF(6) ' Loop until end of file. Input #6, TheDrawingname ' Read data into two variables. 'Debug.Print MyString ' Print data to Debug window. 'If TheDrawingname "" Then ThisDrawing.Open (TheDrawingname) If TheDrawingname "" Then AutoCAD.Documents.Open (TheDrawingname) ThisDrawing.Regen acAllViewports 'MsgBox ("Plot Prompt") PlotRoutine ' For plotting above batchloopcount = batchloopcount + 1 ThisDrawing.Save 'Save the drawing ThisDrawing.Close End If Loop Close #6 ' Close file. Me.Show Exit Sub FileError: Close #6 MsgBox "File Error" 'progerror 'program error 'Resume Next End Sub Quote Link to comment Share on other sites More sharing options...
muck Posted January 26, 2010 Author Share Posted January 26, 2010 For anyone interested. Here is my corrected Batch Plot Routine: Private Sub BatchPlotRoutine() Me.hide If batchloopcount = 0 Then Dim lstName As String Dim PlotConfigurations As AcadPlotConfigurations Dim Plot As AcadPlot Dim Activelayout As AcadLayout End If Set PlotConfigurations = ThisDrawing.PlotConfigurations Set Plot = ThisDrawing.Plot Set Activelayout = ThisDrawing.Activelayout Activelayout.RefreshPlotDeviceInfo lstName = "FitLayoutCanon2870GE11x17" 'lstName = "FitLayoutCanon2870GELetter" 'lstName = ComboBox1.Value lstName = ComboBox1.Value If lstName = "" Then lstName = "FitLayoutCanon2870GE11x17" Activelayout.CopyFrom PlotConfigurations.Item(lstName) 'lstname.value is the user selected Page Setup ThisDrawing.Regen acAllViewports 'Plot.DisplayPlotPreview acFullPreview Plot.PlotToDevice 'ThisDrawing.Plot.PlotToDevice 'Me.Show End Sub Private Sub CommandButton8_Click() Me.hide Dim BackPlot As Variant BackPlot = ThisDrawing.GetVariable("BACKGROUNDPLOT") ThisDrawing.SetVariable "BACKGROUNDPLOT", 0 'On Error GoTo FileError Dim TheDrawingname As String AutoCAD.Documents.Close batchloopcount = 0 Open "c:/VBdwgFilelist.txt" For Input As #6 ' Open file for input. Do While Not EOF(6) ' Loop until end of file. Input #6, TheDrawingname ' Read data into two variables. 'Debug.Print MyString ' Print data to Debug window. 'If TheDrawingname "" Then ThisDrawing.Open (TheDrawingname) If TheDrawingname "" Then AutoCAD.Documents.Open (TheDrawingname) ThisDrawing.Regen acAllViewports 'MsgBox ("Plot Prompt") BatchPlotRoutine ' For plotting above batchloopcount = batchloopcount + 1 ThisDrawing.Save 'Save the drawing ThisDrawing.SetVariable "BACKGROUNDPLOT", BackPlot ThisDrawing.Close End If Loop Close #6 ' Close file. Me.Show Exit Sub FileError: Close #6 MsgBox "File Error" 'progerror 'program error 'Resume Next End Sub Quote Link to comment Share on other sites More sharing options...
asos2000 Posted January 28, 2010 Share Posted January 28, 2010 Could you plz upload the DVB file or dwg embaded with this DVB? Quote Link to comment Share on other sites More sharing options...
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.