<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: cannot read custom paper size with c# in AutoCAD 2014 above in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7816141#M27111</link>
    <description>&lt;P&gt;SENL1362:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;I finally got it. It's related to acad's plot file support path. Although in acad's option dialog, the&amp;nbsp;support path like :&lt;/P&gt;&lt;P&gt;C:\Users\xxxxx\AppData\Roaming\Autodesk\AutoCAD 2016\R20.1\chs\Plotters, and the modified pc3 file is located at that folder, acad has another default PC3 folder, like :&amp;nbsp;C:\Users\xxxxx\AppData\Roaming\Autodesk\AutoCAD 2016\R20.1\chs\Plotters\AutoCAD 2016 -&amp;nbsp; PC3&amp;nbsp;File.&lt;/P&gt;&lt;P&gt;If that folder exists, GetCanonicalMediaNameList() call&amp;nbsp; reads pc3 from it. If it does not exist, the function reads the actual modified pc3 file. What a misleading&amp;nbsp;mechanism...&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Any way, thank you for your help!&lt;/P&gt;</description>
    <pubDate>Wed, 28 Feb 2018 14:40:09 GMT</pubDate>
    <dc:creator>kuang_hf</dc:creator>
    <dc:date>2018-02-28T14:40:09Z</dc:date>
    <item>
      <title>cannot read custom paper size with c# in AutoCAD 2014 above</title>
      <link>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7811106#M27101</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;Does anyone know why I cannot read&amp;nbsp;custom paper size with c# in AutoCAD 2014 and above version? I read it successfully through&amp;nbsp; PlosettingValidator.GetCanonicalMediaNameList() under Acad 2012 and 2013. But failed in 2014 and 2016. The pc3 is 'DWG To PDF.pc3'.&lt;/P&gt;&lt;P&gt;I also call&amp;nbsp;&lt;SPAN&gt;PlosettingValidator.&lt;/SPAN&gt;RefreshLists() before&amp;nbsp;&lt;SPAN&gt;GetCanonicalMediaNameList. Is there anything special in this API of ACAD 2014 and above?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The code snippet:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ArrayList media_list = new ArrayList();&lt;BR /&gt;Transaction tr = db.TransactionManager.StartTransaction();&lt;BR /&gt;using (tr)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForRead);&lt;BR /&gt;&amp;nbsp; Layout layout = (Layout)tr.GetObject(btr.LayoutId, OpenMode.ForRead);&lt;BR /&gt;&amp;nbsp; PlotSettings ps = new PlotSettings(layout.ModelType);&lt;BR /&gt;&amp;nbsp; ps.CopyFrom(layout);&lt;BR /&gt;&amp;nbsp; PlotSettingsValidator psv = PlotSettingsValidator.Current;&lt;BR /&gt;&amp;nbsp; psv.SetPlotConfigurationName(ps, devname, null);&lt;BR /&gt;&amp;nbsp; psv.RefreshLists(ps);&lt;/P&gt;&lt;P&gt;&amp;nbsp; StringCollection medlist = psv.GetCanonicalMediaNameList(ps);&lt;BR /&gt;&amp;nbsp; foreach (string medname in medlist)&lt;BR /&gt;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; psv.SetPlotConfigurationName(ps, devname, medname);&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;PaperInfo pi = new PaperInfo();&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;pi.name = medname;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;pi.local_name = psv.GetLocaleMediaName(ps, medname);&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;pi.width = ps.PlotPaperSize.X;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;pi.height = ps.PlotPaperSize.Y;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;pi.margin = ps.PlotPaperMargins;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;media_list.Add(pi);&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; ps.Dispose();&lt;BR /&gt;&amp;nbsp; psv.Dispose();&lt;/P&gt;&lt;P&gt;&amp;nbsp; tr.Abort();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 02:13:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7811106#M27101</guid>
      <dc:creator>kuang_hf</dc:creator>
      <dc:date>2018-02-27T02:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: cannot read custom paper size with c# in AutoCAD 2014 above</title>
      <link>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7811601#M27102</link>
      <description>Not that i know of, but you you need to add the custom paper sizes you're self.&lt;BR /&gt;They are stored in the associated PMP file.</description>
      <pubDate>Tue, 27 Feb 2018 08:14:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7811601#M27102</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2018-02-27T08:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: cannot read custom paper size with c# in AutoCAD 2014 above</title>
      <link>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7811618#M27103</link>
      <description>&lt;P&gt;...&lt;BR /&gt;psv.RefreshLists(plotSettings);&lt;BR /&gt;var canonicalMediaNames = psv.GetCanonicalMediaNameList(plotSettings);&lt;BR /&gt;foreach (string canonicalMediaName in canonicalMediaNames)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; var localMediaName = psv.GetLocaleMediaName(plotSettings, canonicalMediaName);&lt;BR /&gt;&amp;nbsp; psv.SetCanonicalMediaName(plotSettings, canonicalMediaName);&lt;BR /&gt;&amp;nbsp; ed.WriteMessage($"\nPlotPaperSize={plotSettings.PlotPaperSize.X} X {plotSettings.PlotPaperSize.Y}");&lt;BR /&gt;...&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 08:22:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7811618#M27103</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2018-02-27T08:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: cannot read custom paper size with c# in AutoCAD 2014 above</title>
      <link>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7814425#M27104</link>
      <description>&lt;P&gt;Surely I have added custom paper size in ACAD first.&amp;nbsp; But it seems in higher version of CAD I cannot get them through&amp;nbsp;GetCanonicalMediaNameList.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 02:26:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7814425#M27104</guid>
      <dc:creator>kuang_hf</dc:creator>
      <dc:date>2018-02-28T02:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: cannot read custom paper size with c# in AutoCAD 2014 above</title>
      <link>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7814776#M27105</link>
      <description>&lt;P&gt;Is it allowed to send the PC3+PMP?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 07:22:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7814776#M27105</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2018-02-28T07:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: cannot read custom paper size with c# in AutoCAD 2014 above</title>
      <link>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7814796#M27106</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi&amp;nbsp; SENL1362,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Files attached. It's in acad 2016, and has a custom paper 880*1280 mm.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 07:30:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7814796#M27106</guid>
      <dc:creator>kuang_hf</dc:creator>
      <dc:date>2018-02-28T07:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: cannot read custom paper size with c# in AutoCAD 2014 above</title>
      <link>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7814862#M27107</link>
      <description>&lt;P&gt;You shouldn't have give away the custom paper size &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway i don't see the problem, i can read the papersize directly from the PlotSettings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/468724iF5CEF25F497C7A4A/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;[CommandMethod("TestPlotMedia")]
