<?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: How to execute command from command that has session flag in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-execute-command-from-command-that-has-session-flag/m-p/6938179#M32368</link>
    <description>To add to &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;'s advice, you should also add the CommandFlags.NoHistory flag to your document command, to prevent it from repeating if the user presses Enter afterwards.&lt;BR /&gt;&lt;BR /&gt;If you need to do other things after all calls to Command() have completed, you should do them from the document command, as the session command will not wait for the call to SendStringToExecute() to return.</description>
    <pubDate>Fri, 10 Mar 2017 19:25:57 GMT</pubDate>
    <dc:creator>ActivistInvestor</dc:creator>
    <dc:date>2017-03-10T19:25:57Z</dc:date>
    <item>
      <title>How to execute command from command that has session flag</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-execute-command-from-command-that-has-session-flag/m-p/6937308#M32364</link>
      <description>&lt;P&gt;I have a command that is decorated with session flag - because it needs to have it. From within that command, I want to execute an AutoCAD command - specifically &lt;FONT face="courier new,courier"&gt;LAYOUT&lt;/FONT&gt; command. I have tried following ways:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;ed.Command("-LAYOUT", "S", "REPORT" });&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;ed.Command(new object[] { "-LAYOUT", "S", "REPORT" });&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have also tried the &lt;FONT face="courier new,courier"&gt;CommandAsync&lt;/FONT&gt; as well. I have also tried calling them from inside of a transaction as well. I have also tried &lt;FONT face="courier new,courier"&gt;Document.SendStringToExecute(&lt;/FONT&gt;).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But they all result in eInvalidInput exception.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have several such commands to execute in synchronized order. How can I call AutoCAD commands? I am using AutoCAD 2017, C#, .NET 4.5.2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have googled and found many thread but none has helped me specifically with this problem. Any help is much appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 14:23:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-execute-command-from-command-that-has-session-flag/m-p/6937308#M32364</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-10T14:23:37Z</dc:date>
    </item>
    <item>
      <title>Re : How to execute command from command that has session flag</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-execute-command-from-command-that-has-session-flag/m-p/6937457#M32365</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Editor.Command() only works in document context, not in application context.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, with the CommandFlags.Session in the parent method, you cannot use Editor.Command() (idem for CommandAsync()).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;instead of:&lt;/P&gt;
&lt;PRE&gt;ed.Command("-LAYOUT", "S", "REPORT" });&lt;/PRE&gt;
&lt;P&gt;you can simply do:&lt;/P&gt;
&lt;PRE&gt;Application.SetSystemVariable("CVPORT", "REPORT");&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Mar 2017 15:16:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-execute-command-from-command-that-has-session-flag/m-p/6937457#M32365</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-03-10T15:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute command from command that has session flag</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-execute-command-from-command-that-has-session-flag/m-p/6937680#M32366</link>
      <description>&lt;P&gt;Thanks Giles. But I have&amp;nbsp; many other commands to execute and I don't suppose they all can be somehow be achieved by your suggestion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can I implement another&amp;nbsp; command that doesn't use sessions flag, and call that command from my command that uses sessions flag?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 16:27:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-execute-command-from-command-that-has-session-flag/m-p/6937680#M32366</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-10T16:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute command from command that has session flag</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-execute-command-from-command-that-has-session-flag/m-p/6937784#M32367</link>
      <description>&lt;P&gt;Yes, you can call a custom command from the command with session flag using SendStringToExecute() which autoamically switch AutoCAD into docuement context..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a trivial example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        [CommandMethod("SESSIONCMD", CommandFlags.Session)]
        public void TestCmd()
        {
            foreach (Document doc in Application.DocumentManager)
            {
                doc.SendStringToExecute("DOCCMD ", false, false, false);
            }
        }

        [CommandMethod("DOCCMD")]
        public void DocumentCmd()
        {
            var ed = AcAp.DocumentManager.MdiActiveDocument.Editor;
            ed.Command("_circle", new Point3d(10.0, 20.0, 0.0), 10.0);
            ed.Command("_zoom", "_extents");
            ed.Command("_zoom", "0.8xp");
        }&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Mar 2017 17:01:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-execute-command-from-command-that-has-session-flag/m-p/6937784#M32367</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-03-10T17:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute command from command that has session flag</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-execute-command-from-command-that-has-session-flag/m-p/6938179#M32368</link>
      <description>To add to &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;'s advice, you should also add the CommandFlags.NoHistory flag to your document command, to prevent it from repeating if the user presses Enter afterwards.&lt;BR /&gt;&lt;BR /&gt;If you need to do other things after all calls to Command() have completed, you should do them from the document command, as the session command will not wait for the call to SendStringToExecute() to return.</description>
      <pubDate>Fri, 10 Mar 2017 19:25:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-execute-command-from-command-that-has-session-flag/m-p/6938179#M32368</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2017-03-10T19:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute command from command that has session flag</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-execute-command-from-command-that-has-session-flag/m-p/12211821#M32369</link>
      <description>&lt;P&gt;So, how the SESSIONCMD command can be invoked from AutoCAD? When no document is opened, there is no command line present where this command can be entered.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2023 11:22:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-execute-command-from-command-that-has-session-flag/m-p/12211821#M32369</guid>
      <dc:creator>hennadii_k</dc:creator>
      <dc:date>2023-09-01T11:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to execute command from command that has session flag</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-execute-command-from-command-that-has-session-flag/m-p/12220324#M32370</link>
      <description>&lt;P&gt;Commands are issued via the command line, which is not available when there are no open documents.&lt;BR /&gt;&lt;BR /&gt;If you need to execute some process or operation when no documents are open, you will need to provide your own modeless UI, such as a ribbon element; a pallete, or modeless dialog/window.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 22:05:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-execute-command-from-command-that-has-session-flag/m-p/12220324#M32370</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2023-09-05T22:05:50Z</dc:date>
    </item>
  </channel>
</rss>

