Ukemi72
2014-03-03, 09:11 PM
Hello,
i'm trying to make a VB.net-code to set the plotterdevicename and MediaName to a file, but now i have the following question.
The program stops by debugging when de MediaName is selected. Now i found why this is happening but i don't know how to program the solution in VB.net-code. The reason the debugging stopped is that the papersize is not defined in the plotterdecive (Windows). Now ik don't know how i can programm in VB.net-code.
Does somebody know how i can do this?
Greetings, Tori72
Ukemi72
2014-03-11, 06:38 PM
i've the following code, it produces an error "eInvalidinput" and i don't know why this is happening. Hopefully maybe someone see where it's going wrong.
The program also doesn't give an error before debugging.
The VB.net-code is :
Public Sub PageSetupInstellenPlotter(ByVal LayoutName As String,
ByVal PageSetupNaam As String,
ByVal PlotterNaam As String,
ByVal Papierformaat As String,
ByVal PenStyleTable As String)
' Creates a new page setup or edits the page set if it exists
' Get the current document and database, and start a transaction
Dim Doc As Document = Application.DocumentManager.MdiActiveDocument
Dim Dwg As Database = Doc.Database
Dim PlotterName As String
PlotterName = PlotterNaam
Dim PaperSize As String
PaperSize = Papierformaat
Dim CTBfileName As String
CTBfileName = PenStyleTable
'Vergrendel het document
Using Doc.LockDocument
'Start transactie
Using Transactie As Transaction = Dwg.TransactionManager.StartTransaction()
'Try
Dim PlotSettingsDictionary As DBDictionary
PlotSettingsDictionary = Transactie.GetObject(Dwg.PlotSettingsDictionaryId, OpenMode.ForRead)
Dim VisualStylesDictionary As DBDictionary
VisualStylesDictionary = Transactie.GetObject(Dwg.VisualStyleDictionaryId, OpenMode.ForRead)
Dim PlotSettings As PlotSettings
Dim CreateNew As Boolean = False
' Reference the Layout Manager
Dim LayoutManager As LayoutManager = LayoutManager.Current
'Get the current layout and output its name in the Command Line window
Dim Layout As Layout
Layout = Transactie.GetObject(LayoutManager.GetLayoutId(LayoutManager.CurrentLayout), OpenMode.ForRead)
' Check to see if the page setup exists
If PlotSettingsDictionary.Contains(LayoutName) = False Then
CreateNew = True
'Create a new PlotSettings object:
'True= Modelspace, False = Named layout (Paperspace)
PlotSettings = New PlotSettings(Layout.ModelType)
PlotSettings.CopyFrom(Layout)
PlotSettings.PlotSettingsName = PageSetupNaam
PlotSettings.AddToPlotSettingsDictionary(Dwg)
Transactie.AddNewlyCreatedDBObject(PlotSettings, True)
Else
PlotSettings = PlotSettingsDictionary.GetAt(PageSetupNaam).GetObject(OpenMode.ForWrite)
End If
' Bijwerken van de object PlotSettings
Try
Dim PlotSettingsValidator As PlotSettingsValidator
PlotSettingsValidator = PlotSettingsValidator.Current
'Selecteer de plotter en het papierformaat
'Voorbeeld: PlotSettingsValidator.SetPlotConfigurationName(PlotSettings, "DWF6 ePlot.pc3", "ANSI_B_(17.00_x_11.00_Inches)")
PlotSettingsValidator.SetPlotConfigurationName(PlotSettings, PlotterName, PaperSize)
'Set to plot to the current display
If Layout.ModelType = False Then
PlotSettingsValidator.SetPlotType(PlotSettings, Autodesk.AutoCAD.DatabaseServices.PlotType.Layout)
Else
PlotSettingsValidator.SetPlotType(PlotSettings, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents)
PlotSettingsValidator.SetPlotCentered(PlotSettings, True)
End If
' Use SetPlotWindowArea with PlotType.Window
'PlotSettingsValidator.SetPlotWindowArea(plSet, New Extents2d(New Point2d(0.0, 0.0), New Point2d(9.0, 12.0)))
' Use SetPlotViewName with PlotType.View
'PlotSettingsValidator.SetPlotViewName(plSet, "MyView")
'Instellen Plot offset (Origin set to printable area)
PlotSettingsValidator.SetPlotOrigin(PlotSettings, New Point2d(0, 0))
'Instellen Plot Scale:
PlotSettingsValidator.SetUseStandardScale(PlotSettings, True)
'Schaal
PlotSettingsValidator.SetStdScaleType(PlotSettings, StdScaleType.StdScale1To1)
'Ploteenheid (millimeters / Inches)
PlotSettingsValidator.SetPlotPaperUnits(PlotSettings, PlotPaperUnit.Millimeters)
'Scale lineweight
PlotSettings.ScaleLineweights = False
' Display plot styles
PlotSettings.ShowPlotStyles = False
' Bijwerken (Rebuild) plotter, plot style, and canonical media lists (must be called before setting the plot style)
PlotSettingsValidator.RefreshLists(PlotSettings)
'Instellen Shaded viewport options
'Shade Plot:
PlotSettings.ShadePlot = PlotSettingsShadePlotType.AsDisplayed
'Quality:
PlotSettings.ShadePlotResLevel = ShadePlotResLevel.Normal
'Instellen Plot options:
PlotSettings.PrintLineweights = True
PlotSettings.PlotTransparency = False
PlotSettings.PlotPlotStyles = True
PlotSettings.DrawViewportsFirst = True
' Use only on named layouts - Hide paperspace objects option
' plSet.PlotHidden = True
'Instellen Drawing orientation:
PlotSettingsValidator.SetPlotRotation(PlotSettings, PlotRotation.Degrees000)
' Instellen Plot Style Table (Pen assignment)
If Dwg.PlotStyleMode = True Then
PlotSettingsValidator.SetCurrentStyleSheet(PlotSettings, CTBfileName)
Else
PlotSettingsValidator.SetCurrentStyleSheet(PlotSettings, "acad.ctb")
End If
'Weergeven van het papierformaat / Zoom extend
PlotSettingsValidator.SetZoomToPaperOnUpdate(PlotSettings, True)
' Catch es As Autodesk.AutoCAD.Runtime.Exception
' MsgBox("Fout in PageSetupInstellenOfWijzigingen: " & vbCrLf & ex.Message)
' End Try
'End Try
' Bijwerken (Rebuild) plotter, plot style, and canonical media lists (must be called before setting the plot style)
PlotSettingsValidator.RefreshLists(PlotSettings)
If CreateNew = True Then
PlotSettings.Dispose()
End If
'Voltooi transactie
Transactie.Commit()
'Opvangen en melding bij een fout
Catch ex As Exception
MsgBox("Fout in PageSetupInstellenPlotter: " & vbCrLf & ex.Message)
End Try
' End Try
End Using
End Using
End Sub
Greetings, Tori72
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.