<?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: Create Layout 2016 C# in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/create-layout-2016-c/m-p/7064723#M31679</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You shouldn't open the layout dictionary before creating the new layout with the LayoutManager.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you don't need to start a transaction, the layout manager takes care of that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        [CommandMethod("JT_CREATELAYOUT")]
        public void JT_CREATELAYOUT()
        {
            Editor ed = ACDAS.Application.DocumentManager.MdiActiveDocument.Editor;
            Database db = HostApplicationServices.WorkingDatabase;

            PromptStringOptions pso = new PromptStringOptions("\nEnter the layout name: ");
            PromptResult PR = ed.GetString(pso);
            string name = PR.StringResult;

            ObjectId layoutId = LayoutManager.Current.CreateLayout(name);
            LayoutManager.Current.CurrentLayout = name;
        }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Oops!.. Kerry was faster...&lt;/P&gt;</description>
    <pubDate>Fri, 05 May 2017 15:28:37 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2017-05-05T15:28:37Z</dc:date>
    <item>
      <title>Create Layout 2016 C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layout-2016-c/m-p/7064212#M31677</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;can someone tell me what I am missing?&lt;/P&gt;&lt;P&gt;I am trying to create a new layout with the following code.&lt;/P&gt;&lt;P&gt;please assume I have entered a valid layout name and that that layout name is not already in use.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the issue is, it seems to work, the layout is created in the current AutoCAD doc however it does not seem to be valid, the layout cannot be activated and disappears if I activate any other layout.&lt;/P&gt;&lt;P&gt;clearly, i am doing something wrong, any ideas&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[CommandMethod("JT_CREATELAYOUT")]
        public void JT_CREATELAYOUT()
        {
            Editor ed = ACDAS.Application.DocumentManager.MdiActiveDocument.Editor;
            Database db = HostApplicationServices.WorkingDatabase;

            try
            {
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    DBDictionary layouts = (DBDictionary)tr.GetObject(db.LayoutDictionaryId, OpenMode.ForWrite);

                    PromptStringOptions pso = new PromptStringOptions("\nEnter the layout name: ");

                    PromptResult PR = ed.GetString(pso);
                    string name = PR.StringResult;

                    ObjectId layoutId = LayoutManager.Current.CreateLayout(name);

                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage("\nError: " + ex.Message);
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 12:44:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layout-2016-c/m-p/7064212#M31677</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-05-05T12:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: Create Layout 2016 C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layout-2016-c/m-p/7064696#M31678</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;@Anonymous,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are creating in the current document so you may be better served using the LayoutManager Class rather than work through the Dictionary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Refer :&lt;/P&gt;
&lt;P&gt;&lt;A href="https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-NET/files/GUID-5FA86EF3-DEFD-4256-BB1C-56DAC32BD868-htm.html" target="_blank"&gt;https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-NET/files/GUID-5FA86EF3-DEFD-4256-BB1C-56DAC32BD868-htm.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 15:18:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layout-2016-c/m-p/7064696#M31678</guid>
      <dc:creator>kerry_w_brown</dc:creator>
      <dc:date>2017-05-05T15:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: Create Layout 2016 C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layout-2016-c/m-p/7064723#M31679</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You shouldn't open the layout dictionary before creating the new layout with the LayoutManager.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you don't need to start a transaction, the layout manager takes care of that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        [CommandMethod("JT_CREATELAYOUT")]
        public void JT_CREATELAYOUT()
        {
            Editor ed = ACDAS.Application.DocumentManager.MdiActiveDocument.Editor;
            Database db = HostApplicationServices.WorkingDatabase;

            PromptStringOptions pso = new PromptStringOptions("\nEnter the layout name: ");
            PromptResult PR = ed.GetString(pso);
            string name = PR.StringResult;

            ObjectId layoutId = LayoutManager.Current.CreateLayout(name);
            LayoutManager.Current.CurrentLayout = name;
        }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Oops!.. Kerry was faster...&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 15:28:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layout-2016-c/m-p/7064723#M31679</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-05-05T15:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: Create Layout 2016 C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layout-2016-c/m-p/7068894#M31680</link>
      <description>&lt;P&gt;Thank you very much for your help&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 12:57:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layout-2016-c/m-p/7068894#M31680</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-05-08T12:57:29Z</dc:date>
    </item>
  </channel>
</rss>

