Пример #1
0
        public void jigcmd3()
        {
            var doc = Application.DocumentManager.MdiActiveDocument;

            var firstPt = doc.Editor.GetPoint("\n请输入起始坐标点");

            if (firstPt.Status == PromptStatus.OK)
            {
                var poly = new Polyline();
                //var dim = new AlignedDimension();
                //var aDim = new Point3AngularDimension();
                poly.AddVertexAt(poly.NumberOfVertices,
                                 new Point2d(firstPt.Value.X, firstPt.Value.Y), 0, 0, 0);

                var jigOpt  = new JigPromptPointOptions();
                var polyJig = new JigHelper();
                polyJig.SetEntities(new Entity[] { poly });

                for (var i = 1; i < int.MaxValue; i++)
                {
                    polyJig.PrapareForNextInput(jigOpt, "\n请输入下一个点");
                    polyJig.SetUpdate(jig =>
                    {
                        if (poly.NumberOfVertices == i)
                        {
                            poly.AddVertexAt(poly.NumberOfVertices,
                                             new Point2d(jig.Point.X, jig.Point.Y), 0, 0, 0);
                        }
                        else
                        {
                            poly.SetPointAt(i, new Point2d(jig.Point.X, jig.Point.Y));
                        }
                    });

                    var stat = polyJig.Drag();
                    if (stat == PromptStatus.Cancel)
                    {
                        break;
                    }
                    else if (stat != PromptStatus.OK)
                    {
                        return;
                    }
                }

                poly.ToSpace();
            }
        }
Пример #2
0
        public void jigcmd2()
        {
            var doc = Application.DocumentManager.MdiActiveDocument;

            var basePt = doc.Editor.GetPoint("\n请输入圆心");

            if (basePt.Status == PromptStatus.OK)
            {
                var jigOpt = new JigPromptDistanceOptions();
                jigOpt.BasePoint    = basePt.Value;
                jigOpt.UseBasePoint = true;

                var circle1 = new Circle()
                {
                    Center = basePt.Value
                };
                var circle2 = new Circle()
                {
                    Center = basePt.Value
                };
                var hatch = new Hatch();
                hatch.SetHatchPattern(HatchPatternType.PreDefined, "BOX");

                var donut = new JigHelper();

                // Step 1
                donut.PrapareForNextInput(jigOpt, "\n请确定第一圈");
                donut.SetEntities(new Entity[] { circle1 });
                donut.SetUpdate(jig => circle1.Radius = Math.Max(0.1, jig.Distance));
                if (donut.Drag() != PromptStatus.OK)
                {
                    return;
                }

                // Step 2
                donut.PrapareForNextInput(jigOpt, "\n请确定第二圈");
                donut.SetEntities(new Entity[] { circle1, circle2, hatch });
                donut.SetUpdate(jig =>
                {
                    circle2.Radius = Math.Max(0.1, jig.Distance);
                    while (hatch.NumberOfLoops > 0)
                    {
                        hatch.RemoveLoopAt(0);
                    }
                    hatch.AppendLoop(HatchLoopTypes.Default, new Curve2dCollection()
                    {
                        new CircularArc2d(new Point2d(circle1.Center.X, circle1.Center.Y),
                                          circle1.Radius),
                    }, new IntegerCollection()
                    {
                        0
                    });
                    hatch.AppendLoop(HatchLoopTypes.Default, new Curve2dCollection()
                    {
                        new CircularArc2d(new Point2d(circle2.Center.X, circle2.Center.Y),
                                          circle2.Radius),
                    }, new IntegerCollection()
                    {
                        0
                    });
                });
                if (donut.Drag() != PromptStatus.OK)
                {
                    return;
                }

                // Final
                circle1.ToSpace();
                circle2.ToSpace();
                hatch.ToSpace();
            }
        }