Esempio n. 1
0
        LeaderHardWired()
        {
            m_db = Utils.Db.GetCurDwg();

            using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) {
                compBldr.Start();
                compBldr.PushXform(Utils.Db.GetUcsMatrix(m_db));

                Point3d startPoint = new Point3d(0.0, 0.0, 0.0);
                Point3d midPoint   = new Point3d(50.0, 50.0, 0.0);
                Point3d endPoint   = new Point3d(100.0, 50.0, 0.0);

                Point3dCollection pts = new Point3dCollection();
                pts.Add(startPoint);
                pts.Add(midPoint);
                pts.Add(endPoint);

                Leader leader = new Leader();
                foreach (Point3d pt in pts)
                {
                    leader.AppendVertex(pt);
                }
                compBldr.AddToDb(leader);
                compBldr.Commit();
            }
        }
Esempio n. 2
0
        Polyline2dHardwired()
        {
            m_db = Utils.Db.GetCurDwg();

            using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) {
                compBldr.Start();
                compBldr.PushXform(Utils.Db.GetUcsMatrix(m_db));

                Polyline2d pline2d = new Polyline2d();
                pline2d.Color = Color.FromRgb(42, 184, 185);
                // polyline2d needs to be in database before the vertices
                // can be added to it. The polyline2d owns the vertices.
                compBldr.AddToDb(pline2d);

                Point3d[] pts = new Point3d[4];
                pts[0] = new Point3d(0.0, 0.0, 0.0);
                pts[1] = new Point3d(15.0, 0.0, 0.0);
                pts[2] = new Point3d(15.0, 8.0, 0.0);
                pts[3] = new Point3d(0.0, 8.0, 0.0);

                Vertex2d vertX2d;

                for (int i = 0; i < pts.Length; i++)
                {
                    vertX2d = new Vertex2d(pts[i], 0.0, 0.0, 0.0, 0.0);
                    pline2d.AppendVertex(vertX2d);
                    compBldr.Transaction.AddNewlyCreatedDBObject(vertX2d, true);
                }

                pline2d.Closed = true;
                compBldr.Commit();
            }
        }
Esempio n. 3
0
        Lineweights()
        {
            m_db = Utils.Db.GetCurDwg();

            using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) {
                compBldr.Start();
                compBldr.PushXform(Utils.Db.GetUcsMatrix(m_db));

                Point3d startPt = new Point3d(0.0, 0.0, 0.0);
                Point3d endPt   = new Point3d(100.0, 0.0, 0.0);

                Vector3d offset = new Vector3d(0.0, 10.0, 0.0);

                foreach (Autodesk.AutoCAD.DatabaseServices.LineWeight lw in System.Enum.GetValues(typeof(LineWeight)))
                {
                    Line line = new Line(startPt, endPt);
                    line.LineWeight = lw;

                    compBldr.AddToDb(line);

                    DBText text = new DBText();
                    text.Height     = 5.0;
                    text.Position   = endPt;
                    text.TextString = lw.ToString();

                    compBldr.AddToDb(text);

                    startPt += offset;
                    endPt   += offset;
                }

                compBldr.Commit();
            }
        }
Esempio n. 4
0
        CompBldrCurSpace()
        {
            m_db = Utils.Db.GetCurDwg();

            using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) {
                compBldr.Start();

                double tmpRadius = 1.0;

                Circle tmpCirc = null;
                for (int i = 0; i < 10; i++)
                {
                    tmpCirc            = new Circle();
                    tmpCirc.Radius     = tmpRadius;
                    tmpCirc.ColorIndex = i;

                    Utils.Db.TransformToWcs(tmpCirc, m_db);
                    compBldr.AddToDb(tmpCirc);

                    tmpRadius += 1.0;
                }

                Matrix3d mat = Matrix3d.Displacement(new Vector3d(10.0, 10.0, 0.0));
                compBldr.PushXform(mat);

                tmpCirc        = new Circle();
                tmpCirc.Radius = 2.0;
                Utils.Db.TransformToWcs(tmpCirc, m_db);
                compBldr.AddToDb(tmpCirc);

                compBldr.PopXform();

                compBldr.Commit();
            }
        }
