Add parameter in command


I’ve created a command, and I need pass parameters.

I can create a new property in PlugInClass and get this property in the command, but I don’t like do it.

I call the command so

return (Rhino.RhinoApp.RunScript(“AgutImportDXF”, true));

So… how I can pass a parameter?

I’m using c# and rhinoCommon

Let’s say your command AgutImportDXF has two parameters (MyParam1 and MyParam2), one number and one toggle (Yes/No).

Then, you can script it like this:

return (Rhino.RhinoApp.RunScript("_-AgutImportDXF MyParam1=140 MyParam2=Yes _Enter", true));

Note the use of the -(dash) in front of the command, this is to set the command to scripted mode. Secondly, note the _ (underscore) in front of the command and the Enter command. This is to force English name of the command when Rhino is running in another language.


And…how I can get the parameters value inside the command class

in RunCommand function?

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
_doc = doc;
if (_plugin == null)
_plugin = new AgutCAM2PlugIn();
if (ImportarDXF())
return Result.Success;
return Result.Cancel;

You looking for:

    string str = String.Empty;
    RhinoGet.GetString("Custom String", true, ref str);
    if str = 0
return Result.Success;

dont know if I typed that right but this way you can get a custom str. or integer.
I’m more into Vb.NET

1 Like

Ok, It works but…

I run the script so:

Rhino.RhinoApp.RunScript("_-AgutImportDXF calibrado=10 _Enter", true);

If I use inside RunCommand method:

string str = String.Empty
RhinoGet.GetString(“calibrado”, true, ref str);

the result in str is “calibrado = 10”

If I use
RhinoGet.GetInteger(string.Empty, true, ref _calibrado);

the result in _calibrado is 0 not 10

How I can use RhinoGet.GetInteger?

An integer is only a number so it cant get calibrado=.

Then you should do something like:

Ingeger int = 0
RhinoGet.GetInteger(“calibrado”, true, ref int );

Rhino.RhinoApp.RunScript("_-AgutImportDXF 10 _Enter", true);

It not works.

And if I want two parameters… how can I differentiate both? The first parameter in GetInteger is not referenced in RunScript

Please see this example on how to use GetOption with multiple command line options

1 Like

Thanks menno.

I had not seen that example.

I can read the parameter so:

In RunCommand function
int _calibrado = 0;
OptionInteger optionInteger = new OptionInteger(0, 0, 1000);
GetObject go = new GetObject();
go.AddOptionInteger(“calibrado”, ref optionInteger);
RhinoGet.GetInteger(“calibrado”, true, ref _calibrado);

and calling RhinoScript

Rhino.RhinoApp.RunScript("_-AgutImportDXF 10 _Enter", true)

No, this is wrong. Don’t use RhinoGet.GetInteger, use go.Get(), just like in the example. Then you can use named parameter as I wrote earlier.

1 Like

oki, thanks