How to use GetMultiple from a panel or dialog

Hi everyone.

I’m working on a plugin and I’m creating an interface in Eto.
I would like to import Curves or Breps by pressing the import button in Eto (it is a button in the Panel or SemiModal dialog).

By pressing the import_Button, I am executing the OnImportButton method and GetMultiple, but I can’t finish the selection.

var import_button = new Button { Text = "Import Button" };
import_button.Click += (sender, e) => OnImportButton();

I’m writing the inside of OnImportButton in the form below, and I can select and Add to curves, but I can’t finish the selection prompt.
I think there’s something wrong with the relationship between While and GetMultiple, but I can’t figure out the Result.

I found a sample of using GetMultiple in a command, but I would appreciate it if there is a sample of using GetMultiple from a button in a panel.

Does anyone know how to do this?

Best regards,
Masaki

protected Result OnImportButton()
{
    var have_preselected_objects = false;

    var goCurves = new GetObject();
    goCurves.SetCommandPrompt("Please select mutiple curves.");
    goCurves.GeometryFilter = ObjectType.Curve;
    goCurves.GeometryAttributeFilter = GeometryAttributeFilter.ClosedCurve;
    goCurves.GroupSelect = true;
    goCurves.SubObjectSelect = false;

    while (true)
    {
        goCurves.GetMultiple(1, 0);

        if (goCurves.CommandResult() != Rhino.Commands.Result.Success)
        {     
            return goCurves.CommandResult();
        }

    if (goCurves.ObjectsWerePreselected)
        {
            have_preselected_objects = true;
            goCurves.EnablePreSelect(false, true);
            goCurves.AlreadySelectedObjectSelect = true;
            goCurves.EnableClearObjectsOnEntry(false);
            goCurves.DeselectAllBeforePostSelect = false;
            goCurves.EnableUnselectObjectsOnExit(false);
	  continue;
      }
         break;
    }

    for (var i = 0; i < goCurves.ObjectCount; i++)
    {
        curves.Add(goCurves.Object(i).Curve());
    }

    return goCurves.CommandResult();
}

Why not use the more easy RhinoGet.GetMultipleObjects with a custom GetObjectGeometryFilter?

    public Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      Result res = RhinoGet.GetMultipleObjects("Select multiple (closed) curves", false, FilterClosedCurve, out var cRefs);
      if (res != Result.Success) return res;

      return Result.Success;
    }

    private bool FilterClosedCurve(RhinoObject rhObject, GeometryBase geometry, ComponentIndex componentIndex)
    {
      if (geometry is Curve crv) {
        return crv.IsClosed;
      }
      return false;
    }
1 Like

Hi Menno,

Thanks for the comment and the easy way to select the curves!

But I rewrote the contents of OnImportButton as below, but the message [Select multiple (closed) curves.Press Enter when done] remains even after I press Enter.
After pressing Enter, the object cannot be selected anymore, so I think the command is finished.

If you can tell me how to solve this problem, I would appreciate it.
Masaki.

    Rhino.Commands.Result OnImportButton()
    {
        Result res = RhinoGet.GetMultipleObjects("Select multiple (closed) curves ", false, FilterClosedCurve, out var cRefs);
        if (res != Rhino.Commands.Result.Success) return res;

        foreach (var obj in cRefs)
        {
            curves.Add(obj.Curve());
        }	

        return Rhino.Commands.Result.Success;

        bool FilterClosedCurve(RhinoObject rhObject, GeometryBase geometry, ComponentIndex componentIndex)
        {
            if (geometry is Curve crv)
            {
                return crv.IsClosed;
            }
            return false;
        }
    }

This looks like normal behavior to me. As soon as the operation finishes (i.e. the curves are moved upwards) the text goes into the command history window. This is the same for other Rhino commands.
If you really don’t what that, you can set RhinoApp.CommandPrompt with something different.

1 Like

Thank you very much!

I was able to change the message displayed at the prompt by putting a String in RhinoApp.CommandPrompt.