batch plotting program

batch plotting program

Anonymous
Not applicable
786 Views
8 Replies
Message 1 of 9

batch plotting program

Anonymous
Not applicable
I've had a lot of help from this forum and I have completed my batch plotting program. I originally did it in lisp, but that wasn't very good and didn't work some of the time, not to mention taking ages.
the program is in two modules:


'sub for getting each dwg in a directory and then using the plotdwf sub to plot them
Public Sub listfiles()
Dim MyFiles As String
Dim pathName As String
Dim expVar As Integer
Dim backplotVar As Integer
pathName = InputBox("Enter directory path")
'MsgBox pathName
If Dir(pathName & "\plot", vbDirectory) = "" Then
MkDir (pathName & "\plot")
End If
MyFiles = Dir(pathName & "\*.dwg")
If (MyFiles = "") Then
MsgBox "Not a valid directory or does not contain any .dwg files"
End
End If
'set expert mode to 1 (no regen popup message)
expVar = ThisDrawing.GetVariable("EXPERT")
ThisDrawing.SetVariable "EXPERT", 1
'set background plot to 0 (plots in foreground, else shits itself)
backplotVar = ThisDrawing.GetVariable("BACKGROUNDPLOT")
ThisDrawing.SetVariable "BACKGROUNDPLOT", 0
Do While (MyFiles <> "")
'MsgBox MyFiles
ThisDrawing.Application.Documents.Open (pathName & "\" & MyFiles)
plotdwf (pathName)
'If ThisDrawing.GetVariable("Diastat") = 1 Then
'MsgBox "Plot Sent", vbOKOnly
'End If
ThisDrawing.Close
MyFiles = Dir
Loop
'restore system variables
ThisDrawing.SetVariable "EXPERT", expVar
ThisDrawing.SetVariable "BACKGROUNDPLOT", backplotVar
End Sub



and




'plots a dwf with the set parameters to a folder called 'plot' within the file's directory (taken from the pathname2 variable)
Public Sub plotdwf(pathName2 As String)
Dim ACADLayout As ACADLayout
Dim lowleft(1) As Double
Dim upright(1) As Double
Dim originalValue As Boolean
Dim plottablestyles As String
Dim plotfile As Boolean
Dim fname As String

'define window
lowleft(0) = 0
lowleft(1) = 0
upright(0) = 840.1415
upright(1) = 593.6786
'set plot style to acad.ctb
Set ACADLayout = ThisDrawing.ActiveLayout
On Error Resume Next
ACADLayout.StyleSheet = "acad.ctb"
ACADLayout.SetWindowToPlot lowleft, upright
ACADLayout.PlotType = acWindow
ACADLayout.StandardScale = acScaleToFit
plottablestyles = ACADLayout.StyleSheet
'MsgBox "Plot style" & plottablestyles
originalValue = ACADLayout.PlotWithPlotStyles
'MsgBox "The PlotWithPlotStyles value is set to: " & originalValue
'plot file
fname = Left(ThisDrawing.Name, Len(ThisDrawing.Name) - 4)
'MsgBox "plot file name " & fname
plotfile = ThisDrawing.Plot.PlotToFile(pathName2 & "\plot\" & fname, "DWF6 ePlot.pc3")
End Sub


The script asks for a directory to process, and then plots all the dwg files in that folder, and puts the plots in a folder called 'plot' within the directory.
at the moment it is plotting to a window with the specified dimensions (lowleft(0) = lower x, lowleft(1) = lower y, and same for upright), but i usually plot to extents, which only requires minor modification:
comment out the line ' ACADLayout.SetWindowToPlot lowleft, upright' and change the plot type to acExtents.
the other attributes (plot style, scale, etc) can be changed easily as well, and if someone feels like it, they can make it more user friendly so that options can be selected from a message box and the code does not need to be modified.
0 Likes
787 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
i just realised that i have left a lot of code in that i have commented out but not removed. just ignore that as it probably doesn't work.
0 Likes
Message 3 of 9

Anonymous
Not applicable
Why go thru all that when you can use page setups that plot by layout and
then use Publish?

I don't understand why people insist that plotting by window or extents is
somehow superior. And don't give me "legacy drawings" as an excuse... don't
you think we have legacy drawings too? We have ~15 years of legacy drawings.
Auto-import of page setups removes that argument.

--
R. Robert Bell


wrote in message news:[email protected]...
I've had a lot of help from this forum and I have completed my batch
plotting program. I originally did it in lisp, but that wasn't very good and
didn't work some of the time, not to mention taking ages.
the program is in two modules:


'sub for getting each dwg in a directory and then using the plotdwf sub to
plot them
Public Sub listfiles()
Dim MyFiles As String
Dim pathName As String
Dim expVar As Integer
Dim backplotVar As Integer
pathName = InputBox("Enter directory path")
'MsgBox pathName
If Dir(pathName & "\plot", vbDirectory) = "" Then
MkDir (pathName & "\plot")
End If
MyFiles = Dir(pathName & "\*.dwg")
If (MyFiles = "") Then
MsgBox "Not a valid directory or does not contain any .dwg files"
End
End If
'set expert mode to 1 (no regen popup message)
expVar = ThisDrawing.GetVariable("EXPERT")
ThisDrawing.SetVariable "EXPERT", 1
'set background plot to 0 (plots in foreground, else shits itself)
backplotVar = ThisDrawing.GetVariable("BACKGROUNDPLOT")
ThisDrawing.SetVariable "BACKGROUNDPLOT", 0
Do While (MyFiles <> "")
'MsgBox MyFiles
ThisDrawing.Application.Documents.Open (pathName & "\" & MyFiles)
plotdwf (pathName)
'If ThisDrawing.GetVariable("Diastat") = 1 Then
'MsgBox "Plot Sent", vbOKOnly
'End If
ThisDrawing.Close
MyFiles = Dir
Loop
'restore system variables
ThisDrawing.SetVariable "EXPERT", expVar
ThisDrawing.SetVariable "BACKGROUNDPLOT", backplotVar
End Sub



and




'plots a dwf with the set parameters to a folder called 'plot' within the
file's directory (taken from the pathname2 variable)
Public Sub plotdwf(pathName2 As String)
Dim ACADLayout As ACADLayout
Dim lowleft(1) As Double
Dim upright(1) As Double
Dim originalValue As Boolean
Dim plottablestyles As String
Dim plotfile As Boolean
Dim fname As String

'define window
lowleft(0) = 0
lowleft(1) = 0
upright(0) = 840.1415
upright(1) = 593.6786
'set plot style to acad.ctb
Set ACADLayout = ThisDrawing.ActiveLayout
On Error Resume Next
ACADLayout.StyleSheet = "acad.ctb"
ACADLayout.SetWindowToPlot lowleft, upright
ACADLayout.PlotType = acWindow
ACADLayout.StandardScale = acScaleToFit
plottablestyles = ACADLayout.StyleSheet
'MsgBox "Plot style" & plottablestyles
originalValue = ACADLayout.PlotWithPlotStyles
'MsgBox "The PlotWithPlotStyles value is set to: " & originalValue
'plot file
fname = Left(ThisDrawing.Name, Len(ThisDrawing.Name) - 4)
'MsgBox "plot file name " & fname
plotfile = ThisDrawing.Plot.PlotToFile(pathName2 & "\plot\" & fname,
"DWF6 ePlot.pc3")
End Sub


The script asks for a directory to process, and then plots all the dwg files
in that folder, and puts the plots in a folder called 'plot' within the
directory.
at the moment it is plotting to a window with the specified dimensions
(lowleft(0) = lower x, lowleft(1) = lower y, and same for upright), but i
usually plot to extents, which only requires minor modification:
comment out the line ' ACADLayout.SetWindowToPlot lowleft, upright' and
change the plot type to acExtents.
the other attributes (plot style, scale, etc) can be changed easily as well,
and if someone feels like it, they can make it more user friendly so that
options can be selected from a message box and the code does not need to be
modified.
0 Likes
Message 4 of 9

Anonymous
Not applicable
R. Robert Bell wrote:
> Why go thru all that when you can use page setups that plot by layout and
> then use Publish?

Publish has had problems in assigning PageSetups to multiple dwgs.
Has this been fixed in '07 - only used it a couple of times.

It also displays a list of previous printed dwgs.
Any idea how to get rid of this annoying habit?


> I don't understand why people insist that plotting by window or extents is
> somehow superior. And don't give me "legacy drawings" as an excuse... don't
> you think we have legacy drawings too? We have ~15 years of legacy drawings.
> Auto-import of page setups removes that argument.

I thought I explained that clearly a couple of days ago.

Just because you rant about doing it one way is best for you, doesn't
mean it's best for others.
0 Likes
Message 5 of 9

Anonymous
Not applicable
Setting up batch plots and quick plots which automatically set plotters, paper sizes, and ctb files can save a lot of time for users.

especially if you plot extents, you can basically plot every tab in your dwg with company standard, paper size, & ctb with a single command line entry.

It's also great to plot a quick 11x17 check plot with a single command.

publish takes some time to set up for each dwg/project.
0 Likes
Message 6 of 9

Anonymous
Not applicable
Does not. Our templates are setup from day one to provide what is needed for
any new drawing. Just a matter of picking the needed template.

--
R. Robert Bell


wrote in message news:[email protected]...
Setting up batch plots and quick plots which automatically set plotters,
paper sizes, and ctb files can save a lot of time for users.

especially if you plot extents, you can basically plot every tab in your dwg
with company standard, paper size, & ctb with a single command line entry.

It's also great to plot a quick 11x17 check plot with a single command.

publish takes some time to set up for each dwg/project.
0 Likes
Message 7 of 9

Anonymous
Not applicable
this is far quicker if you want to plot a large number of drawings. just enter a folder and away it goes
0 Likes
Message 8 of 9

Anonymous
Not applicable
Probably no faster than using the Publish button in SSM.

--
R. Robert Bell


wrote in message news:[email protected]...
this is far quicker if you want to plot a large number of drawings. just
enter a folder and away it goes
0 Likes
Message 9 of 9

dgorsman
Consultant
Consultant
Hmmm. Despite the fact that the Publish dialog takes several minutes to appear? Or that it can take 5-10 minutes to just add drawings to the publish list? I wrote our quick plot program in less time than it took for one person to set up a Publish.

And I don't know about your projects, but we only have a general idea of how many drawing we are going to end up with at the end, and we don't always know what the file names will be.

For us, an in-house batch plot was the most efficient solution.
----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes