<?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: Publish through API in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/7877896#M26752</link>
    <description>&lt;P&gt;this is my current code:&lt;/P&gt;&lt;PRE&gt;using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using System.Collections.Generic;
using System.IO;
namespace AutoCAD.Command
{
    public class Commands
    {

        [CommandMethod("NewDrawing", CommandFlags.Session)]
          public static void NewDrawing()
        {
            string strTemplatePath = "acad.dwt";
            DocumentCollection acDocMgr = Application.DocumentManager;
            Document acDoc = acDocMgr.Add(strTemplatePath);
        }




        [CommandMethod("PrintMultiSheetsPdf", CommandFlags.Session)]
        public void PrintMultiSheetsPdf()
        {
            try
            {
                Document doc = Application.DocumentManager.MdiActiveDocument;   //mother autocad document
                PromptResult promptResult = doc.Editor.GetString("\nEnter the parameter: ");  //hardcode user command from anothert side
                if (promptResult.Status != PromptStatus.OK)
                    return;
                if (promptResult.StringResult.Contains(";") != true)
                {
                    doc.Editor.WriteMessage($"Input parametr: {promptResult.StringResult} is invalid. Right format - (destination path;source file path).");
                    return;
                }
                string[] inputParametrs = promptResult.StringResult.Split(';');     //input parameters: destination path and source file path

                if (File.Exists(inputParametrs[1]) != true)
                {
                    doc.Editor.WriteMessage($"Source file: {inputParametrs[1]} does not exist.");
                    return;
                }

                if (!System.IO.Directory.Exists(inputParametrs[0]))
                    System.IO.Directory.CreateDirectory(inputParametrs[0]);

                bool isValidate = false;
                string PaperSize = "ISO full bleed A3 (420.00 x 297.00 MM)";
                string Plottername = "DWG To PDF.pc3";
                string PlotStyleName = "PDF files for instructions.ctb";
                CustomScale customScale = new CustomScale(1, 1);
                string PaperCode = string.Empty;
                int i = 0;
                bool UsePlotStyles = true;
                bool UseLineWeights = true;
                bool ScaleLineWeights = false;
                bool HidePaperspaceObjects = false;
                bool CenterPlot = true;
                foreach (string plotDevice in PlotSettingsValidator.Current.GetPlotDeviceList())    // check available printer, 
                {
                    if (Plottername.Trim().ToUpper() == plotDevice.Trim().ToUpper())
                    {
                        isValidate = true;
                        break;
                    }
                }
                if (isValidate == false)
                {
                    doc.Editor.WriteMessage($"Selected printer: {Plottername} is not installed on this computer. Contact your system administrator");
                    return;
                }
                using (PlotSettings acPlSet = new PlotSettings(true))    //try to find right paper value because it is no possible to set GetLocaleMediaName(this value is only show in UI)
                {
                    PlotSettingsValidator acPlSetVdr = PlotSettingsValidator.Current;
                    acPlSetVdr.SetPlotConfigurationName(acPlSet, Plottername, null);
                    foreach (string mediaName in acPlSetVdr.GetCanonicalMediaNameList(acPlSet))
                    {
                        if (PaperSize.Trim().ToUpper() == acPlSetVdr.GetLocaleMediaName(acPlSet, i).Trim().ToUpper())
                        {
                            PaperCode = mediaName;
                            break;
                        }
                        i++;
                    }
                }
                if (PaperCode == string.Empty)
                {
                    doc.Editor.WriteMessage($"Selected papersize: {PaperSize} is not available on selected printer. Contact your system administrator");
                    return;
                }
                List&amp;lt;Layout&amp;gt; layouts = new List&amp;lt;Layout&amp;gt;();
                using (Database db = new Database(false, true))
                {
                    if (Functions.IsFileAvailable(new FileInfo(inputParametrs[1])) != true)
                    {
                        doc.Editor.WriteMessage($" File: {inputParametrs[1]} is already locked by some other process.");
                        return;
                    }
                    db.ReadDwgFile(inputParametrs[1], System.IO.FileShare.ReadWrite, true, ""); // open select DWG file
                    using (Transaction tr = db.TransactionManager.StartTransaction())
                    {
                        DBDictionary layoutDict = (DBDictionary)db.LayoutDictionaryId.GetObject(OpenMode.ForRead);
                        foreach (DBDictionaryEntry entry in layoutDict)
                        {
                            if (entry.Key.Trim().ToUpper() != "MODEL") // set all layouts except model
                            {
                                Layout acLayout = (Layout)tr.GetObject(entry.Value, OpenMode.ForRead);
                                using (PlotSettings currentPlSet = new PlotSettings(acLayout.ModelType))
                                {
                                    currentPlSet.CopyFrom(acLayout);
                                    PlotSettingsValidator acPlSetVdr = PlotSettingsValidator.Current;
                                    acPlSetVdr.SetPlotConfigurationName(currentPlSet, Plottername, PaperCode);
                                    acPlSetVdr.SetPlotPaperUnits(currentPlSet, PlotPaperUnit.Millimeters);
                                    acPlSetVdr.SetPlotWindowArea(currentPlSet, new Extents2d(10, 8.5, 430, 288.5));
                                    acPlSetVdr.SetPlotType(currentPlSet, Autodesk.AutoCAD.DatabaseServices.PlotType.Window);
                                    acPlSetVdr.SetPlotCentered(currentPlSet, CenterPlot);
                                    acPlSetVdr.SetPlotRotation(currentPlSet, PlotRotation.Degrees000);
                                    acPlSetVdr.SetPlotOrigin(currentPlSet, new Point2d(0, 0));
                                    currentPlSet.ShowPlotStyles = UsePlotStyles;
                                    try { acPlSetVdr.SetCurrentStyleSheet(currentPlSet, PlotStyleName); }
                                    catch
                                    {
                                        doc.Editor.WriteMessage($"AutoCAD does not contains file - {PlotStyleName} .");
                                        return;
                                    }
                                  
                                    currentPlSet.PlotHidden = HidePaperspaceObjects;
                                    currentPlSet.PrintLineweights = UseLineWeights;
                                    currentPlSet.ScaleLineweights = ScaleLineWeights;
                                    acPlSetVdr.SetCustomPrintScale(currentPlSet, customScale);
                                    acPlSetVdr.SetZoomToPaperOnUpdate(currentPlSet, true);    // Zoom to show the whole paper
                                    acLayout.UpgradeOpen();   // Update the layout
                                    acLayout.CopyFrom(currentPlSet);
                                }
                                layouts.Add(acLayout);
                            }
                        }
                        tr.Commit();
                    }
                    try  //try to delte old file
                    {
                        if (System.IO.File.Exists(Path.ChangeExtension(inputParametrs[1], "pdf")))
                            System.IO.File.Delete(Path.ChangeExtension(inputParametrs[1], "pdf"));
                    }
                    catch
                    {
                        doc.Editor.WriteMessage($"There is no possible delete old file - {Path.ChangeExtension(inputParametrs[1], "pdf")} .");
                        return;
                    }
                    doc.Editor.Regen();
                    db.SaveAs(inputParametrs[1], DwgVersion.Current);   //save modify print settings back to layout
                }
                layouts.Sort((l1, l2) =&amp;gt; l1.TabOrder.CompareTo(l2.TabOrder)); // Sort selected layouts to right order
                MultiSheetsPdf plotter = new MultiSheetsPdf(inputParametrs[0], layouts, inputParametrs[1]); //prepare plot
                plotter.Publish();  //plot selected laouys
            }
            catch { return; }
        }
    }

}&lt;/PRE&gt;</description>
    <pubDate>Fri, 23 Mar 2018 09:11:10 GMT</pubDate>
    <dc:creator>BestFriendCZ</dc:creator>
    <dc:date>2018-03-23T09:11:10Z</dc:date>
    <item>
      <title>Publish through API</title>
      <link>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/7877892#M26751</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I need again advice from knowledge programmers &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;. I have a drawing where i defind print settings layout… then i use the function for multiple publish. I was inspired function for multiple publish here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/net/plot-dwg-to-pdf-for-multiple-layouts-in-c/td-p/5849145" target="_blank"&gt;https://forums.autodesk.com/t5/net/plot-dwg-to-pdf-for-multiple-layouts-in-c/td-p/5849145&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All parameters which i sett are in layouts objects but function for public use another pc3 file (AutoCAD PDF (General Documentation).pc3) - no matter which pc3 file i sett. When i published manually then all is correct. How can i force publish layouts with my pc3 file through API.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 09:09:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/7877892#M26751</guid>
      <dc:creator>BestFriendCZ</dc:creator>
      <dc:date>2018-03-23T09:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: Publish through API</title>
      <link>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/7877896#M26752</link>
      <description>&lt;P&gt;this is my current code:&lt;/P&gt;&lt;PRE&gt;using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using System.Collections.Generic;
