Beispiel #1
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            Rhino.UI.OpenFileDialog dialog = new Rhino.UI.OpenFileDialog();
            dialog.Title = "Open pointcloud file";
            dialog.ShowOpenDialog();

            Rhino.Input.Custom.OptionInteger optStep = new Rhino.Input.Custom.OptionInteger(4, 1, 1000);
            Rhino.Input.Custom.GetOption     getOpt  = new Rhino.Input.Custom.GetOption();
            getOpt.AddOptionInteger("Resolution", ref optStep);
            getOpt.SetCommandPrompt("Loading options");

            string path = dialog.FileName;

            if (!System.IO.File.Exists(path))
            {
                Rhino.RhinoApp.WriteLine("Farhino: Failed to find file...");
                return(Result.Failure);
            }

            getOpt.Get();

            Rhino.RhinoApp.WriteLine("Farhino: Step value: " + optStep.CurrentValue.ToString());
            RFContext.LoadScan(path, optStep.CurrentValue);

            return(Result.Success);
        }
Beispiel #2
0
    public static Rhino.Commands.Result CommandLineOptions(Rhino.RhinoDoc doc)
    {
        // For this example we will use a GetPoint class, but all of the custom
        // "Get" classes support command line options.
        Rhino.Input.Custom.GetPoint gp = new Rhino.Input.Custom.GetPoint();
        gp.SetCommandPrompt("GetPoint with options");

        // set up the options
        Rhino.Input.Custom.OptionInteger intOption  = new Rhino.Input.Custom.OptionInteger(1, 1, 99);
        Rhino.Input.Custom.OptionDouble  dblOption  = new Rhino.Input.Custom.OptionDouble(2.2, 0, 99.9);
        Rhino.Input.Custom.OptionToggle  boolOption = new Rhino.Input.Custom.OptionToggle(true, "Off", "On");
        string[] listValues = new string[] { "Item0", "Item1", "Item2", "Item3", "Item4" };

        gp.AddOptionInteger("Integer", ref intOption);
        gp.AddOptionDouble("Double", ref dblOption);
        gp.AddOptionToggle("Boolean", ref boolOption);
        int listIndex = 3;
        int opList    = gp.AddOptionList("List", listValues, listIndex);

        while (true)
        {
            // perform the get operation. This will prompt the user to input a point, but also
            // allow for command line options defined above
            Rhino.Input.GetResult get_rc = gp.Get();
            if (gp.CommandResult() != Rhino.Commands.Result.Success)
            {
                return(gp.CommandResult());
            }

            if (get_rc == Rhino.Input.GetResult.Point)
            {
                doc.Objects.AddPoint(gp.Point());
                doc.Views.Redraw();
                Rhino.RhinoApp.WriteLine("Command line option values are");
                Rhino.RhinoApp.WriteLine(" Integer = {0}", intOption.CurrentValue);
                Rhino.RhinoApp.WriteLine(" Double = {0}", dblOption.CurrentValue);
                Rhino.RhinoApp.WriteLine(" Boolean = {0}", boolOption.CurrentValue);
                Rhino.RhinoApp.WriteLine(" List = {0}", listValues[listIndex]);
            }
            else if (get_rc == Rhino.Input.GetResult.Option)
            {
                if (gp.OptionIndex() == opList)
                {
                    listIndex = gp.Option().CurrentListOptionIndex;
                }
                continue;
            }
            break;
        }
        return(Rhino.Commands.Result.Success);
    }
    public static Rhino.Commands.Result CommandLineOptions(Rhino.RhinoDoc doc)
    {
        // For this example we will use a GetPoint class, but all of the custom
        // "Get" classes support command line options.
        Rhino.Input.Custom.GetPoint gp = new Rhino.Input.Custom.GetPoint();
        gp.SetCommandPrompt("GetPoint with options");

        // set up the options
        Rhino.Input.Custom.OptionInteger intOption = new Rhino.Input.Custom.OptionInteger(1, 1, 99);
        Rhino.Input.Custom.OptionDouble dblOption = new Rhino.Input.Custom.OptionDouble(2.2, 0, 99.9);
        Rhino.Input.Custom.OptionToggle boolOption = new Rhino.Input.Custom.OptionToggle(true, "Off", "On");
        string[] listValues = new string[] { "Item0", "Item1", "Item2", "Item3", "Item4" };

        gp.AddOptionInteger("Integer", ref intOption);
        gp.AddOptionDouble("Double", ref dblOption);
        gp.AddOptionToggle("Boolean", ref boolOption);
        int listIndex = 3;
        int opList = gp.AddOptionList("List", listValues, listIndex);

        while (true)
        {
          // perform the get operation. This will prompt the user to input a point, but also
          // allow for command line options defined above
          Rhino.Input.GetResult get_rc = gp.Get();
          if (gp.CommandResult() != Rhino.Commands.Result.Success)
        return gp.CommandResult();

          if (get_rc == Rhino.Input.GetResult.Point)
          {
        doc.Objects.AddPoint(gp.Point());
        doc.Views.Redraw();
        Rhino.RhinoApp.WriteLine("Command line option values are");
        Rhino.RhinoApp.WriteLine(" Integer = {0}", intOption.CurrentValue);
        Rhino.RhinoApp.WriteLine(" Double = {0}", dblOption.CurrentValue);
        Rhino.RhinoApp.WriteLine(" Boolean = {0}", boolOption.CurrentValue);
        Rhino.RhinoApp.WriteLine(" List = {0}", listValues[listIndex]);
          }
          else if (get_rc == Rhino.Input.GetResult.Option)
          {
        if (gp.OptionIndex() == opList)
          listIndex = gp.Option().CurrentListOptionIndex;
        continue;
          }
          break;
        }
        return Rhino.Commands.Result.Success;
    }
        private void GetNestingSettings()
        {
            //Parameters
            Rhino.Input.Custom.GetOption gp = new Rhino.Input.Custom.GetOption();
            gp.SetCommandPrompt("OpenNest: Set nesting settings");

            Rhino.Input.Custom.OptionInteger Iterations     = new Rhino.Input.Custom.OptionInteger(1, 1, 100);
            Rhino.Input.Custom.OptionDouble  Spacing        = new Rhino.Input.Custom.OptionDouble(0.01, 0.001, 10);
            Rhino.Input.Custom.OptionInteger Placement      = new Rhino.Input.Custom.OptionInteger(1, 0, 4);
            Rhino.Input.Custom.OptionDouble  Tolerance      = new Rhino.Input.Custom.OptionDouble(0.1, 0.01, 10);
            Rhino.Input.Custom.OptionInteger Rotations      = new Rhino.Input.Custom.OptionInteger(4, 0, 360);
            Rhino.Input.Custom.OptionInteger Seed           = new Rhino.Input.Custom.OptionInteger(0, 1, 100);
            Rhino.Input.Custom.OptionDouble  ClosestObjects = new Rhino.Input.Custom.OptionDouble(0.01, 0, 100);

            gp.AddOptionInteger("Iterations", ref Iterations);
            gp.AddOptionDouble("Spacing", ref Spacing);
            gp.AddOptionInteger("Placement", ref Placement);
            gp.AddOptionDouble("Tolerance", ref Tolerance);
            gp.AddOptionInteger("Rotations", ref Rotations);
            gp.AddOptionInteger("Seed", ref Seed);
            gp.AddOptionDouble("ClosestObjects", ref ClosestObjects);

            while (true)
            {
                Rhino.Input.GetResult get_rc = gp.Get();
                if (gp.CommandResult() != Rhino.Commands.Result.Success)
                {
                    break;
                }
            }

            this.iterations    = Iterations.CurrentValue;
            this.spacing       = Spacing.CurrentValue;
            this.placementType = Placement.CurrentValue;
            this.tolerance     = Tolerance.CurrentValue;
            this.rotations     = Rotations.CurrentValue;
            this.seed          = Seed.CurrentValue;
            this.spacing      *= (1 / tolerance);
            this.cp            = ClosestObjects.CurrentValue;
        }
