.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Printer Paper Sizes
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I am trying to get the various sizes of paper for each printer. I can do this for Windows Printers.
But I also want to get the sizes of the .pc3 files.
So far I have this.
Friend Function GetPaperSizes(ByVal Plotter As String) As StringCollection
For i = 0 To PrinterSettings.InstalledPrinters.Count - 1
ps.PrinterName = PrinterSettings.InstalledPrinters.Item(i)
For j = 0 To ps.PaperSizes.Count - 1
pz = ps.PaperSizes.Item(j)
AcadEdt.WriteMessage(vbLf & pz.PaperName & " w=" & pz.Width * 0.254 & " h=" & pz.Height * 0.254)
Next
Next
Dim p As PlotConfig = PlotConfigManager.SetCurrentConfig(Plotter)
Dim t As String = p.Comment
AcadEdt.WriteMessage(vbLf & t)
Using tr As Transaction = CurDb.TransactionManager.StartTransaction()
Dim lyMgr As LayoutManager = LayoutManager.Current ' Get the current layout
Dim cLayout As Layout = tr.GetObject(lyMgr.GetLayoutId(lyMgr.CurrentLayout ), OpenMode.ForRead)
Dim cpInfo As PlotInfo = New PlotInfo() ' Get the PlotInfo from the layout
cpInfo.Layout = cLayout.ObjectId ' Get a copy of the PlotSettings from the layout
Dim cpSet As PlotSettings = New PlotSettings(cLayout.ModelType)
cpSet.CopyFrom(cLayout) ' Update the PlotConfigurationName property of the PlotSettings object
Dim s As String = pl.Comment
' Returns a list of media sizes that are supported for the current device or the PC3 files. (Acad Help)
' except that it always returns ""
Dim cpVdr As PlotSettingsValidator = PlotSettingsValidator.Current
Try
Return cpVdr.GetCanonicalMediaNameList(cpSet)
Catch ex As Exception
Return Nothing
End Try
End Using
End FunctionSo,
I am looking for the various sheet descriptions + width and height.
All help gratefully received.
Solved! Go to Solution.
Re: Printer Paper Sizes
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
These (C#) samples may help you to find the answers.
1: QueryPlotters()
2: QueryMediaNames()
3: QueryPlotStyles()
4: QueryPaperSize()
5: QueryNamedPlotStyles()
6: QueryDetailedNamedPlotStyles()
Re: Printer Paper Sizes
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks for your help.
I've got a bit of this already, but you may well have found the missing bits for me.
Let me have a look and I'll get back to you.
Re: Printer Paper Sizes
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Watchout for the custom papersizes when creating NamedPlotStyles.
These custom papersizes are referenced by their internal id and those may alter when newley defined in a PC3 file or in the Printer.
Re: Printer Paper Sizes
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
OK. Converted to VB and tried the code
Public Sub QueryDetailedNamedPlotStyles()
Dim plSetVdr As PlotSettingsValidator = PlotSettingsValidator.Current
CurDb.TileMode = False
AcadEdt.SwitchToPaperSpace()
Using tr As Transaction = CurDb.TransactionManager.StartTransaction()
Dim plotDict As DBDictionary = DirectCast(CurDb.PlotSettingsDictionaryId.GetObjec t(OpenMode.ForRead), DBDictionary)
AcadEdt.WriteMessage(vbLf & "{0} NamedPlotStyles", plotDict.Count)etc.
plotDict.Count alwats returns 0, so I don't get the sizes etc.
I went to Page Setup, ensured I had a plotter set etc.
However, in reality the idea is to plot automatically so people don't have to setup Page.
Re: Printer Paper Sizes
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Propably an empty drawing -- no Named Plot Styles.
Try to add some from within paperspace: File/Page Setup Manager/New...
Enter Printer/Pc3, Papersize, PlotArea, PlotScale, Orientation and Pen Table
Re: Printer Paper Sizes
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Sorry. Didn't look closely enough.
I think QueryMediaNames may do the trick.
Incidently, I didn't know you could do what you do with the WriteMessage function. Neat.
I'll get back
Re: Printer Paper Sizes
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Incidently, I didn't know you could do what you do with the WriteMessage function. Neat.
Do you referring to the Formatting of strings such as in:
ed.WriteMessage("\n\tPaper: {0:0.00} X {1:0.00} ({2})", ps.PlotPaperSize.X, ps.PlotPaperSize.Y, ps.CanonicalMediaName);
You can use that in any String operation, like
String myFormattedString =String.Format("{0:0.0}", TheValue); // "0.0"
String.Format("{0:0.0}", 0.0); // "0.0"
String.Format("{0:0.#}", 0.0); // "0"
Re: Printer Paper Sizes
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I've got it working and it is just what I want.
PSizes is used elsewhere and is a global variable. It contains the Width and Height and I use the CanonicalMediaName as a key.
a_Paper.Suffix is read from an INI file and contains MM, or CM or INCHES etc.
So my code is this:
Public Sub QueryMediaNames()
PSizes = New Collection
Dim layMgr As LayoutManager = LayoutManager.Current
Dim plSetVdr As PlotSettingsValidator = PlotSettingsValidator.Current
Using tr As Transaction = CurDb.TransactionManager.StartTransaction()
Dim ly As Layout = DirectCast(tr.GetObject(layMgr.GetLayoutId(layMgr. CurrentLayout), OpenMode.ForRead), Layout)
Dim np As New PlotSettings(ly.ModelType)
np.CopyFrom(ly)
Dim canMedNames As StringCollection = plSetVdr.GetCanonicalMediaNameList(np)
Dim i As Integer, s As String
For Each c As String In canMedNames
If c.ToUpper.Contains(a_Paper.Suffix.ToUpper) Then
i = InStr(c, "(")
If i > 0 Then
Dim p As gs_Size
s = c.Substring(i)
s = s.Substring(0, s.Length - 4)
i = InStr(s, "_x_")
p.Width = CSng(s.Substring(0, i - 1))
p.Height = CSng(s.Substring(i + 2))
PSizes.Add(p, c)
End If
End If
Next
End Using
End SubThanks for your help.
I now need to use the paper sizes.
Re: Printer Paper Sizes
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
You can create a global variable using CIL but I do not think you can in VB.NET



