Quantcast
Channel: Rhino Developer - McNeel Forum
Viewing all articles
Browse latest Browse all 8532

Commandline options problem in C#

$
0
0

I am trying to make a simple command in rhino to array rectangles in a curve, the problem is the commandline options does not work properly as an input. This is just a test I am trying to learn C# in VS.

        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
            {
                int i;
                var selectedcurves = new CurveList();
                Point3d[] divptarray;


                //Step 1 - Select curves---------------------------------------------------

                GetObject gp = new GetObject();
                gp.SetCommandPrompt("Select some curves");
                gp.GeometryFilter = ObjectType.Curve;
                RhinoApp.WriteLine("Now Choose the Options");

                // set up the options
                OptionInteger intOption = new OptionInteger(1, 1, 99);
                OptionDouble dblOption = new OptionDouble(2.2, 0, 99.9);
                OptionDouble dblOption2 = new OptionDouble(2.2, 0, 99.9);

                gp.AddOptionInteger("Division", ref intOption);
                gp.AddOptionDouble("x", ref dblOption);
                gp.AddOptionDouble("y", ref dblOption2);

                int divisions = intOption.CurrentValue;
                double Xrec = dblOption.CurrentValue;
                double Yrec = dblOption2.CurrentValue;


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

                    if (get_rc == 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}", dblOption2.CurrentValue);
                    }
                    else if (get_rc == GetResult.Option)
                    {
                        continue;
                    }
                    break;
                }

                var curve = gp.Object(0).Curve();

                double[] parameters = curve.DivideByCount(divisions, true, out divptarray);

                myFunctions.XDrawPoints(divptarray, doc);

                myFunctions.XDrawRectanglesInCurve(divptarray, curve, Xrec, Yrec, doc);

                doc.Views.Redraw();

                return Result.Success;
            }

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 8532

Trending Articles