<?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 C# eInvalidInput SetPlotConfigurationName new PC3 in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/c-einvalidinput-setplotconfigurationname-new-pc3/m-p/13365122#M586</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;I have code to print, but it doesn't print quite right. So I created a new PC3 file to use for my print. However now I'm getting an error at the PlotSetValidator.SetPlotConfiguration line. It's a runtime error "DB.WriteLine(" (See top screenshot).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Without an certainty I think this might be because the media dropdown is greyed out when using this pc3 to print (See 2nd screeshot). The SetPlotConfiguration command is trying to specify media where it can't.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to print with custom pc3 files where the media can't be changed?&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="snappyjazz_0-1741717548802.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1476459i5B068A35C17FA67E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="snappyjazz_0-1741717548802.png" alt="snappyjazz_0-1741717548802.png" /&gt;&lt;/span&gt;&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="snappyjazz_1-1741717561527.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1476460iBC6F67DFE4B3BF45/image-size/medium?v=v2&amp;amp;px=400" role="button" title="snappyjazz_1-1741717561527.png" alt="snappyjazz_1-1741717561527.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;LI-CODE lang="general"&gt;namespace AutocadAddinC.EZ_Print_Commands
{
    class FitToC
    {
        // Fit drawing to C size Print Command
        public static void Emp_FitToC()
        {

            // Exit if printer is busy
            if (CadPrint.PlotFactory.ProcessPlotState != CadPrint.ProcessPlotState.NotPlotting) 
            { g_AcDoc.Editor.WriteMessage($"\nAnother plot is in progress.\\n\""); DB.WriteLine($"\nAnother plot is in progress.\n"); return; }
            // Exit if not paper space
            if (g_ActiveLayout.Layout.ModelType == true) 
            { g_AcDoc.Editor.WriteMessage($"\nThis command is setup to print from paperspace."); DB.WriteLine($"\nThis command is setup to print from paperspace.\n"); return; }
            // Get and set the BackgroundPlot system variable value
            Object backPlot = CadApp.Application.GetSystemVariable("BACKGROUNDPLOT"); CadApp.Application.SetSystemVariable("BACKGROUNDPLOT", 0);
            // Get and set the plot config system variable value
            Object SysCfg = CadApp.Application.GetSystemVariable("SYSPLOTCFG"); CadApp.Application.SetSystemVariable("SYSPLOTCFG", 1);
            //DB.WriteLine($"Updated System Variable (sysplotcfg): {CadApp.Application.GetSystemVariable("SYSPLOTCFG")}");

            CadDBS.Transaction Trans = g_AcDatBas.TransactionManager.StartTransaction();
            CadDBS.BlockTableRecord BlTblRec = (CadDBS.BlockTableRecord)Trans.GetObject(g_AcDatBas.CurrentSpaceId, CadDBS.OpenMode.ForRead);
            CadPrint.PlotInfo PlotInfo = new CadPrint.PlotInfo();
            CadDBS.PlotSettings PlSet = new CadDBS.PlotSettings(g_ActiveLayout.Layout.ModelType);
            CadDBS.PlotSettingsValidator PlSetVal = CadDBS.PlotSettingsValidator.Current;

            //try
            //{
                PlotInfo.Layout = BlTblRec.LayoutId;

                // API makes sure that the new "plotsettings" is initialized correctly.
                CadDBS.DBDictionary plSets = (CadDBS.DBDictionary)Trans.GetObject(g_AcDatBas.PlotSettingsDictionaryId, CadDBS.OpenMode.ForRead);

                // Establish plot setup name
                string PlSetName = "EZ-Print-DD_Plotter-C-Scale_To_Fit";
            //DB.WriteLine($"\n...\tPlot Style: {PlSetName}\n");

            #region copy page setup from layout
            // Create a new PlotSettings object for: 
            //    true - model space, false - named layout
            PlSet = new CadDBS.PlotSettings(g_ActiveLayout.Layout.ModelType); //&amp;lt;-- not used when copy and pasted
                // Use CopyFrom property of the plotsetting to initialize it on the layout
                PlSet.CopyFrom(g_ActiveLayout.Layout); // API makes sure that the new "PlotSettings" is initialized correctly, by copying the existing one.

                // Set the name of the Plot Settings (Page Setup)
                PlSet.PlotSettingsName = PlSetName;

                // Add to the plot settings dictionary (Adds to the drawing database)
                PlSet.AddToPlotSettingsDictionary(g_AcDatBas);

                // Adds the plot settings to the transaction
                Trans.AddNewlyCreatedDBObject(PlSet, true);

                // Refreshing the plot settings with plot settings validator
                PlSetVal.RefreshLists(PlSet);
            #endregion

            // Establish plotter and sheet
            //PlSetVal.SetPlotConfigurationName(PlSet, g_PP.DdPlotterC, g_PPS.DD_Arch_C);
            PlSetVal.SetPlotConfigurationName(PlSet, "SysPrint_DD_ENG_ARCH_C", "4444 458 611");
            DB.WriteLine($"\n...\tPlotter: {g_PP.DdPlotter} | Paper: {g_PPS.DD_Arch_C}\n");

            #region AutoCad Print Dialog Settings
            // Rotate 90 degrees
            //PlSetVal.SetPlotRotation(PlSet, CadDBS.PlotRotation.Degrees090);
            //PlSetVal.SetPlotRotation(PlSet, CadDBS.PlotRotation.Degrees270); // Landscape
            //PlSetVal.SetPlotRotation(PlSet, CadDBS.PlotRotation.Degrees180); // Portrait

            PlSetVal = CadDBS.PlotSettingsValidator.Current; //&amp;lt;-- not used when copy and pasted
                PlSet.ShowPlotStyles = true;
                PlSet.ShadePlot = CadDBS.PlotSettingsShadePlotType.AsDisplayed;
                PlSet.ShadePlotResLevel = CadDBS.ShadePlotResLevel.Normal;
                PlSet.ShadePlotCustomDpi = 300;
                PlSet.PlotHidden = false;
                PlSet.PrintLineweights = false;
                PlSet.ScaleLineweights = false;
                PlSet.DrawViewportsFirst = false;
                //PlSet.SetPaperOrientation(true); // &amp;lt; --Creates a match between plot settings and page setup
                //PlSet.PaperOrientation = CadDBS.PaperOrientationStates.True;
                //PlSetVal.SetPlotPaperUnits(PlSet, CadDBS.PlotPaperUnit.Inches)
                //PlSetVal.SetCustomPrintScale(PlSet, ScaleConv) //&amp;lt;--Used with Layout plot type
                //PlSetVal.SetPlotType(PlSet, CadDBS.PlotType.Layout)
                //PlSetVal.SetPlotWindowArea(PlSet, Layout.Limits) //&amp;lt;--Used with Window plot type
                //PlSetVal.SetPlotType(PlSet, CadDBS.PlotType.Window)
                PlSetVal.SetPlotType(PlSet, CadDBS.PlotType.Extents);
                PlSetVal.SetStdScaleType(PlSet, CadDBS.StdScaleType.ScaleToFit); //&amp;lt;-- Used with Window Plot Type. This is greyed out when using layout plot type
                PlSetVal.SetPlotCentered(PlSet, true); //&amp;lt;-- Center is greyed out when plot area (Type) is set to "Layout"
                //PlSetVal.SetPlotOrigin(PlSet, new CadGeo.Point2d(0, 0)); //&amp;lt;--overwrites the centered option if after.

                // Validate that the style exists and switch to it.
                if (PlSetVal.GetPlotStyleSheetList().Contains(g_PS.Monochrome.ToString())) { PlSetVal.SetCurrentStyleSheet(PlSet, g_PS.Monochrome.ToString()); } else { DB.WriteLine($"\nCouldn't load {g_PS.Monochrome.ToString()} style.\n"); }
                #endregion

                // Zoom to show the whole paper
                PlSetVal.SetZoomToPaperOnUpdate(PlSet, true);

                //Add these plot settings to the plot settings dictionary
                PlSet.AddToPlotSettingsDictionary(g_AcDatBas);

                // Refresh the plot settings with plot settings validator
                PlSetVal.RefreshLists(PlSet);

                // Update the plot info with the plot settings
                PlotInfo.OverrideSettings = PlSet;
                CadPrint.PlotInfoValidator PlotInfoVal = new CadPrint.PlotInfoValidator();
                PlotInfoVal.MediaMatchingPolicy = CadPrint.MatchingPolicy.MatchEnabled;
                PlotInfoVal.Validate(PlotInfo);

                // Plot the sheet
                PlotWithDialog(ref PlotInfo, ref Trans);

                g_ActiveLayout.Layout.Dispose();
                Trans.Commit();
                PlSet.Dispose();
                PlSetVal.Dispose();

                // Regenerate the document
                g_AcDoc.Editor.Regen();

                // Restore the previous value for the Backgroundplot system variable
                CadApp.Application.SetSystemVariable("BACKGROUNDPLOT", backPlot);
                // Restor the previous value for the plot config system variable
                CadApp.Application.SetSystemVariable("SYSPLOTCFG", SysCfg);

            //}
            //catch (System.Exception ex)
            //{
            //    // Restore the previous value for the Backgroundplot system variable
            //    CadApp.Application.SetSystemVariable("BACKGROUNDPLOT", backPlot);
            //    // Restor the previous value for the plot config system variable
            //    CadApp.Application.SetSystemVariable("SYSPLOTCFG", SysCfg);
            //    g_AcDoc.Editor.WriteMessage($"\nCouldn//t complete the print function.");
            //    DB.WriteLine($"Had to exit early...\n");
            //    Trans.Abort();
            //    return;
            //}

            DB.WriteLine($"\nEnded...\n");
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Mar 2025 18:42:04 GMT</pubDate>
    <dc:creator>snappyjazz</dc:creator>
    <dc:date>2025-03-11T18:42:04Z</dc:date>
    <item>
      <title>C# eInvalidInput SetPlotConfigurationName new PC3</title>
      <link>https://forums.autodesk.com/t5/net-forum/c-einvalidinput-setplotconfigurationname-new-pc3/m-p/13365122#M586</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I have code to print, but it doesn't print quite right. So I created a new PC3 file to use for my print. However now I'm getting an error at the PlotSetValidator.SetPlotConfiguration line. It's a runtime error "DB.WriteLine(" (See top screenshot).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Without an certainty I think this might be because the media dropdown is greyed out when using this pc3 to print (See 2nd screeshot). The SetPlotConfiguration command is trying to specify media where it can't.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to print with custom pc3 files where the media can't be changed?&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="snappyjazz_0-1741717548802.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1476459i5B068A35C17FA67E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="snappyjazz_0-1741717548802.png" alt="snappyjazz_0-1741717548802.png" /&gt;&lt;/span&gt;&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="snappyjazz_1-1741717561527.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1476460iBC6F67DFE4B3BF45/image-size/medium?v=v2&amp;amp;px=400" role="button" title="snappyjazz_1-1741717561527.png" alt="snappyjazz_1-1741717561527.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;LI-CODE lang="general"&gt;namespace AutocadAddinC.EZ_Print_Commands
{
    class FitToC
    {
        // Fit drawing to C size Print Command
        public static void Emp_FitToC()
        {

            // Exit if printer is busy
            if (CadPrint.PlotFactory.ProcessPlotState != CadPrint.ProcessPlotState.NotPlotting) 
            { g_AcDoc.Editor.WriteMessage($"\nAnother plot is in progress.\\n\""); DB.WriteLine($"\nAnother plot is in progress.\n"); return; }
            // Exit if not paper space
            if (g_ActiveLayout.Layout.ModelType == true) 
            { g_AcDoc.Editor.WriteMessage($"\nThis command is setup to print from paperspace."); DB.WriteLine($"\nThis command is setup to print from paperspace.\n"); return; }
            // Get and set the BackgroundPlot system variable value
            Object backPlot = CadApp.Application.GetSystemVariable("BACKGROUNDPLOT"); CadApp.Application.SetSystemVariable("BACKGROUNDPLOT", 0);
            // Get and set the plot config system variable value
            Object SysCfg = CadApp.Application.GetSystemVariable("SYSPLOTCFG"); CadApp.Application.SetSystemVariable("SYSPLOTCFG", 1);
            //DB.WriteLine($"Updated System Variable (sysplotcfg): {CadApp.Application.GetSystemVariable("SYSPLOTCFG")}");

            CadDBS.Transaction Trans = g_AcDatBas.TransactionManager.StartTransaction();
            CadDBS.BlockTableRecord BlTblRec = (CadDBS.BlockTableRecord)Trans.GetObject(g_AcDatBas.CurrentSpaceId, CadDBS.OpenMode.ForRead);
            CadPrint.PlotInfo PlotInfo = new CadPrint.PlotInfo();
            CadDBS.PlotSettings PlSet = new CadDBS.PlotSettings(g_ActiveLayout.Layout.ModelType);
            CadDBS.PlotSettingsValidator PlSetVal = CadDBS.PlotSettingsValidator.Current;

            //try
            //{
                PlotInfo.Layout = BlTblRec.LayoutId;

                // API makes sure that the new "plotsettings" is initialized correctly.
                CadDBS.DBDictionary plSets = (CadDBS.DBDictionary)Trans.GetObject(g_AcDatBas.PlotSettingsDictionaryId, CadDBS.OpenMode.ForRead);

                // Establish plot setup name
                string PlSetName = "EZ-Print-DD_Plotter-C-Scale_To_Fit";
            //DB.WriteLine($"\n...\tPlot Style: {PlSetName}\n");

            #region copy page setup from layout
            // Create a new PlotSettings object for: 
            //    true - model space, false - named layout
            PlSet = new CadDBS.PlotSettings(g_ActiveLayout.Layout.ModelType); //&amp;lt;-- not used when copy and pasted
                // Use CopyFrom property of the plotsetting to initialize it on the layout
                PlSet.CopyFrom(g_ActiveLayout.Layout); // API makes sure that the new "PlotSettings" is initialized correctly, by copying the existing one.

                // Set the name of the Plot Settings (Page Setup)
                PlSet.PlotSettingsName = PlSetName;

                // Add to the plot settings dictionary (Adds to the drawing database)
                PlSet.AddToPlotSettingsDictionary(g_AcDatBas);

                // Adds the plot settings to the transaction
                Trans.AddNewlyCreatedDBObject(PlSet, true);

                // Refreshing the plot settings with plot settings validator
                PlSetVal.RefreshLists(PlSet);
            #endregion

            // Establish plotter and sheet
            //PlSetVal.SetPlotConfigurationName(PlSet, g_PP.DdPlotterC, g_PPS.DD_Arch_C);
            PlSetVal.SetPlotConfigurationName(PlSet, "SysPrint_DD_ENG_ARCH_C", "4444 458 611");
            DB.WriteLine($"\n...\tPlotter: {g_PP.DdPlotter} | Paper: {g_PPS.DD_Arch_C}\n");

            #region AutoCad Print Dialog Settings
            // Rotate 90 degrees
            //PlSetVal.SetPlotRotation(PlSet, CadDBS.PlotRotation.Degrees090);
            //PlSetVal.SetPlotRotation(PlSet, CadDBS.PlotRotation.Degrees270); // Landscape
            //PlSetVal.SetPlotRotation(PlSet, CadDBS.PlotRotation.Degrees180); // Portrait

            PlSetVal = CadDBS.PlotSettingsValidator.Current; //&amp;lt;-- not used when copy and pasted
                PlSet.ShowPlotStyles = true;
                PlSet.ShadePlot = CadDBS.PlotSettingsShadePlotType.AsDisplayed;
                PlSet.ShadePlotResLevel = CadDBS.ShadePlotResLevel.Normal;
                PlSet.ShadePlotCustomDpi = 300;
                PlSet.PlotHidden = false;
                PlSet.PrintLineweights = false;
                PlSet.ScaleLineweights = false;
                PlSet.DrawViewportsFirst = false;
                //PlSet.SetPaperOrientation(true); // &amp;lt; --Creates a match between plot settings and page setup
                //PlSet.PaperOrientation = CadDBS.PaperOrientationStates.True;
                //PlSetVal.SetPlotPaperUnits(PlSet, CadDBS.PlotPaperUnit.Inches)
                //PlSetVal.SetCustomPrintScale(PlSet, ScaleConv) //&amp;lt;--Used with Layout plot type
                //PlSetVal.SetPlotType(PlSet, CadDBS.PlotType.Layout)
                //PlSetVal.SetPlotWindowArea(PlSet, Layout.Limits) //&amp;lt;--Used with Window plot type
                //PlSetVal.SetPlotType(PlSet, CadDBS.PlotType.Window)
                PlSetVal.SetPlotType(PlSet, CadDBS.PlotType.Extents);
                PlSetVal.SetStdScaleType(PlSet, CadDBS.StdScaleType.ScaleToFit); //&amp;lt;-- Used with Window Plot Type. This is greyed out when using layout plot type
                PlSetVal.SetPlotCentered(PlSet, true); //&amp;lt;-- Center is greyed out when plot area (Type) is set to "Layout"
                //PlSetVal.SetPlotOrigin(PlSet, new CadGeo.Point2d(0, 0)); //&amp;lt;--overwrites the centered option if after.

                // Validate that the style exists and switch to it.
                if (PlSetVal.GetPlotStyleSheetList().Contains(g_PS.Monochrome.ToString())) { PlSetVal.SetCurrentStyleSheet(PlSet, g_PS.Monochrome.ToString()); } else { DB.WriteLine($"\nCouldn't load {g_PS.Monochrome.ToString()} style.\n"); }
                #endregion

                // Zoom to show the whole paper
                PlSetVal.SetZoomToPaperOnUpdate(PlSet, true);

                //Add these plot settings to the plot settings dictionary
                PlSet.AddToPlotSettingsDictionary(g_AcDatBas);

                // Refresh the plot settings with plot settings validator
                PlSetVal.RefreshLists(PlSet);

                // Update the plot info with the plot settings
                PlotInfo.OverrideSettings = PlSet;
                CadPrint.PlotInfoValidator PlotInfoVal = new CadPrint.PlotInfoValidator();
                PlotInfoVal.MediaMatchingPolicy = CadPrint.MatchingPolicy.MatchEnabled;
                PlotInfoVal.Validate(PlotInfo);

                // Plot the sheet
                PlotWithDialog(ref PlotInfo, ref Trans);

                g_ActiveLayout.Layout.Dispose();
                Trans.Commit();
                PlSet.Dispose();
                PlSetVal.Dispose();

                // Regenerate the document
                g_AcDoc.Editor.Regen();

                // Restore the previous value for the Backgroundplot system variable
                CadApp.Application.SetSystemVariable("BACKGROUNDPLOT", backPlot);
                // Restor the previous value for the plot config system variable
                CadApp.Application.SetSystemVariable("SYSPLOTCFG", SysCfg);

            //}
            //catch (System.Exception ex)
            //{
            //    // Restore the previous value for the Backgroundplot system variable
            //    CadApp.Application.SetSystemVariable("BACKGROUNDPLOT", backPlot);
            //    // Restor the previous value for the plot config system variable
            //    CadApp.Application.SetSystemVariable("SYSPLOTCFG", SysCfg);
            //    g_AcDoc.Editor.WriteMessage($"\nCouldn//t complete the print function.");
            //    DB.WriteLine($"Had to exit early...\n");
            //    Trans.Abort();
            //    return;
            //}

            DB.WriteLine($"\nEnded...\n");
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Mar 2025 18:42:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/c-einvalidinput-setplotconfigurationname-new-pc3/m-p/13365122#M586</guid>
      <dc:creator>snappyjazz</dc:creator>
      <dc:date>2025-03-11T18:42:04Z</dc:date>
    </item>
  </channel>
</rss>

