<?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 : problem about the 'SendStringToExecute' in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/problem-about-the-sendstringtoexecute/m-p/4891892#M44984</link>
    <description>thank you Gilles, i'll try this.</description>
    <pubDate>Tue, 18 Mar 2014 08:38:55 GMT</pubDate>
    <dc:creator>swaywood</dc:creator>
    <dc:date>2014-03-18T08:38:55Z</dc:date>
    <item>
      <title>problem about the 'SendStringToExecute'</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-about-the-sendstringtoexecute/m-p/4891686#M44980</link>
      <description>&lt;P&gt;&amp;nbsp;I just want to draw a pline on the screen and get the pline objectid and continue the next step code, but it seems the sending command 'pline' always starts in the end of all the code. could you help me to solve this problem?&lt;/P&gt;&lt;P&gt;the following code was copy from kean's blog, I try to add one line of code after the 'PLINE' command, but alert dialog shows before let user select pline point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
namespace revMarkCreate
{
    public class MyPlineCmds1 : IExtensionApplication
    {
        // Flag used to check whether it's our command
        // that launched PLINE
        private static bool myCommandStarted = false;
        public void Initialize()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            doc.CommandEnded += new CommandEventHandler(plineCommandEnded);
        }
        public void Terminate()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            doc.CommandEnded -= new CommandEventHandler(plineCommandEnded);
        }
        [CommandMethod("MYPOLY1")]
        public void MyPoly()
        {
            // Set the flag and launch PLINE
            myCommandStarted = true;
            Document doc = Application.DocumentManager.MdiActiveDocument;
            doc.SendStringToExecute("_PLINE ", false, false, false);
            //I want to let the 'PLINE' command run before the alertdialog shows
            Application.ShowAlertDialog("test");
        }
        private void plineCommandEnded(object sender, CommandEventArgs e)
        {
            if (myCommandStarted &amp;amp;&amp;amp; e.GlobalCommandName.ToUpper() == "PLINE")
            {
                // We're just performing a simple check, so OK..
                // We could launch a follow-on command, if needed
                Document doc = Application.DocumentManager.MdiActiveDocument;
                PromptSelectionResult lastRes = doc.Editor.SelectLast();
                if (lastRes.Value != null &amp;amp;&amp;amp; lastRes.Value.Count == 1)
                {
                    doc.Editor.WriteMessage("\nThe entity is： " + lastRes.Value[0].ObjectId);
                }
                myCommandStarted = false;
            }
        }
    }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Mar 2014 03:01:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-about-the-sendstringtoexecute/m-p/4891686#M44980</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2014-03-18T03:01:59Z</dc:date>
    </item>
    <item>
      <title>Re : problem about the 'SendStringToExecute'</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-about-the-sendstringtoexecute/m-p/4891784#M44981</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a well known issue:&lt;/P&gt;
&lt;P&gt;- SendStringToExecute does not run synchronously.&lt;/P&gt;
&lt;P&gt;- SendCommand (the COM method) may not be completely synchronous.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To synchronously run a command, you have to P/Invoke acedCmd or acedCommand, or better, use &lt;A href="https://forums.autodesk.com/t5/NET/Send-Command-Executes-after-exiting-command-method/td-p/3882929" target="_blank"&gt;Tony Tanzillo's wrapper&lt;/A&gt; for the undocumented runCommand() method.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Mar 2014 06:46:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-about-the-sendstringtoexecute/m-p/4891784#M44981</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2014-03-18T06:46:37Z</dc:date>
    </item>
    <item>
      <title>Re : problem about the 'SendStringToExecute'</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-about-the-sendstringtoexecute/m-p/4891854#M44982</link>
      <description>Hi,Gilles&lt;BR /&gt;I got the following code, but I am not familial with VB.NET,could you give me a sample of c# to use P/Invoke acedCmd or acedCommand?&lt;BR /&gt;best regards&lt;BR /&gt;swaywood&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.autodesk.com/t5/NET/Select-Object-Command-Prompt/m-p/3484914/highlight/true#M29221" target="_blank"&gt;http://forums.autodesk.com/t5/NET/Select-Object-Command-Prompt/m-p/3484914/highlight/true#M29221&lt;/A&gt;</description>
      <pubDate>Tue, 18 Mar 2014 08:13:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-about-the-sendstringtoexecute/m-p/4891854#M44982</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2014-03-18T08:13:15Z</dc:date>
    </item>
    <item>
      <title>Re : problem about the 'SendStringToExecute'</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-about-the-sendstringtoexecute/m-p/4891882#M44983</link>
      <description>&lt;P&gt;You'd rather use the runCommand wrapper shown in the link I provided.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, if you indeed want to p/invoke acedCmd:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For A2013 and later&lt;/P&gt;
&lt;PRE&gt;        [System.Security.SuppressUnmanagedCodeSecurity]
        [DllImport("accore.dll", EntryPoint = "acedCmd",
            CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl)]
        extern static private int acedCmd(IntPtr resbuf);

        public static void Command(ResultBuffer args)
        {
            acedCmd(args.UnmanagedObject);
        }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;For prior versions, replace accore.dll with acad.exe.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Mar 2014 08:34:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-about-the-sendstringtoexecute/m-p/4891882#M44983</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2014-03-18T08:34:57Z</dc:date>
    </item>
    <item>
      <title>Re : problem about the 'SendStringToExecute'</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-about-the-sendstringtoexecute/m-p/4891892#M44984</link>
      <description>thank you Gilles, i'll try this.</description>
      <pubDate>Tue, 18 Mar 2014 08:38:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-about-the-sendstringtoexecute/m-p/4891892#M44984</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2014-03-18T08:38:55Z</dc:date>
    </item>
    <item>
      <title>Re : problem about the 'SendStringToExecute'</title>
      <link>https://forums.autodesk.com/t5/net-forum/problem-about-the-sendstringtoexecute/m-p/4893086#M44985</link>
      <description>&lt;P&gt;In the meantime, invest the time in adding drawing entities directly (as opposed to sending commands).&amp;nbsp; Its well worth the effort.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Mar 2014 16:04:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/problem-about-the-sendstringtoexecute/m-p/4893086#M44985</guid>
      <dc:creator>dgorsman</dc:creator>
      <dc:date>2014-03-18T16:04:03Z</dc:date>
    </item>
  </channel>
</rss>

