<?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 Command with Call options in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/create-command-with-call-options/m-p/6487789#M35021</link>
    <description>&lt;P&gt;You can simulate a .net command call with arguments if you use an autocad macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;macro&lt;/P&gt;
&lt;P&gt;^C^Cdotnetcommandmethod;PARAM1,PARAM2;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;.net&lt;/P&gt;
&lt;P&gt;[CommandMethod("dotnetcommandmethod")&lt;/P&gt;
&lt;P&gt;public void dotnetcommandmethod()&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;acapp.Document doc = acapp.Core.Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt; Editor ed = doc.Editor;&lt;BR /&gt; PromptStringOptions pso = new PromptStringOptions("");&lt;BR /&gt; PromptResult pr = ed.GetString(pso);&lt;BR /&gt;&amp;gt;&amp;gt; pr.StringResult will contain "PARAM1,PARAM2"&lt;/P&gt;
&lt;P&gt;&amp;lt;edit&amp;gt;&lt;/P&gt;
&lt;P&gt;string[] myparams = pr.StringResult.Split(',');&lt;/P&gt;
&lt;P&gt;&amp;lt;/edit&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you could use something like that? &amp;nbsp;I have macros assigned to autocad ribbon buttons that implement this method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 09 Aug 2016 14:48:15 GMT</pubDate>
    <dc:creator>fieldguy</dc:creator>
    <dc:date>2016-08-09T14:48:15Z</dc:date>
    <item>
      <title>Create Command with Call options</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-command-with-call-options/m-p/6486507#M35014</link>
      <description>&lt;P&gt;hi !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want to create functions in vb.net to make some aktion and there should be different ways in use - control by optionalparameters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i know the way to call a function direct:&lt;/P&gt;&lt;PRE&gt; &amp;lt;Autodesk.AutoCAD.Runtime.CommandMethod("TEST", CType(2097155, Autodesk.AutoCAD.Runtime.CommandFlags))&amp;gt; _
    Public Shared Sub TEST()&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my idea is to put following into commandline - like Lisp-call&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;test Option1 Option2&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;(test Option1 Option2)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could someone help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards Jan&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 06:25:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-command-with-call-options/m-p/6486507#M35014</guid>
      <dc:creator>jan_tappenbeck</dc:creator>
      <dc:date>2016-08-09T06:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: Create Command with Call options</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-command-with-call-options/m-p/6486552#M35015</link>
      <description>&lt;P&gt;I think the key is to understand that once you press 'TEST ' (with the trailing space) the command is launched and you are already inside your function.&lt;/P&gt;&lt;P&gt;From there you must mimic the options management.&lt;/P&gt;&lt;P&gt;If your command will have a graphics interaction, like getting a point, the best solution is to set keyword options in the same prompt, because it will work exactly as AutoCAD native commands.&lt;/P&gt;&lt;P&gt;For Example, here I want to select a polyline, but also allow for keyword actions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;            // set defaults
            PromptDoubleOptions optVal = new PromptDoubleOptions("");
            PromptDoubleResult res_double;
            PromptEntityResult res;

            while (true)
            {
                String szMessage = String.Format("\nSelect polyline or [Radius={0}/Width={1}/Xhatch={2}/Keep={3}]:",
                                                 dRad, dThick, (bDrawHatch ? "S" : "N"), (bKeepPline ? "S" : "N"));

                // get Polyline or keywords
                PromptEntityOptions opt = new PromptEntityOptions(szMessage, "Radius Width Xhatch Keep");
                opt.SetRejectMessage("** not a polyline **");
                opt.AddAllowedClass(typeof(Polyline), true);
                res = ed.GetEntity(opt);

                if (res.Status == PromptStatus.OK)
                {
                    // execute the command with current parameters
                    if (DoLamiere(res.ObjectId, dRad, dThick, bDrawHatch, false, bKeepPline) == true)
                    {
                        csProfili.SaveCurrentParameters(csProfili.SECT_LAMIERE, dRad, dThick, 0.0, bDrawHatch, bKeepPline, 0);
                    }
                }
                else if (res.Status == PromptStatus.Keyword)
                {
                    switch (res.StringResult.ToUpperInvariant())
                    {
                        case "RADIUS":
                            // ask for new fillet radius
                            optVal.Message = "\nInternal bending radius";
                            optVal.AllowZero = true;
                            optVal.DefaultValue = dRad;
                            optVal.UseDefaultValue = true;
                            res_double = ed.GetDouble(optVal);
                            if (res_double.Status == PromptStatus.OK) dRad = res_double.Value;

                            break;

                        case "WIDTH":
                            // ask for new width
                            optVal.Message = "\nWidth";
                            optVal.AllowZero = false;
                            optVal.DefaultValue = dThick;
                            optVal.UseDefaultValue = true;
                            res_double = ed.GetDouble(optVal);
                            if (res_double.Status == PromptStatus.OK) dThick = res_double.Value;

                            break;

                        case "XHATCH":
                            // Flag: draw xh or not
                            bDrawHatch = !bDrawHatch;
                            break;

                        case "KEEP":
                            // Flag: keep original polyline or discard
                            bKeepPline = !bKeepPline;
                            break;
                    }
                }
                else
                    break;  // command aborted, exit main loop
            }&lt;/PRE&gt;&lt;P&gt;If you use JIG function, keywords are also available, see&amp;nbsp;JigPromptPointOptions.SetMessageAndKeywords().&lt;/P&gt;&lt;P&gt;If you don't have an interactive session, I'm afraid you should mimic a text input and process it. The only not-standard behavior is that for empty parameters you need an additional space or enter to actually run the command. Maybe you may display default values to let the user know he/she needs another Enter to actually start the command.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 06:51:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-command-with-call-options/m-p/6486552#M35015</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-08-09T06:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: Create Command with Call options</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-command-with-call-options/m-p/6486562#M35016</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for answer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your idea is to allow options in the process of a function!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i search a way to call a funktion with options - here a example by lisp:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(defun myfunktion ( option1 option2 / )

.....&lt;/PRE&gt;&lt;P&gt;this will be call in commandline by&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;(myfunktion 15 52)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;did you understand?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards Jan&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 06:55:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-command-with-call-options/m-p/6486562#M35016</guid>
      <dc:creator>jan_tappenbeck</dc:creator>
      <dc:date>2016-08-09T06:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: Create Command with Call options</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-command-with-call-options/m-p/6486575#M35017</link>
      <description>&lt;P&gt;So, you have fixed number of options and fixed position? Something like '_MYCMD 100 50 ' ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With NET I would just add a sequence of inputs as soon as my command starts, something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;            // ask for mandatory parameters
            PromptDoubleOptions optVal = new PromptDoubleOptions();

            // ask for length
            optVal.Message = "\nLength"
            optVal.AllowZero = false;
            optVal.DefaultValue = dWidth;
            optVal.UseDefaultValue = true;
            PromptDoubleResult res_wdt = ed.GetDouble(optVal);
            if (res_wdt.Status != PromptStatus.OK) return false;

            // ask for Height
            optVal.Message = "\nHeight";
            optVal.AllowZero = false;
            optVal.DefaultValue = dHeight;
            optVal.UseDefaultValue = true;
            PromptDoubleResult res_hgt = ed.GetDouble(optVal);
            if (res_wdt.Status != PromptStatus.OK) return false;

            // here res_wdt and res_hgt are valid and contain a value&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 07:03:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-command-with-call-options/m-p/6486575#M35017</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-08-09T07:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: Create Command with Call options</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-command-with-call-options/m-p/6486623#M35018</link>
      <description>&lt;P&gt;Hi !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;yes, you ask the two parameter by userinput&amp;nbsp; - but i want to transfer the parameters by call function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;reagards Jan&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 07:31:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-command-with-call-options/m-p/6486623#M35018</guid>
      <dc:creator>jan_tappenbeck</dc:creator>
      <dc:date>2016-08-09T07:31:28Z</dc:date>
    </item>
    <item>
      <title>Re : Create Command with Call options</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-command-with-call-options/m-p/6486634#M35019</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A CommandMethod attributed method (i.e. a custom AutoCAD command) cannot have parameters.&lt;/P&gt;
&lt;P&gt;But you can use a LispFunction attributed method (i.e. a custom AutoLISP function) which requires a ResultBuffer as parameter, the ResultBuffer may contain the LISP function parameters.&lt;/P&gt;
&lt;P&gt;You can google for '&lt;A href="https://www.google.fr/search?q=AutoCAD+.NET+LispFunction&amp;amp;ie=utf-8&amp;amp;oe=utf-8&amp;amp;client=firefox-b&amp;amp;gfe_rd=cr&amp;amp;ei=iIepV-nSEKTS8Aey3JH4CA" target="_blank"&gt;AutoCAD .NET LispFunction&lt;/A&gt;'&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 07:37:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-command-with-call-options/m-p/6486634#M35019</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2016-08-09T07:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: Create Command with Call options</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-command-with-call-options/m-p/6486657#M35020</link>
      <description>&lt;P&gt;Sorry Jan,&lt;/P&gt;&lt;P&gt;maybe I did not explained myself in my first message: &lt;STRONG&gt;you cannot let AutoCAD to handle all the input and THEN call your function with&amp;nbsp;all parameters. As soon as you type 'TEST ' (and the following space), the control is handled to your function, that MUST handle the following user interaction.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With .NET this is a normal scenario, but even if you handle the input by yourself, the whole command will works as a standard command, by manual typing, by script, by UI buttons, whatever!&lt;/P&gt;&lt;P&gt;So, actually is a better behavior, since you have complete control over it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 07:45:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-command-with-call-options/m-p/6486657#M35020</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-08-09T07:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: Create Command with Call options</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-command-with-call-options/m-p/6487789#M35021</link>
      <description>&lt;P&gt;You can simulate a .net command call with arguments if you use an autocad macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;macro&lt;/P&gt;
&lt;P&gt;^C^Cdotnetcommandmethod;PARAM1,PARAM2;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;.net&lt;/P&gt;
&lt;P&gt;[CommandMethod("dotnetcommandmethod")&lt;/P&gt;
&lt;P&gt;public void dotnetcommandmethod()&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;acapp.Document doc = acapp.Core.Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt; Editor ed = doc.Editor;&lt;BR /&gt; PromptStringOptions pso = new PromptStringOptions("");&lt;BR /&gt; PromptResult pr = ed.GetString(pso);&lt;BR /&gt;&amp;gt;&amp;gt; pr.StringResult will contain "PARAM1,PARAM2"&lt;/P&gt;
&lt;P&gt;&amp;lt;edit&amp;gt;&lt;/P&gt;
&lt;P&gt;string[] myparams = pr.StringResult.Split(',');&lt;/P&gt;
&lt;P&gt;&amp;lt;/edit&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you could use something like that? &amp;nbsp;I have macros assigned to autocad ribbon buttons that implement this method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2016 14:48:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-command-with-call-options/m-p/6487789#M35021</guid>
      <dc:creator>fieldguy</dc:creator>
      <dc:date>2016-08-09T14:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: Create Command with Call options</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-command-with-call-options/m-p/6490211#M35022</link>
      <description>&lt;P&gt;hi !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for this other options - i will try.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards Jan&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2016 05:02:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-command-with-call-options/m-p/6490211#M35022</guid>
      <dc:creator>jan_tappenbeck</dc:creator>
      <dc:date>2016-08-10T05:02:01Z</dc:date>
    </item>
  </channel>
</rss>

