Exemple #1
0
            public static bool Jig(Point3d p0, Point3d t0, Point3d p2, int segments)
            {
                BezierJig jigger = new BezierJig(CreatePolyline(), p0, t0, p2, segments);

                Autodesk.AutoCAD.ApplicationServices.Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
                Autodesk.AutoCAD.DatabaseServices.Database    db  = doc.Database;

                PromptResult res = doc.Editor.Drag(jigger);

                if (res.Status == PromptStatus.OK)
                {
                    using (Transaction tr = db.TransactionManager.StartTransaction())
                        using (BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite))
                        {
                            btr.AppendEntity(jigger.Entity);
                            tr.AddNewlyCreatedDBObject(jigger.Entity, true);

                            tr.Commit();
                        }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
Exemple #2
0
        public void DrawQuadraticBezier()
        {
            if (!CheckLicense.Check())
            {
                return;
            }

            Autodesk.AutoCAD.ApplicationServices.Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Autodesk.AutoCAD.DatabaseServices.Database    db  = doc.Database;

            PromptPointResult p0Res;

            while (true)
            {
                PromptPointOptions p0Opts = new PromptPointOptions("\nStart Point: [Seçenekler]", "Settings");
                p0Res = doc.Editor.GetPoint(p0Opts);
                if (p0Res.Status == PromptStatus.Keyword && p0Res.StringResult == "Settings")
                {
                    PromptIntegerOptions opts = new PromptIntegerOptions("Eğri segment sayısı: ");
                    opts.AllowNone       = true;
                    opts.AllowZero       = false;
                    opts.AllowNegative   = false;
                    opts.LowerLimit      = 1;
                    opts.UpperLimit      = 100;
                    opts.DefaultValue    = CurveSegments;
                    opts.UseDefaultValue = true;
                    PromptIntegerResult res = doc.Editor.GetInteger(opts);
                    if (res.Status == PromptStatus.Cancel)
                    {
                        return;
                    }
                    else if (res.Status == PromptStatus.OK)
                    {
                        CurveSegments = res.Value;
                    }
                }
                else if (p0Res.Status != PromptStatus.OK)
                {
                    return;
                }
                else
                {
                    break;
                }
            }
            PromptPointOptions t0Opts = new PromptPointOptions("\nStart Tangent: ");

            t0Opts.BasePoint    = p0Res.Value;
            t0Opts.UseBasePoint = true;
            PromptPointResult t0Res = doc.Editor.GetPoint(t0Opts);

            if (t0Res.Status != PromptStatus.OK)
            {
                return;
            }
            PromptPointResult p2Res = doc.Editor.GetPoint("\nEnd Point: ");

            if (p2Res.Status != PromptStatus.OK)
            {
                return;
            }

            BezierJig.Jig(p0Res.Value, t0Res.Value, p2Res.Value, CurveSegments);
        }