using System.IO;
namespace AutoCAD.Command
{
    public class Commands
    {

        [CommandMethod("NewDrawing", CommandFlags.Session)]
          public static void NewDrawing()
        {
            string strTemplatePath = "acad.dwt";
            DocumentCollection acDocMgr = Application.DocumentManager;
            Document acDoc = acDocMgr.Add(strTemplatePath);
        }




        [CommandMethod("PrintMultiSheetsPdf", CommandFlags.Session)]
        public void PrintMultiSheetsPdf()
        {
            try
            {
                Document doc = Application.DocumentManager.MdiActiveDocument;   //mother autocad document
                PromptResult promptResult = doc.Editor.GetString("\nEnter the parameter: ");  //hardcode user command from anothert side
                if (promptResult.Status != PromptStatus.OK)
                    return;
                if (promptResult.StringResult.Contains(";") != true)
                {
                    doc.Editor.WriteMessage($"Input parametr: {promptResult.StringResult} is invalid. Right format - (destination path;source file path).");
                    return;
                }
                string[] inputParametrs = promptResult.StringResult.Split(';');     //input parameters: destination path and source file path

                if (File.Exists(inputParametrs[1]) != true)
                {
                    doc.Editor.WriteMessage($"Source file: {inputParametrs[1]} does not exist.");
                    return;
                }

                if (!System.IO.Directory.Exists(inputParametrs[0]))
                    System.IO.Directory.CreateDirectory(inputParametrs[0]);

                bool isValidate = false;
                string PaperSize = "ISO full bleed A3 (420.00 x 297.00 MM)";
                string Plottername = "DWG To PDF.pc3";
                string PlotStyleName = "PDF files for instructions.ctb";
                CustomScale customScale = new CustomScale(1, 1);
                string PaperCode = string.Empty;
                int i = 0;
                bool UsePlotStyles = true;
                bool UseLineWeights = true;
                bool ScaleLineWeights = false;
                bool HidePaperspaceObjects = false;
                bool CenterPlot = true;
                foreach (string plotDevice in PlotSettingsValidator.Current.GetPlotDeviceList())    // check available printer, 
                {
                    if (Plottername.Trim().ToUpper() == plotDevice.Trim().ToUpper())
                    {
                        isValidate = true;
                        break;
                    }
                }
                if (isValidate == false)
                {
                    doc.Editor.WriteMessage($"Selected printer: {Plottername} is not installed on this computer. Contact your system administrator");
                    return;
                }
                using (PlotSettings acPlSet = new PlotSettings(true))    //try to find right paper value because it is no possible to set GetLocaleMediaName(this value is only show in UI)
                {
                    PlotSettingsValidator acPlSetVdr = PlotSettingsValidator.Current;
                    acPlSetVdr.SetPlotConfigurationName(acPlSet, Plottername, null);
                    foreach (string mediaName in acPlSetVdr.GetCanonicalMediaNameList(acPlSet))
                    {
                        if (PaperSize.Trim().ToUpper() == acPlSetVdr.GetLocaleMediaName(acPlSet, i).Trim().ToUpper())
                        {
                            PaperCode = mediaName;
                            break;
                        }
                        i++;
                    }
                }
                if (PaperCode == string.Empty)
                {
                    doc.Editor.WriteMessage($"Selected papersize: {PaperSize} is not available on selected printer. Contact your system administrator");
                    return;
                }
                List&amp;lt;Layout&amp;gt; layouts = new List&amp;lt;Layout&amp;gt;();
                using (Database db = new Database(false, true))
                {
                    if (Functions.IsFileAvailable(new FileInfo(inputParametrs[1])) != true)
                    {
                        doc.Editor.WriteMessage($" File: {inputParametrs[1]} is already locked by some other process.");
                        return;
                    }
                    db.ReadDwgFile(inputParametrs[1], System.IO.FileShare.ReadWrite, true, ""); // open select DWG file
                    using (Transaction tr = db.TransactionManager.StartTransaction())
                    {
                        DBDictionary layoutDict = (DBDictionary)db.LayoutDictionaryId.GetObject(OpenMode.ForRead);
                        foreach (DBDictionaryEntry entry in layoutDict)
                        {
                            if (entry.Key.Trim().ToUpper() != "MODEL") // set all layouts except model
                            {
                                Layout acLayout = (Layout)tr.GetObject(entry.Value, OpenMode.ForRead);
                                using (PlotSettings currentPlSet = new PlotSettings(acLayout.ModelType))
                                {
                                    currentPlSet.CopyFrom(acLayout);
                                    PlotSettingsValidator acPlSetVdr = PlotSettingsValidator.Current;
                                    acPlSetVdr.SetPlotConfigurationName(currentPlSet, Plottername, PaperCode);
                                    acPlSetVdr.SetPlotPaperUnits(currentPlSet, PlotPaperUnit.Millimeters);
                                    acPlSetVdr.SetPlotWindowArea(currentPlSet, new Extents2d(10, 8.5, 430, 288.5));
                                    acPlSetVdr.SetPlotType(currentPlSet, Autodesk.AutoCAD.DatabaseServices.PlotType.Window);
                                    acPlSetVdr.SetPlotCentered(currentPlSet, CenterPlot);
                                    acPlSetVdr.SetPlotRotation(currentPlSet, PlotRotation.Degrees000);
                                    acPlSetVdr.SetPlotOrigin(currentPlSet, new Point2d(0, 0));
                                    currentPlSet.ShowPlotStyles = UsePlotStyles;
                                    try { acPlSetVdr.SetCurrentStyleSheet(currentPlSet, PlotStyleName); }
                                    catch
                                    {
                                        doc.Editor.WriteMessage($"AutoCAD does not contains file - {PlotStyleName} .");
                                        return;
                                    }
                                  
                                    currentPlSet.PlotHidden = HidePaperspaceObjects;
                                    currentPlSet.PrintLineweights = UseLineWeights;
                                    currentPlSet.ScaleLineweights = ScaleLineWeights;
                                    acPlSetVdr.SetCustomPrintScale(currentPlSet, customScale);
                                    acPlSetVdr.SetZoomToPaperOnUpdate(currentPlSet, true);    // Zoom to show the whole paper
                                    acLayout.UpgradeOpen();   // Update the layout
                                    acLayout.CopyFrom(currentPlSet);
                                }
                                layouts.Add(acLayout);
                            }
                        }
                        tr.Commit();
                    }
                    try  //try to delte old file
                    {
                        if (System.IO.File.Exists(Path.ChangeExtension(inputParametrs[1], "pdf")))
                            System.IO.File.Delete(Path.ChangeExtension(inputParametrs[1], "pdf"));
                    }
                    catch
                    {
                        doc.Editor.WriteMessage($"There is no possible delete old file - {Path.ChangeExtension(inputParametrs[1], "pdf")} .");
                        return;
                    }
                    doc.Editor.Regen();
                    db.SaveAs(inputParametrs[1], DwgVersion.Current);   //save modify print settings back to layout
                }
                layouts.Sort((l1, l2) =&amp;gt; l1.TabOrder.CompareTo(l2.TabOrder)); // Sort selected layouts to right order
                MultiSheetsPdf plotter = new MultiSheetsPdf(inputParametrs[0], layouts, inputParametrs[1]); //prepare plot
                plotter.Publish();  //plot selected laouys
            }
            catch { return; }
        }
    }

}&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Mar 2018 09:11:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/7877896#M26752</guid>
      <dc:creator>BestFriendCZ</dc:creator>
      <dc:date>2018-03-23T09:11:10Z</dc:date>
    </item>
    <item>
      <title>Re: Publish through API</title>
      <link>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/7877921#M26754</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i tryed send here too my code but everytime was marked like spam and delete it&lt;/P&gt;&lt;P&gt;then i gave him to attachments&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 09:17:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/7877921#M26754</guid>
      <dc:creator>BestFriendCZ</dc:creator>
      <dc:date>2018-03-23T09:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: Publish through API</title>
      <link>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/7878873#M26755</link>
      <description>Try set PlotType==PlotType.Window before setting the PlotWindowArea</description>
      <pubDate>Fri, 23 Mar 2018 14:24:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/7878873#M26755</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2018-03-23T14:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: Publish through API</title>
      <link>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/7880048#M26756</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;you have right... these parametrs are on wrong order... but I do not think it will&amp;nbsp; some change printer driver... for sure I tested and result is same...it is used AutoCAD PDF (General Documentation).pc3 and in layouts is set DWG to PDF.pc3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i think problem will be in function for multiple layouts print but relly dont know why this&amp;nbsp; function does not respect layout settings -mainly printer driver&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;function print is here:&lt;/P&gt;&lt;PRE&gt;using System.Collections.Generic;
