예제 #1
0
        public override void OnDraw(GeometryBuilder dc)
        {
            dc.Clear();

            // Define the basic points for drawing
            Point3d pnt1 = _pnt1;
            Point3d pnt2 = new Point3d(_pnt2.X, pnt1.Y, 0);
            Point3d pnt3 = new Point3d(pnt2.X, pnt1.Y + 150, 0);
            Point3d pnt4 = new Point3d(pnt1.X, pnt3.Y, 0);

            // Set the color to ByObject value
            dc.Color = McDbEntity.ByObject;
            Vector3d hvec = new Vector3d(0, 0, _h);

            // Draw the upper and lower sides
            dc.DrawPolyline(new Point3d[] { pnt1, pnt2, pnt3, pnt4, _pnt1 });
            dc.DrawPolyline(new Point3d[] { _pnt1.Add(hvec),
                                            pnt2.Add(hvec), pnt3.Add(hvec), pnt4.Add(hvec), pnt1.Add(hvec) });

            // Draw the edges
            dc.DrawLine(pnt1, pnt1.Add(hvec));
            dc.DrawLine(pnt2, pnt2.Add(hvec));
            dc.DrawLine(pnt3, pnt3.Add(hvec));
            dc.DrawLine(pnt4, pnt4.Add(hvec));

            // Create contours for the front and rear sides and hatch them
            // In this demo, we hatch only two sides, you can tailor the others yourself
            List <Polyline3d> c1 = new List <Polyline3d>();

            c1.Add(new Polyline3d(
                       new List <Point3d>()
            {
                pnt1, pnt1.Add(hvec), pnt2.Add(hvec), pnt2, pnt1,
            }));
            dc.DrawGeometry(new Hatch(c1, "BRICK", 0, 20, false, HatchStyle.Normal, PatternType.PreDefined, 30), 1);

            List <Polyline3d> c2 = new List <Polyline3d>();

            c2.Add(new Polyline3d(
                       new List <Point3d>()
            {
                pnt4, pnt4.Add(hvec), pnt3.Add(hvec), pnt3, pnt4,
            }));
            dc.DrawGeometry(new Hatch(c2, "BRICK", 0, 20, false, HatchStyle.Normal, PatternType.PreDefined, 30), 1);
        }