<?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: Make a command with parameter in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/11154854#M30867</link>
    <description>&lt;P&gt;Does your script file properly ends? IOW is there a validation (space or carriage return) after the (setvar "osmode" old-osmode) LISP expression.&lt;/P&gt;</description>
    <pubDate>Sun, 08 May 2022 08:23:39 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2022-05-08T08:23:39Z</dc:date>
    <item>
      <title>Make a command with parameter</title>
      <link>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/7172578#M30859</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;I want transmit a outside parameter to CAD, my thinking is like following :&lt;/P&gt;&lt;P&gt;//outside code&lt;/P&gt;&lt;P&gt;class xxxxx&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;//outside code&lt;/P&gt;&lt;P&gt;string parameter="ParameterToTransmit";&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;document acdoc.SendCommand("MyCommand ",&lt;STRONG&gt;ParameterToTransmit&lt;/STRONG&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//CAD command&lt;/P&gt;&lt;P&gt;&amp;nbsp;[CommandMethod("MyCommand ")]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void MyCommand (&lt;STRONG&gt;ParameterToTransmit&lt;/STRONG&gt;)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;But i don't know how to make a command with parameter&amp;nbsp;.&lt;/P&gt;&lt;P&gt;Is&amp;nbsp; it possible to create a command with parameter ?&lt;/P&gt;&lt;P&gt;Or is&amp;nbsp; it have other solution?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2017 00:06:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/7172578#M30859</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-06-23T00:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Make a command with parameter</title>
      <link>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/7173810#M30860</link>
      <description>&lt;P&gt;Maybe you can use a macro?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/net/create-command-with-call-options/m-p/6487789#M49739" target="_blank"&gt;https://forums.autodesk.com/t5/net/create-command-with-call-options/m-p/6487789#M49739&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2017 13:48:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/7173810#M30860</guid>
      <dc:creator>fieldguy</dc:creator>
      <dc:date>2017-06-23T13:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Make a command with parameter</title>
      <link>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/7174447#M30861</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You cannot define a command with a parameter (the method attributed with the CommandMethod attribute must return void).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create a command with an user prompt and call the command passing ot the input.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        [CommandMethod("MyCommand")]
        public void MyCommand()
        {
            var doc = Application.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;

            var promptResult = ed.GetString("\nEnter the parameter: ");
            if (promptResult.Status != PromptStatus.OK)
                return;

            // Do what you want with the parameter
        }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, you can hard code the call to the command with your parameter:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using AcAdDocument.SendCommand (COM API)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;acdoc.SendCommand("MyCommand " + parameter + "\n");&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using Document.SendstringToExecute (.NET API)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;doc.SendStringToExecute("MyCommand " + parameter + "\n", false, false, false);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using Editor.Command()&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ed.Command("MyCommand", parameter);&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Jun 2017 17:14:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/7174447#M30861</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-06-23T17:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: Make a command with parameter</title>
      <link>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/7179090#M30862</link>
      <description>&lt;P&gt;Thanks Sir!&lt;/P&gt;&lt;P&gt;Before i have try this way, it failed, but now it sucess, thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 14:37:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/7179090#M30862</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-06-26T14:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: Make a command with parameter</title>
      <link>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/7179108#M30863</link>
      <description>&lt;P&gt;Dear Sir,&lt;/P&gt;&lt;P&gt;May be you are right, but it too trouble for me(i'm not a &lt;SPAN&gt;Professional&lt;/SPAN&gt;).&lt;/P&gt;&lt;P&gt;So I accepted solution from Mr _gile&amp;nbsp;. Still very thank you for you help!&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 14:46:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/7179108#M30863</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-06-26T14:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: Make a command with parameter</title>
      <link>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/11154727#M30864</link>
      <description>&lt;P&gt;hi, gile&lt;/P&gt;&lt;P&gt;I'm trying to load&amp;nbsp; some scripts into cad to draw some lines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Autocad 2018
.NET framework 4.6.1
C#&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried to use (with FILEDIA set to 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;[CommandMethod("BATCHSCR")]
public void BATCHSCR()
{
    Document acDoc = Application.DocumentManager.MdiActiveDocument;
    Editor ed = acDoc.Editor;
    ed.Command(".script","D:\\123.scr\n ");
    ed.Command(".script","D:\\234.scr\n ");
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;only commands in the second script has been executed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;[CommandMethod("BATCHSCR")]
public void BATCHSCR()
{
    string path1 = @"D:\123.scr";
    string path2 = @"D:\234.scr";
    acDoc.SendStringToExecute(".script " + path1 + "\n", false, false, false);
    acDoc.SendStringToExecute(".script " + path2 + "\n", false, false, false);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;only commands in the first script has been executed.&lt;/P&gt;&lt;P&gt;Is&amp;nbsp; it possible to load scripts in one customize command ?&lt;/P&gt;&lt;P&gt;Or is&amp;nbsp; it have other solution?&amp;nbsp;&lt;/P&gt;&lt;P&gt;123.scr :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(setq old-osmode(getvar "osmode"))
_osmode 0
_units
2
2
3
4
0
_y
_DIMAUNIT
2
_DIMUNIT
2


_-layer
_n
220427__20220427_2_Report
_c
_red
220427__20220427_2_Report
_s
220427__20220427_2_Report

_POINT
1387480.930000,2623185.220000,0.000000
_POINT
1387602.000000,2623185.220000,0.000000
_-layer
_n
220427__20220427_2_Report
_c
_red
220427__20220427_2_Report
_s
220427__20220427_2_Report

_3DPOLY
1387480.930000,2623185.220000,0.000000
1387602.000000,2623185.220000,0.000000

(setvar "osmode" old-osmode)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;234.scr&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(setq old-osmode(getvar "osmode"))
_osmode 0
_units
2
2
3
4
0
_y
_DIMAUNIT
2
_DIMUNIT
2


_-layer
_n
220427__20220427_1_Report
_c
_red
220427__20220427_1_Report
_s
220427__20220427_1_Report

_POINT
1387525.930000,2623185.220000,0.000000
_POINT
1387550.000000,2623103.550000,0.000000
_-layer
_n
220427__20220427_1_Report
_c
_red
220427__20220427_1_Report
_s
220427__20220427_1_Report

_3DPOLY
1387525.930000,2623185.220000,0.000000
1387550.000000,2623103.550000,0.000000

(setvar "osmode" old-osmode)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 May 2022 04:41:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/11154727#M30864</guid>
      <dc:creator>foxever</dc:creator>
      <dc:date>2022-05-08T04:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: Make a command with parameter</title>
      <link>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/11154784#M30865</link>
      <description>&lt;P&gt;Using .NET to launch an AutoCAD script is like chasing mosquitoes with a bazooka.&lt;BR /&gt;That said, with the Editor.Command() method, you don't have to add a validation after the script file name.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;ed.Command(".script", "D:\123.scr");&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;You can test arguments of Editor.Command() method more simply by using LISP command function directly from AutoCAD:&lt;/P&gt;
&lt;LI-CODE lang="lisp"&gt;(command ".script" "D:\123.scr")&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 May 2022 06:42:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/11154784#M30865</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2022-05-08T06:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: Make a command with parameter</title>
      <link>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/11154835#M30866</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Using .NET to launch an AutoCAD script is like chasing mosquitoes with a bazooka.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It's a funny&amp;nbsp; anology.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The scenerio is Program A outputs one script file which contains commands of drawing points and lines for each project.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Script files are placed in different subfolders named with project name.&lt;/P&gt;&lt;P&gt;And I wanna write a plugin to traverse the main folder&amp;nbsp; to load all the script files into one dwg file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;There is no need of '\n' in parameter when using ed.Command().&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;ed.Command(".script", "D:\\123.scr");&lt;/LI-CODE&gt;&lt;P&gt;It works well without "\n".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is another problem, when using the following codes, the second line will not be executed.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;ed.Command(".script", "D:\\123.scr");
ed.Command(".zoom", "e");&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;And there is even no history command (ZOOM E) in autocad command window.&lt;/P&gt;&lt;P&gt;The last command in command window is the last line of script file.&lt;/P&gt;</description>
      <pubDate>Sun, 08 May 2022 08:12:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/11154835#M30866</guid>
      <dc:creator>foxever</dc:creator>
      <dc:date>2022-05-08T08:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: Make a command with parameter</title>
      <link>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/11154854#M30867</link>
      <description>&lt;P&gt;Does your script file properly ends? IOW is there a validation (space or carriage return) after the (setvar "osmode" old-osmode) LISP expression.&lt;/P&gt;</description>
      <pubDate>Sun, 08 May 2022 08:23:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/11154854#M30867</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2022-05-08T08:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: Make a command with parameter</title>
      <link>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/11154870#M30868</link>
      <description>&lt;P&gt;Uploading scr file is not supported,&amp;nbsp; file&amp;nbsp;&lt;SPAN&gt;extension change to txt.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;This is a&amp;nbsp; new line after&amp;nbsp;&lt;SPAN&gt;the (setvar "osmode" old-osmode).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This file seems using LF(Unix) as the line break.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 08 May 2022 08:42:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/11154870#M30868</guid>
      <dc:creator>foxever</dc:creator>
      <dc:date>2022-05-08T08:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: Make a command with parameter</title>
      <link>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/11155223#M30869</link>
      <description>&lt;P&gt;It looks like running a script from .NET is equivalent to call SendStringToExecute passing it the whole .scr file content as argument. This is probalby why it runs asynchronously.&lt;/P&gt;
&lt;P&gt;You can try this way;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;            var doc = Application.DocumentManager.MdiActiveDocument;
            string command = File.ReadAllText("D:\\123.scr");
            command += File.ReadAllText("D:\\234.scr");
            command += "_zoom\n_Extents\n";
            doc.SendStringToExecute(command, false, false, true);&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 08 May 2022 16:10:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/11155223#M30869</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2022-05-08T16:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: Make a command with parameter</title>
      <link>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/11158137#M30870</link>
      <description>&lt;P&gt;Graceful solution!&lt;/P&gt;&lt;P&gt;It works perfect. Thank u so much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;During the progress, unit setting window will prompt twice. Solved by adding "-" between "_" and "UNITS".&lt;/P&gt;&lt;P&gt;Reference:&lt;/P&gt;&lt;P&gt;AutoCAD help files.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;SPAN&gt;A script can execute any command at the Command prompt except a command that displays a dialog box. In most cases, a command that displays a dialog box has an alternative version of the command that displays Command prompts instead of a dialog box. Most alternative versions of a command start with a hypen (-). For example, use -INSERT instead of INSERT.&lt;/SPAN&gt;&amp;nbsp;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 01:18:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/make-a-command-with-parameter/m-p/11158137#M30870</guid>
      <dc:creator>foxever</dc:creator>
      <dc:date>2022-05-10T01:18:03Z</dc:date>
    </item>
  </channel>
</rss>