public static void TestPlotMedia()
{
    Document doc = null;
    Editor ed = null;
    Database db = null;
    LayoutManager lm = null;

    var pc3Name = "DWG To PDF.pc3";

    try
    {
        doc = AcadApp.DocumentManager.MdiActiveDocument;
        ed = doc.Editor;
        db = doc.Database;
        lm = LayoutManager.Current;
        var psv = PlotSettingsValidator.Current;

        ed.WriteMessage($"\nPc3: {pc3Name}");
        using (var tr = db.TransactionManager.StartTransaction())
        {
            var layoutName = lm.CurrentLayout;
            var layoutId = lm.GetLayoutId(layoutName);
            var layout = (Layout)tr.GetObject(layoutId, OpenMode.ForRead);
            var ps = new PlotSettings(layout.ModelType);
            ps.CopyFrom(layout);
            psv.SetPlotConfigurationName(ps, pc3Name, null);
            psv.RefreshLists(ps);
            var canMedNames=psv.GetCanonicalMediaNameList(ps);
            foreach(var canMedName in canMedNames)
            {
                psv.SetCanonicalMediaName(ps, canMedName);

                var medName = psv.GetLocaleMediaName(ps, canMedName);
                var papUnts = ps.PlotPaperUnits;
                var papSize=ps.PlotPaperSize;
                var papMargins= ps.PlotPaperMargins;
                ed.WriteMessage($"\n\t Paper: {medName} ({canMedName})");
                ed.WriteMessage($"\n\t\t Units  : {papUnts.ToString()}");
                ed.WriteMessage($"\n\t\t Size   : {papSize.X} X {papSize.Y}");
                ed.WriteMessage($"\n\t\t Margins: {papMargins.MinPoint.ToString()} X {papMargins.MaxPoint.ToString()}");
            }
            tr.Commit();
        }
    }
    catch (System.Exception ex)
    {
        ed?.WriteMessage($"\n{ex.Message}");
    }
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 08:03:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7814862#M27107</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2018-02-28T08:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: cannot read custom paper size with c# in AutoCAD 2014 above</title>
      <link>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7814887#M27108</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And some additional lines of code to return a list of all the media details:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;...
var plotMedias = new Dictionary&amp;lt;string, Dictionary&amp;lt;string, Object&amp;gt;&amp;gt;(StringComparer.OrdinalIgnoreCase);
ed.WriteMessage($"\nPc3: {pc3Name}");
...
foreach(var canMedName in canMedNames)
{
   var mediaDetails = new Dictionary&amp;lt;string, Object&amp;gt;(StringComparer.OrdinalIgnoreCase);
  psv.SetCanonicalMediaName(ps, canMedName);
...
  //ed.WriteMessage(...
  mediaDetails["LocalMediaName"] = medName;
  mediaDetails["CanonicalMediaName"] = canMedName;
  mediaDetails["PaperSize"] = ps.PlotPaperSize;
  mediaDetails["PaperMargins"] = ps.PlotPaperMargins;
  mediaDetails["PaperUnits"] = ps.PlotPaperUnits;
  plotMedias[medName] = mediaDetails;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 08:11:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7814887#M27108</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2018-02-28T08:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: cannot read custom paper size with c# in AutoCAD 2014 above</title>
      <link>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7815172#M27109</link>
      <description>&lt;P&gt;Thanks for you code. I tried it, but in my acad 2016, it just read out standard paper size, no custom paper.&amp;nbsp; I'm sure there is only one 'DWG to PDF.pc3'. So strange:(&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 10:06:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7815172#M27109</guid>
      <dc:creator>kuang_hf</dc:creator>
      <dc:date>2018-02-28T10:06:03Z</dc:date>
    </item>
    <item>
      <title>Re: cannot read custom paper size with c# in AutoCAD 2014 above</title>
      <link>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7815296#M27110</link>
      <description>&lt;P&gt;that can be easily tested:&lt;/P&gt;
&lt;P&gt;Snippet&lt;/P&gt;
&lt;PRE style="font-family: Consolas; font-size: 13; color: black; background: white;"&gt;&lt;SPAN style="color: blue;"&gt;var&lt;/SPAN&gt;&amp;nbsp;acadPref&amp;nbsp;=&amp;nbsp;(&lt;SPAN style="color: blue;"&gt;dynamic&lt;/SPAN&gt;)&lt;SPAN style="color: #2b91af;"&gt;AcadApp&lt;/SPAN&gt;.Preferences;
&lt;SPAN style="color: blue;"&gt;var&lt;/SPAN&gt;&amp;nbsp;plotConfigPathname&amp;nbsp;=&amp;nbsp;acadPref.Files.PrinterConfigPath;
&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 10:44:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7815296#M27110</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2018-02-28T10:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: cannot read custom paper size with c# in AutoCAD 2014 above</title>
      <link>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7816141#M27111</link>
      <description>&lt;P&gt;SENL1362:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;I finally got it. It's related to acad's plot file support path. Although in acad's option dialog, the&amp;nbsp;support path like :&lt;/P&gt;&lt;P&gt;C:\Users\xxxxx\AppData\Roaming\Autodesk\AutoCAD 2016\R20.1\chs\Plotters, and the modified pc3 file is located at that folder, acad has another default PC3 folder, like :&amp;nbsp;C:\Users\xxxxx\AppData\Roaming\Autodesk\AutoCAD 2016\R20.1\chs\Plotters\AutoCAD 2016 -&amp;nbsp; PC3&amp;nbsp;File.&lt;/P&gt;&lt;P&gt;If that folder exists, GetCanonicalMediaNameList() call&amp;nbsp; reads pc3 from it. If it does not exist, the function reads the actual modified pc3 file. What a misleading&amp;nbsp;mechanism...&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Any way, thank you for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 14:40:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7816141#M27111</guid>
      <dc:creator>kuang_hf</dc:creator>
      <dc:date>2018-02-28T14:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: cannot read custom paper size with c# in AutoCAD 2014 above</title>
      <link>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7816210#M27112</link>
      <description>&lt;P&gt;You could add this to find out where the PC3 comes from:&lt;/P&gt;
&lt;P&gt;Snippet&lt;/P&gt;
&lt;PRE style="font-family: Consolas; font-size: 13; color: black; background: white;"&gt;&lt;SPAN style="color: #2b91af;"&gt;PlotConfigManager&lt;/SPAN&gt;.RefreshList(&lt;SPAN style="color: #2b91af;"&gt;RefreshCode&lt;/SPAN&gt;.RefreshDevicesList);
&lt;SPAN style="color: blue;"&gt;foreach&lt;/SPAN&gt;(&lt;SPAN style="color: #2b91af;"&gt;PlotConfigInfo&lt;/SPAN&gt;&amp;nbsp;pd&amp;nbsp;&lt;SPAN style="color: blue;"&gt;in&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN style="color: #2b91af;"&gt;PlotConfigManager&lt;/SPAN&gt;.Devices)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ed.WriteMessage(&lt;SPAN style="color: #a31515;"&gt;$"\n&lt;/SPAN&gt;{pd.DeviceType}&lt;SPAN style="color: #a31515;"&gt;:&amp;nbsp;&lt;/SPAN&gt;{pd.DeviceName}&lt;SPAN style="color: #a31515;"&gt;,&amp;nbsp;@:&lt;/SPAN&gt;{pd.FullPath}&lt;SPAN style="color: #a31515;"&gt;"&lt;/SPAN&gt;);
}
&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Feb 2018 14:57:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cannot-read-custom-paper-size-with-c-in-autocad-2014-above/m-p/7816210#M27112</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2018-02-28T14:57:51Z</dc:date>
    </item>
  </channel>
</rss>

