What function to use to get the preselected curve using RhinoCommon (C#)?


#1

Hi there,

I am quite new to the I am trying to create a small plugin to automate a process that I do all the time.

Here is what I want to do:

  1. User select a closed curve (rectangle)
  2. Run the plugin command
  3. A form will come up for user to select some options for the pattern, for example, Round or square
  4. When user press OK in the dialog box, the pattern is filled into the closed curve.

Has anyone done something like this before??

This is what I tried, but get ObjectCount is always 0 even I have selected some object.

        // Check the selected curve
        GetObject go = new GetObject();

        go.GroupSelect = true;
        go.SubObjectSelect = false;
        go.EnableClearObjectsOnEntry(false);
        go.EnableUnselectObjectsOnExit(false);
        go.DeselectAllBeforePostSelect = false;
        go.EnableSelPrevious(true);
        go.EnablePreSelect(true, false);
        go.GeometryFilter = Rhino.DocObjects.ObjectType.Curve;

        GetResult result = go.Get();

(Giulio Piacentino) #2

Hi Toby

I think that the reason for this is that the Get() meets the condition to return just at the point when you enter.

If you want to use just one curve, then I would suggest that you use:
Rhino.Input.RhinoGet.GetOneObject().
It has a simpler and more understandable interface. I prefer it when I can use it.

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com


(Dale Fugier) #3

If a single curve is pre-selected, then this should work:

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
  // Check the selected curve
  GetObject go = new GetObject();
  go.GeometryFilter = Rhino.DocObjects.ObjectType.Curve;
  go.EnablePreSelect(true, false);
  go.EnablePostSelect(false);
  GetResult result = go.Get();

  if (result == GetResult.Object)
    RhinoApp.WriteLine("Selected count = {0}", go.ObjectCount);
  else
    RhinoApp.WriteLine("Selected count = 0");

  return Result.Success;
}