예제 #1
0
        bool SelectHeight()
        {
            using (var cmd = new GetPoint())
            {
                cmd.SetCommandPrompt("Select the Height");
                cmd.AcceptNumber(true, true);
                cmd.SetDefaultNumber(DefaultHeight);

                var r = cmd.Get();
                switch (r)
                {
                case Rhino.Input.GetResult.Number:
                    m_height      = cmd.Number();
                    DefaultHeight = m_height;
                    break;

                case Rhino.Input.GetResult.Point:
                    m_height = cmd.Point().Z - m_basePoint.Z;
                    break;

                default:
                    return(false);
                }

                return(true);
            }
        }
        private static Result GetTolerance(ref double tolerance)
        {
            var gp = new GetPoint();

            gp.SetCommandPrompt("Tolerance");
            gp.SetDefaultNumber(tolerance);
            gp.AcceptNumber(true, false);

            for (; ;)
            {
                var res = gp.Get();

                if (res == GetResult.Number)
                {
                    var d = gp.Number();
                    if (d < 0.0)
                    {
                        RhinoApp.WriteLine("Tolerance must be greater than 0.");
                    }
                    else
                    {
                        tolerance = d;
                        return(Result.Success);
                    }
                }

                if (res != GetResult.Point)
                {
                    return(Result.Cancel);
                }

                break;
            }

            var base_point = gp.Point();

            gp.SetBasePoint(base_point, true);
            gp.DrawLineFromPoint(base_point, true);
            gp.DynamicDrawColor = Rhino.ApplicationSettings.AppearanceSettings.TrackingColor;

            for (; ;)
            {
                var res = gp.Get();

                if (res == GetResult.Number)
                {
                    var d = gp.Number();
                    if (d < 0.0)
                    {
                        RhinoApp.WriteLine("Tolerance must be greater than 0.");
                    }
                    else
                    {
                        tolerance = d;
                        return(Result.Success);
                    }
                }

                if (res != GetResult.Point)
                {
                    return(Result.Cancel);
                }

                break;
            }

            tolerance = base_point.DistanceTo(gp.Point());
            return(Result.Success);
        }