Beispiel #5
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            const Rhino.DocObjects.ObjectType geometryFilter = Rhino.DocObjects.ObjectType.Surface |
                                                               Rhino.DocObjects.ObjectType.PolysrfFilter |
                                                               Rhino.DocObjects.ObjectType.Mesh;
            int integer1 = 300;
            int integer2 = 300;

            Rhino.Input.Custom.OptionInteger optionInteger1 = new Rhino.Input.Custom.OptionInteger(integer1, 200, 900);
            Rhino.Input.Custom.OptionInteger optionInteger2 = new Rhino.Input.Custom.OptionInteger(integer2, 200, 900);

            Rhino.Input.Custom.GetObject go = new Rhino.Input.Custom.GetObject();
            go.SetCommandPrompt("Select surfaces, polysurfaces, or meshes");
            go.GeometryFilter = geometryFilter;
            go.AddOptionInteger("Option1", ref optionInteger1);
            go.AddOptionInteger("Option2", ref optionInteger2);
            go.GroupSelect     = true;
            go.SubObjectSelect = false;
            go.EnableClearObjectsOnEntry(false);
            go.EnableUnselectObjectsOnExit(false);
            go.DeselectAllBeforePostSelect = false;

            bool bHavePreselectedObjects = false;

            for (; ;)
            {
                var res = go.GetMultiple(1, 0);

                if (res == Rhino.Input.GetResult.Option)
                {
                    go.EnablePreSelect(false, true);
                    continue;
                }

                else if (res != Rhino.Input.GetResult.Object)
                {
                    return(Result.Cancel);
                }

                if (go.ObjectsWerePreselected)
                {
                    bHavePreselectedObjects = true;
                    go.EnablePreSelect(false, true);
                    continue;
                }

                break;
            }

            if (bHavePreselectedObjects)
            {
                // Normally, pre-selected objects will remain selected, when a
                // command finishes, and post-selected objects will be unselected.
                // This this way of picking, it is possible to have a combination
                // of pre-selected and post-selected. So, to make sure everything
                // "looks the same", lets unselect everything before finishing
                // the command.
                for (int i = 0; i < go.ObjectCount; i++)
                {
                    Rhino.DocObjects.RhinoObject rhinoObject = go.Object(i).Object();
                    if (null != rhinoObject)
                    {
                        rhinoObject.Select(false);
                    }
                }
                doc.Views.Redraw();
            }

            int objectCount = go.ObjectCount;

            integer1 = optionInteger1.CurrentValue;
            integer2 = optionInteger2.CurrentValue;

            RhinoApp.WriteLine("Select object count = {0}", objectCount);
            RhinoApp.WriteLine("Value of integer1 = {0}", integer1);
            RhinoApp.WriteLine("Value of integer2 = {0}", integer2);

            return(Result.Success);
        }
  public static Rhino.Commands.Result GetMultipleWithOptions(Rhino.RhinoDoc doc)
  {
    const Rhino.DocObjects.ObjectType geometryFilter = Rhino.DocObjects.ObjectType.Surface | 
                                                       Rhino.DocObjects.ObjectType.PolysrfFilter | 
                                                       Rhino.DocObjects.ObjectType.Mesh;
    int integer1 = 300;
    int integer2 = 300;

    Rhino.Input.Custom.OptionInteger optionInteger1 = new Rhino.Input.Custom.OptionInteger(integer1, 200, 900);
    Rhino.Input.Custom.OptionInteger optionInteger2 = new Rhino.Input.Custom.OptionInteger(integer2, 200, 900);

    Rhino.Input.Custom.GetObject go = new Rhino.Input.Custom.GetObject();
    go.SetCommandPrompt("Select surfaces, polysurfaces, or meshes");
    go.GeometryFilter = geometryFilter;
    go.AddOptionInteger("Option1", ref optionInteger1);
    go.AddOptionInteger("Option2", ref optionInteger2);
    go.GroupSelect = true;
    go.SubObjectSelect = false;
    go.EnableClearObjectsOnEntry(false);
    go.EnableUnselectObjectsOnExit(false);
    go.DeselectAllBeforePostSelect = false;

    bool bHavePreselectedObjects = false;

    for (; ; )
    {
      Rhino.Input.GetResult res = go.GetMultiple(1, 0);

      if (res == Rhino.Input.GetResult.Option)
      {
        go.EnablePreSelect(false, true);
        continue;
      }

      else if (res != Rhino.Input.GetResult.Object)
        return Rhino.Commands.Result.Cancel;

      if (go.ObjectsWerePreselected)
      {
        bHavePreselectedObjects = true;
        go.EnablePreSelect(false, true);
        continue;
      }

      break;
    }

    if (bHavePreselectedObjects)
    {
      // Normally when command finishes, pre-selected objects will remain
      // selected, when and post-selected objects will be unselected.
      // With this sample, it is possible to have a combination of 
      // pre-selected and post-selected objects. To make sure everything
      // "looks the same", unselect everything before finishing the command.
      for (int i = 0; i < go.ObjectCount; i++)
      {
        Rhino.DocObjects.RhinoObject rhinoObject = go.Object(i).Object();
        if (null != rhinoObject)
          rhinoObject.Select(false);
      }
      doc.Views.Redraw();
    }

    int objectCount = go.ObjectCount;
    integer1 = optionInteger1.CurrentValue;
    integer2 = optionInteger2.CurrentValue;

    Rhino.RhinoApp.WriteLine("Select object count = {0}", objectCount);
    Rhino.RhinoApp.WriteLine("Value of integer1 = {0}", integer1);
    Rhino.RhinoApp.WriteLine("Value of integer2 = {0}", integer2);

    return Rhino.Commands.Result.Success;
  }