I desparately need help...I'm working on a batch plot manager in vb.net. I found this code on the posts here and modified it to accomidate my program.
The problem is that my program will loop through the selecteditems of a listbox and I know the loop works properly...It will successfully plot each time but it plots the same drawing each time though.
I'm not exactly sure how to specify what open drawing to plot...Is it the plotsettings object, the validator. I thought is was drawing name that is passed to the BeginDocument method, but I've debuged what is passed to the method and it works properly.
The idea of my program is that the user can manually select what open drawings to plot and what settings to use.
The odd thing is that the print queue in windows shows the unique filenames of the each drawing when plotting but the same page plots each time.
Any thoughts?? Any suggestions would be greatly appreciated.
Dim i As Integer, iDocs As Integer
Dim bFound As Boolean
Dim dOrigin(0 To 1) As Double
Dim bReturnVal As Boolean
Dim acadDocument As Autodesk.AutoCAD.ApplicationServices.Document
Dim strSelectedDrawing As String
Dim strPlotFilename As String
'Dim origSDI As Boolean = Application.AcadApplication.Preferences.System.SingleDocumentMode
Dim plotInfo As PlotInfo = New PlotInfo()
Dim piValidator As PlotInfoValidator = New PlotInfoValidator()
Dim plotSet As PlotSettings
Dim plotEngine As PlotEngine = PlotFactory.CreatePublishEngine
Dim plotDialog As PlotProgressDialog = New PlotProgressDialog(False, 1, False)
Dim strListItem As String
Dim pmDrawing As pmDrawingRecord
'Change over to MDI mode to plot, then return to existing setting
Dim psValidator As PlotSettingsValidator
For Each strListItem In lstDrawings.SelectedItems
For Each pmDrawing In pmOpenDrawings
If strListItem.StartsWith(pmDrawing.strName) = True Then
For Each acadDocument In acadApp.DocumentManager
If pmDrawing.strName = acadDocument.Name Then
plotSet = New PlotSettings(True)
psValidator = PlotSettingsValidator.Current
'Sets the plot to model space
'MsgBox("Layouts: " & LayoutManager.Current.LayoutCount)
psValidator.SetPlotConfigurationName(plotSet, cboDeviceName.Text, cboPaperSize.Text)
'Sets the paper units
'Set the plotter to plot landscape, upside down
'Sets the boundaries to drawing extents
'Instructs AutoCAD to use a standard scale (scale to fit), not a custom scale
'Instructs AutoCAD not to center the plot, and use the given offset
'psValidator.SetPlotOrigin(plotSet, New Point2d(0.0, 0.75))
'Set the style for the plot
'Remove reference to the PlotSettingsValidator
psValidator = Nothing
plotSet.ShadePlot = PlotSettingsShadePlotType.AsDisplayed
'Plot with lineweights
plotSet.PrintLineweights = True
plotSet.ScaleLineweights = False
'Override the plot settings with our own
plotInfo.OverrideSettings = plotSet
'validate the plot info
MsgBox("Validated:" & plotInfo.IsValidated)
'Application.AcadApplication.Preferences.System.SingleDocumentMode = False
If plotEngine IsNot Nothing Then
plotDialog.IsVisible = True
plotEngine.BeginDocument(plotInfo, pmDrawing.strName, Nothing, 1, False, Nothing)
'Dim curItem As Integer
'For curItem = 0 To lstFiles.SelectedItems.Count - 1
Dim filename As String '= lstFiles.SelectedItems(curItem)
'Dim document As acadApp = Acad.Documents.Open((Path.Combine(Acad.ActiveDocument.Path, filename)), True)
Dim pageInfo As PlotPageInfo = New PlotPageInfo()
'Set the current layout to the model layer
LayoutManager.Current.CurrentLayout = "Model"
I found the answer.
I solved it by setting the mdiactivedocument to the desired document. Appearently this is what dictates what document is plotted because now it works.
The difference between what I'm creating and publish isn't an enourmous amount of things. You can get an idea with the screen capture attached. I can click on a preset and it fills in the plotting info into the selection combo boxes (the plotting settings are not dependent on the "Page Setup" settings in the drawing)
I have a separate macro that displays a dialog much like this one that batch plots PDF's...I am very proud of this PDF plotter since it uses Adobe Acrobat 7.0, Adobe Distiller, Postscript and creates great PDF's (Sure other programs out there do this) but few are for free and can be custimized at will like having your own code.
I love programming so I'm willing to do the "work" ))
Yes. It needs some work to do all the things I want it to. But everything involving interfacing with AutoCAD I've got figured out. I've also been able to incorporate showing preview window before plotting to device with the help of someone at Autodesk.
wrote in message news:email@example.com...
Yes. It needs some work to do all the things I want it to. But everything
involving interfacing with AutoCAD I've got figured out. I've also been able
to incorporate showing preview window before plotting to device with the
help of someone at Autodesk.