Message 1 of 4
VB6.0, Batch Plot

Not applicable
01-16-2007
12:58 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to do a VB6.0 application for batch plot. The program like this: first. it asks user to choose a sample dwg file. then it records its pc3, papersize, plotarea, scale, rotation,etc,settings. Then it asks user to choose multiple files and does plotting one by one. I have a function doing the last part, plotting, everytime it stucked and shutdowned VB6.0. Please help me find where I missed. Here is the function:
Function DoPlot(ByVal FNM As String)
'connect AutoCAD 2004
Dim oApp As AcadApplication
On Error Resume Next
Set oApp = GetObject(, "AutoCAD.Application.16")
If Err Then
Err.Clear
Set oApp = CreateObject("AutoCAD.Application.16")
End If
If oApp Is Nothing Then
MsgBox "Unable to Connect to Autocad 2004, Please contact AutoCAD Admin.", vbCritical
Exit Function
End If
Dim newDoc As AcadDocument
Set newDoc = oApp.Documents.Open(FNM)
Dim oPC As AcadLayout
Set oPC = newDoc.ActiveLayout
'pc3 name
oPC.ConfigName = strPRTname
'papersize name
oPC.CanonicalMediaName = strPaperSize
'ctb name
oPC.StyleSheet = strCTB
newDoc.Plot.PlotToDevice
newDoc.Close
oApp.Quit
End Function
Function DoPlot(ByVal FNM As String)
'connect AutoCAD 2004
Dim oApp As AcadApplication
On Error Resume Next
Set oApp = GetObject(, "AutoCAD.Application.16")
If Err Then
Err.Clear
Set oApp = CreateObject("AutoCAD.Application.16")
End If
If oApp Is Nothing Then
MsgBox "Unable to Connect to Autocad 2004, Please contact AutoCAD Admin.", vbCritical
Exit Function
End If
Dim newDoc As AcadDocument
Set newDoc = oApp.Documents.Open(FNM)
Dim oPC As AcadLayout
Set oPC = newDoc.ActiveLayout
'pc3 name
oPC.ConfigName = strPRTname
'papersize name
oPC.CanonicalMediaName = strPaperSize
'ctb name
oPC.StyleSheet = strCTB
newDoc.Plot.PlotToDevice
newDoc.Close
oApp.Quit
End Function