Last command

Hello

I have this simple command on C# button:
private void button3_Click(object sender, EventArgs e)
{
MessageBox.Show(“Command Teste”);
}

Why is this command not saved as last command ?? (Repeat command with space or right mouse clic)

Hi @MatrixRatrix,

I’m confused. Your code shows a Windows form button click event displaying a message box. Where is the Rhino command that you expect to have repeated?

– Dale

Sorry @dale , this example is just to explain.

In this case, have a button with command like this:

	private void button3_Click(object sender, EventArgs e)
	{
		var rhinoscript_object = RhinoApp.GetPlugInObject("RhinoScript");
		var rs = (IRhinoScript)rhinoscript_object;


		var start = rs.GetPoint("Get start point");
		var end = rs.GetPoint("Get end point");

		rs.AddLine(start,end);

	}

So this command to create a line and dont save as last command, this because is script command?

Thank you

Hi @MatrixRatrix,

Rhino command are classes that inherit from the Rhino.Commands.Command class. These types of command, after execution, show up on the recent command list.

Just curious, you are developing a RhinoCommon plug-in, correct? If so, why are you using the legacy RhinoScript (COM) object? This is slow and quite unnecessary, being that you have RhinoCommon.

– Dale

Correct @dale , I developing RhinoCommon plugin, I know that using the Rhinoscript it’s not the right one way,
but for me is more easy, and I have a lot of python scripts to convert, so it facilitates, but as I progress I start to give up RhinoScript.

Hello @dale ,

In fact already I verified that it was not doing a command correctly, I was doing a command directly from a windows form button, I think it is not a serious problem, but it will not be saved as the last command.

So, for it to be saved as the last command the function must be called as:

protected override Result RunCommand(RhinoDoc doc, RunMode mode)......etc

So far no problem, but I do not want this command available on the Rhino command line when is
typed the “EnglishName”

Can I hide the command from the command line?

I do not know if I explained myself well !

Thank you.

Add the following attribute to your command class:

[CommandStyle(Style.Hidden)] // <- Add this...
public class MyCommand : Command
{
...
}

– Dale

Thank you.

Hello @dale,

Clearly I was structuring my code wrong, now I am trying to optimize for the best possible, and according to what I had already done.

Now I create a Button (on Form) that call my command ex:

	private void Btn_chamfer_Click(object sender, EventArgs e)
	{
		RhinoApp.RunScript("ChamferCmd", true);
	}

And have my command like ex:

	protected override Result RunCommand(RhinoDoc doc, RunMode mode)
	{
		bool ok = RhinoApp.RunScript("_Chamfer", true);
        MessageBox.Show(ok.ToString());
	}

Obviously my command is much larger than this, anyway it’s just to explain what happened.

I think in practice I am calling a command within another (I do not know if it is good practice), and this
work for some commands, but for some other dont work, one of them is the Fillet and Chanfer command.

In this case the command return always False.

I just want to try to figure out if I’m doing something wrong? or just can not use one command inside another?

I already know instead of using a command in this case ("_Chanfer") I can use Rhino common and do the chanfer command inside the “RunCommand” , just to understand.

Thank you

– Dale

0155-Ok