using System.IO;
using System.Text;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.PlottingServices;
using Autodesk.AutoCAD.Publishing;

namespace AutoCAD.Command
{
    public abstract class PlotToFileConfig
    {
        private string dsdFile, dwgFile, outputDir, outputFile, plotType;
        private int sheetNum;
        private IEnumerable&amp;lt;Layout&amp;gt; layouts;
        private const string LOG = "publish.log";
        public PlotToFileConfig(string outputDir, IEnumerable&amp;lt;Layout&amp;gt; layouts, string plotType, string sourceFilePath)
        {
            this.dwgFile = sourceFilePath;
            this.outputDir = outputDir;
            this.dsdFile = Path.ChangeExtension(this.dwgFile, "dsd");
            this.layouts = layouts;
            this.plotType = plotType;
            string ext = plotType == "0" || plotType == "1" ? "dwf" : "pdf";
            this.outputFile = Path.Combine(
                this.outputDir,
                Path.ChangeExtension(Path.GetFileName(this.dwgFile), ext));
        }
        public void Publish()
        {
            if (TryCreateDSD())
            {
                object rememberBACKGROUNDPLOT = Application.GetSystemVariable("BACKGROUNDPLOT");
                object rememberHIDEPRECISION = (short)Application.GetSystemVariable("HIDEPRECISION");
                object remembertraynotify = (short)Application.GetSystemVariable("traynotify");

                try
                {
                    Application.SetSystemVariable("BACKGROUNDPLOT", 0);
                    Application.SetSystemVariable("HIDEPRECISION", 1);
                    Application.SetSystemVariable("traynotify", 0);
                    Publisher publisher = Application.Publisher;
                    PlotProgressDialog plotDlg = new PlotProgressDialog(false, this.sheetNum, true);                
                    publisher.PublishDsd(this.dsdFile, plotDlg);
                    File.Delete(this.dsdFile);
                }
                catch (System.Exception exn)
                {
                    Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
                    ed.WriteMessage("\nError: {0}\n{1}", exn.Message, exn.StackTrace);
                    throw;
                }
                finally
                {
                    Application.SetSystemVariable("BACKGROUNDPLOT", rememberBACKGROUNDPLOT);
                    Application.SetSystemVariable("HIDEPRECISION", rememberHIDEPRECISION);
                    Application.SetSystemVariable("traynotify", remembertraynotify);
                }
            }
        }
        private bool TryCreateDSD()
        {
            using (DsdData dsd = new DsdData())
            using (DsdEntryCollection dsdEntries = CreateDsdEntryCollection(this.layouts))
            {
                if (dsdEntries == null || dsdEntries.Count &amp;lt;= 0) return false;
                this.sheetNum = dsdEntries.Count;
                dsd.SetDsdEntryCollection(dsdEntries);
                dsd.SetUnrecognizedData("PwdProtectPublishedDWF", "FALSE");
                dsd.SetUnrecognizedData("PromptForPwd", "FALSE");
                dsd.NoOfCopies = 1;
                dsd.DestinationName = this.outputFile;
                dsd.LogFilePath = Path.Combine(this.outputDir, LOG);
                PostProcessDSD(dsd);
                return true;
            }
        }
        private DsdEntryCollection CreateDsdEntryCollection(IEnumerable&amp;lt;Layout&amp;gt; layouts)
        {
            DsdEntryCollection entries = new DsdEntryCollection();
            foreach (Layout layout in layouts)
            {
                DsdEntry dsdEntry = new DsdEntry();
                dsdEntry.DwgName = this.dwgFile;
                dsdEntry.Layout = layout.LayoutName;
                dsdEntry.Title = Path.GetFileNameWithoutExtension(this.dwgFile) + "-" + layout.LayoutName;
                dsdEntry.Nps = layout.TabOrder.ToString();
                entries.Add(dsdEntry);
            }
            return entries;
        }
        private void PostProcessDSD(DsdData dsd)
        {
            string str, newStr;
            string tmpFile = Path.Combine(this.outputDir, "temp.dsd");
            dsd.WriteDsd(tmpFile);
            using (StreamReader reader = new StreamReader(tmpFile, Encoding.Default))
            using (StreamWriter writer = new StreamWriter(this.dsdFile, false, Encoding.Default))
            {
                while (!reader.EndOfStream)
                {
                    str = reader.ReadLine();
                    if (str.Contains("Has3DDWF"))
                    {
                        newStr = "Has3DDWF=0";
                    }
                    else if (str.Contains("OriginalSheetPath"))
                    {
                        newStr = "OriginalSheetPath=" + this.dwgFile;
                    }
                    else if (str.Contains("Type"))
                    {
                        newStr = "Type=" + this.plotType;
                    }
                    else if (str.Contains("OUT"))
                    {
                        newStr = "OUT=" + this.outputDir;
                    }
                    else if (str.Contains("IncludeLayer"))
                    {
                        newStr = "IncludeLayer=TRUE";
                    }
                    else if (str.Contains("PromptForDwfName"))
                    {
                        newStr = "PromptForDwfName=FALSE";
                    }
                    else if (str.Contains("LogFilePath"))
                    {
                        newStr = "LogFilePath=" + Path.Combine(this.outputDir, LOG);
                    }
                    else
                    {
                        newStr = str;
                    }
                    writer.WriteLine(newStr);
                }
            }
            File.Delete(tmpFile);
        }
    }
    public class SingleSheetPdf : PlotToFileConfig
    {
        public SingleSheetPdf(string outputDir, IEnumerable&amp;lt;Layout&amp;gt; layouts, string sourceFilePath)
          : base(outputDir, layouts, "5", sourceFilePath) { }
    }
    public class MultiSheetsPdf : PlotToFileConfig
    {
        public MultiSheetsPdf(string outputDir, IEnumerable&amp;lt;Layout&amp;gt; layouts, string sourceFilePath)
         : base(outputDir, layouts, "6", sourceFilePath) { }
    }
}&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Mar 2018 19:49:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/7880048#M26756</guid>
      <dc:creator>BestFriendCZ</dc:creator>
      <dc:date>2018-03-23T19:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: Publish through API</title>
      <link>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/7880092#M26757</link>
      <description>&lt;P&gt;little note&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;BR /&gt;this driver... i mean AutoCAD PDF (General Documentation).pc3... is not use in any layouts..it doesn't set like default&lt;BR /&gt;and too it wasn't use during the last print&lt;BR /&gt;it's strange how this driver was choice&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 20:09:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/7880092#M26757</guid>
      <dc:creator>BestFriendCZ</dc:creator>
      <dc:date>2018-03-23T20:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: Publish through API</title>
      <link>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/7882956#M26758</link>
      <description>&lt;P&gt;any idea?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Mar 2018 05:50:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/7882956#M26758</guid>
      <dc:creator>BestFriendCZ</dc:creator>
      <dc:date>2018-03-26T05:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: Publish through API</title>
      <link>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/7883029#M26759</link>
      <description>&lt;P&gt;i found solution by change DSD file.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Mar 2018 06:36:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/7883029#M26759</guid>
      <dc:creator>BestFriendCZ</dc:creator>
      <dc:date>2018-03-26T06:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: Publish through API</title>
      <link>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/7888661#M26760</link>
      <description>&lt;P&gt;&lt;BR /&gt;maybe it could help:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;print multiple layout with your CP3 file&lt;/P&gt;&lt;PRE&gt;using System.Collections.Generic;
