Пример #1
0
        protected override SamplerStatus Sampler(JigPrompts prompts)
        {
            JigPromptPointOptions jppo = new JigPromptPointOptions(_message);

            jppo.Keywords.Add(""); // mod 20140527
            jppo.Cursor            = CursorType.EntitySelect;
            jppo.BasePoint         = _center;
            jppo.UseBasePoint      = true;
            jppo.UserInputControls = UserInputControls.NullResponseAccepted;
            Point3d end = prompts.AcquirePoint(jppo).Value;

            if (end.IsNull())
            {
                return(SamplerStatus.Cancel);
            }
            else if (end != _end)
            {
                _end = end;
                return(SamplerStatus.OK);
            }
            else
            {
                return(SamplerStatus.NoChange);
            }
        }
Пример #2
0
        protected override SamplerStatus Sampler(JigPrompts prompts)
        {
            JigPromptPointOptions jppo = new JigPromptPointOptions("\n指定位置");

            jppo.Keywords.Add(""); // mod 20140527
            jppo.Cursor            = CursorType.EntitySelect;
            jppo.UseBasePoint      = false;
            jppo.UserInputControls = UserInputControls.NullResponseAccepted;
            Point3d pos = prompts.AcquirePoint(jppo).Value;

            if (pos.IsNull())
            {
                return(SamplerStatus.Cancel);
            }
            else if (pos != _pos)
            {
                _move = pos - _pos;
                _pos  = pos;
                return(SamplerStatus.OK);
            }
            else
            {
                _move = pos - _pos;
                return(SamplerStatus.NoChange);
            }
        }
Пример #3
0
        public void TestSpline()
        {
            List <Point3d> points = new List <Point3d>();

            while (true)
            {
                Point3d point = Interaction.GetPoint("\nSpecify a point");
                if (point.IsNull())
                {
                    break;
                }
                points.Add(point);
                Draw.Circle(point, 5);
            }
            Draw.SplineCV(points.ToArray(), true);
        }
Пример #4
0
        public static void PolyLanding()
        {
            ObjectId[]      ids            = QuickSelection.SelectAll("*LINE,ARC").ToArray();
            List <ObjectId> landingLineIds = new List <ObjectId>();

            while (true)
            {
                Point3d p = Interaction.GetPoint("\nSpecify a point");
                if (p.IsNull())
                {
                    break;
                }
                Point3d[] landings = ids.QSelect(x => (x as Curve).GetClosestPointTo(p, false)).ToArray();
                double    minDist  = landings.Min(x => x.DistanceTo(p));
                Point3d   landing  = landings.First(x => x.DistanceTo(p) == minDist);
                Interaction.WriteLine("Shortest landing distance of point ({0:0.00},{1:0.00}) is {2:0.00}。", p.X, p.Y, minDist);
                ObjectId landingLineId = Draw.Line(p, landing);
                landingLineIds.Add(landingLineId);
            }
            landingLineIds.QForEach(x => x.Erase());
        }
Пример #5
0
        protected override SamplerStatus Sampler(JigPrompts prompts)
        {
            JigPromptPointOptions jppo = new JigPromptPointOptions(_message);

            jppo.Keywords.Add(""); // mod 20140527
            jppo.Cursor            = CursorType.EntitySelect;
            jppo.UseBasePoint      = false;
            jppo.UserInputControls = UserInputControls.NullResponseAccepted;
            Point3d corner  = prompts.AcquirePoint(jppo).Value;
            Point3d pos     = Point3d.Origin + 0.5 * (_basePoint.GetAsVector() + corner.GetAsVector());
            var     extents = _ent.GeometricExtents;
            double  scale   = Math.Min(
                Math.Abs(corner.X - _basePoint.X) / (extents.MaxPoint.X - extents.MinPoint.X),
                Math.Abs(corner.Y - _basePoint.Y) / (extents.MaxPoint.Y - extents.MinPoint.Y));

            if (scale < Consts.Epsilon) // 在一开始scale势必很小。过小的scale会导致矩阵运算出现非等比缩放变换,从而被CAD拒绝,导致异常。
            {
                scale = Consts.Epsilon;
            }
            if (pos.IsNull())
            {
                return(SamplerStatus.Cancel);
            }
            else if (pos != _pos)
            {
                _move = pos - _pos;
                _pos  = pos;
                //_mag = scale / _scale;
                //_scale = scale;
                _mag = scale;
                return(SamplerStatus.OK);
            }
            else
            {
                _move = pos - _pos;
                return(SamplerStatus.NoChange);
            }
        }
Пример #6
0
        protected override SamplerStatus Sampler(JigPrompts prompts)
        {
            JigPromptPointOptions jppo = new JigPromptPointOptions(_message);

            jppo.Keywords.Add(""); // mod 20140527
            jppo.Cursor       = CursorType.RubberBand;
            jppo.BasePoint    = _startPoint;
            jppo.UseBasePoint = true;
            Point3d endPoint = prompts.AcquirePoint(jppo).Value;

            if (endPoint.IsNull())
            {
                return(SamplerStatus.Cancel);
            }
            else if (endPoint != _endPoint)
            {
                _endPoint = endPoint;
                return(SamplerStatus.OK);
            }
            else
            {
                return(SamplerStatus.NoChange);
            }
        }