Esempio n. 5
0
        XlineHardWired()
        {
            m_db = Utils.Db.GetCurDwg();

            using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) {
                compBldr.Start();
                compBldr.PushXform(Utils.Db.GetUcsMatrix(m_db));

                Xline xline = new Xline();
                xline.UnitDir = new Vector3d(1.0, 1.0, 0.0);
                compBldr.AddToDb(xline);
                compBldr.Commit();
            }
        }
Esempio n. 6
0
        HelixHardWired()
        {
            m_db = Utils.Db.GetCurDwg();

            using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) {
                compBldr.Start();
                compBldr.PushXform(Utils.Db.GetUcsMatrix(m_db));

                Helix helix = new Helix();
                helix.Turns      = 10.0;
                helix.Twist      = true;
                helix.BaseRadius = 20.0;
                //creates the helix geometry based on the values set in prior function calls
                helix.CreateHelix();
                compBldr.AddToDb(helix);
                compBldr.Commit();
            }
        }
Esempio n. 7
0
        RayHardWired()
        {
            m_db = Utils.Db.GetCurDwg();

            using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) {
                compBldr.Start();
                compBldr.PushXform(Utils.Db.GetUcsMatrix(m_db));

                Point3d  basePoint = new Point3d(0.0, 0.0, 0.0);
                Vector3d unitDir   = new Vector3d(10.0, 10.0, 0.0);

                Ray ray = new Ray();
                ray.BasePoint = basePoint;
                ray.UnitDir   = unitDir;

                compBldr.AddToDb(ray);
                compBldr.Commit();
            }
        }
Esempio n. 8
0
        EllipseHardWired()
        {
            m_db = Utils.Db.GetCurDwg();

            using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) {
                compBldr.Start();
                compBldr.PushXform(Utils.Db.GetUcsMatrix(m_db));

                Point3d center = new Point3d(50.0, 50.0, 0.0);
                // laid out on the XY plane, with normal in Z
                Vector3d uNormal = new Vector3d(0.0, 0.0, 10.0);
                Vector3d majAxis = new Vector3d(10.0, 0.0, 0.0);
                // default values
                double  rRatio     = .5;
                double  startAngle = 0.0;
                double  endAngle   = 6.28318530717958647692;
                Ellipse ellipse    = new Ellipse(center, uNormal, majAxis, rRatio, startAngle, endAngle);
                compBldr.AddToDb(ellipse);
                compBldr.Commit();
            }
        }
Esempio n. 9
0
        Polyline3dHardwired()
        {
            m_db = Utils.Db.GetCurDwg();

            using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) {
                compBldr.Start();
                compBldr.PushXform(Utils.Db.GetUcsMatrix(m_db));

                Point3d[] pts = new Point3d[4];
                pts[0] = new Point3d(0.0, 0.0, 0.0);
                pts[1] = new Point3d(15.0, 0.0, 15.0);
                pts[2] = new Point3d(15.0, 8.0, 15.0);
                pts[3] = new Point3d(0.0, 8.0, 0.0);
                Point3dCollection ptsColl = new Point3dCollection(pts);

                Polyline3d pline3d = new Polyline3d(Poly3dType.SimplePoly, ptsColl, true);
                pline3d.Color = Color.FromRgb(42, 184, 185);

                compBldr.AddToDb(pline3d);
                compBldr.Commit();
            }
        }
Esempio n. 10
0
        SplineHardWired()
        {
            m_db = Utils.Db.GetCurDwg();

            using (CompBldrCurSpace compBldr = new CompBldrCurSpace(m_db)) {
                compBldr.Start();
                compBldr.PushXform(Utils.Db.GetUcsMatrix(m_db));

                Point3dCollection pts = new Point3dCollection();
                pts.Add(new Point3d(0.0, 0.0, 0.0));
                pts.Add(new Point3d(50.0, 50.0, 50.0));
                pts.Add(new Point3d(100.0, 50.0, 100.0));
                pts.Add(new Point3d(150.0, 100.0, 100.0));

                // order of the curve can be between 2 and 26
                int order = 6;
                // determines extent of interpolation through all the points
                double fitTolerance = .5;

                Spline spline = new Spline(pts, order, fitTolerance);
                compBldr.AddToDb(spline);
                compBldr.Commit();
            }
        }