using System.IO;
using System.Text;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.PlottingServices;
using Autodesk.AutoCAD.Publishing;

namespace AutoCAD.Command
{
    public abstract class PlotToFileConfig
    {
        private string dsdFile, dwgFile, outputDir, outputFile, driver;
        private int sheetNum;
        private IEnumerable&amp;lt;Layout&amp;gt; layouts;
        public PlotToFileConfig(string outputDir, IEnumerable&amp;lt;Layout&amp;gt; layouts, string sourceFilePath, string driver)
        {
            this.dwgFile = sourceFilePath;
            this.outputDir = outputDir;
            this.dsdFile = Path.ChangeExtension(this.dwgFile, "dsd");
            this.layouts = layouts;
            this.driver = driver;
            string ext = "pdf";
            this.outputFile = Path.Combine(this.outputDir, Path.ChangeExtension(Path.GetFileName(this.dwgFile), ext));
        }
        public void Publish()
        {
            if (TryCreateDSD())
            {
                object rememberBACKGROUNDPLOT = Application.GetSystemVariable("BACKGROUNDPLOT");
                object rememberHIDEPRECISION = (short)Application.GetSystemVariable("HIDEPRECISION");
                object remembertraynotify = (short)Application.GetSystemVariable("traynotify");
                try
                {
                    Application.SetSystemVariable("BACKGROUNDPLOT", 0);     // user windows off
                    Application.SetSystemVariable("HIDEPRECISION", 1);      // issue all line visible on
                    Application.SetSystemVariable("traynotify", 0);     //print notify off
                    Publisher publisher = Application.Publisher;
                    using (DsdData dsdDataFile = new DsdData())
                    {
                        dsdDataFile.ReadDsd(this.dsdFile);      //change printer driver for all layouts  other settings is from separate layouts
                        PlotConfig acPlCfg = PlotConfigManager.SetCurrentConfig(this.driver);
                        Application.Publisher.PublishExecute(dsdDataFile, acPlCfg);
                    }
                    File.Delete(this.dsdFile);
                }
                catch (System.Exception exn)
                {
                    Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
                    ed.WriteMessage($"\nError:{exn.Message}\n{exn.StackTrace}");
                    throw;
                }
                finally
                {
                    Application.SetSystemVariable("BACKGROUNDPLOT", rememberBACKGROUNDPLOT);
                    Application.SetSystemVariable("HIDEPRECISION", rememberHIDEPRECISION);
                    Application.SetSystemVariable("traynotify", remembertraynotify);
                }
            }
        }
        private bool TryCreateDSD()
        {
            using (DsdData dsd = new DsdData())
            using (DsdEntryCollection dsdEntries = CreateDsdEntryCollection(this.layouts))
            {
                if (dsdEntries == null || dsdEntries.Count &amp;lt;= 0) return false;
                this.sheetNum = dsdEntries.Count;
                dsd.SetDsdEntryCollection(dsdEntries);
                dsd.SetUnrecognizedData("PwdProtectPublishedDWF", "FALSE");
                dsd.SetUnrecognizedData("PromptForPwd", "FALSE");
                dsd.NoOfCopies = 1;
                dsd.DestinationName = this.outputFile;
                PostProcessDSD(dsd);
                return true;
            }
        }
        private DsdEntryCollection CreateDsdEntryCollection(IEnumerable&amp;lt;Layout&amp;gt; layouts)
        {
            try
            {
                DsdEntryCollection entries = new DsdEntryCollection();
                foreach (Layout layout in layouts)
                {
                    DsdEntry dsdEntry = new DsdEntry();
                    dsdEntry.DwgName = this.dwgFile;
                    dsdEntry.Layout = layout.LayoutName;
                    dsdEntry.Title = Path.GetFileNameWithoutExtension(this.dwgFile) + "-" + layout.LayoutName;
                    dsdEntry.Nps = layout.TabOrder.ToString();
                    entries.Add(dsdEntry);
                }
                return entries;
            }
            catch { return null; }
        }
        private void PostProcessDSD(DsdData dsd)
        {
            string str, newStr;
            string tmpFile = Path.Combine(this.outputDir, "temp.dsd");
            dsd.WriteDsd(tmpFile);
            using (StreamReader reader = new StreamReader(tmpFile, Encoding.Default))
            using (StreamWriter writer = new StreamWriter(this.dsdFile, false, Encoding.Default))
            {
                while (!reader.EndOfStream)
                {
                    str = reader.ReadLine();
                    if (str.Contains("Has3DDWF"))
                    {
                        newStr = "Has3DDWF=0";
                    }
                    else if (str.Contains("OriginalSheetPath"))
                    {
                        newStr = "OriginalSheetPath=" + this.dwgFile;
                    }
                    else if (str.Contains("Type"))
                    {
                        newStr = "Type=" + "6";  // print multiple layouts to one file
                    }
                    else if (str.Contains("OUT"))
                    {
                        newStr = "OUT=" + this.outputDir;
                    }
                    else if (str.Contains("IncludeLayer"))
                    {
                        newStr = "IncludeLayer=TRUE";
                    }
                    else if (str.Contains("PromptForDwfName"))
                    {
                        newStr = "PromptForDwfName=FALSE";
                    }
                    else
                    {
                        newStr = str;
                    }
                    writer.WriteLine(newStr);
                }
            }
            File.Delete(tmpFile);
        }
    }
    public class MultiSheetsPdf : PlotToFileConfig
    {
        public MultiSheetsPdf(string outputDir, IEnumerable&amp;lt;Layout&amp;gt; layouts, string sourceFilePath, string driverAllLayouts)
         : base(outputDir, layouts, sourceFilePath, driverAllLayouts) { }
    }
}&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Mar 2018 18:54:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/7888661#M26760</guid>
      <dc:creator>BestFriendCZ</dc:creator>
      <dc:date>2018-03-27T18:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: Publish through API</title>
      <link>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/9889864#M26761</link>
      <description>&lt;P&gt;Beware that the PostProcessDSD method tests are too generic.&amp;nbsp; The tests should be rewritten to include the "=" sign.&amp;nbsp; ie.&amp;nbsp; &amp;nbsp;"OUT="&amp;nbsp; instead of "OUT".&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;I had a client that named one of their files "SOUTH".&amp;nbsp; The related layout in the dsdentry did not plot because it tested true for that condition.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 18:36:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/publish-through-api/m-p/9889864#M26761</guid>
      <dc:creator>jmikel</dc:creator>
      <dc:date>2020-11-23T18:36:26Z</dc:date>
    </item>
  </channel>
</rss>

