Exemplo n.º 1
0
            public override bool WorldDraw(AcGi.Drawable drawable, AcGi.WorldDraw wd)
            {
                var line = drawable as Line;

                if (line != null)
                {
                    //delta,这条直线所代表的三维向量
                    var vec = line.Delta.RotateBy(Math.PI / 2, Vector3d.ZAxis).GetNormal();
                    var pts = new Point3dCollection()
                    {
                        line.StartPoint + vec, line.EndPoint + vec,
                        line.EndPoint - vec, line.StartPoint - vec,
                    };
                    wd.Geometry.Polygon(pts);

                    var hatch = new Hatch();
                    var pts2d = new Point2dCollection();
                    var bulge = new DoubleCollection();

                    foreach (Point3d pt3d in pts)
                    {
                        pts2d.Add(new Point2d(pt3d.X, pt3d.Y));
                        bulge.Add(0);
                    }

                    hatch.AppendLoop(HatchLoopTypes.Default, pts2d, bulge);
                    hatch.SetHatchPattern(HatchPatternType.PreDefined, "ANGLE");

                    hatch.WorldDraw(wd);
                }

                return(base.WorldDraw(drawable, wd));
            }
Exemplo n.º 2
0
        public override bool WorldDraw(AcGi.Drawable drawable, AcGi.WorldDraw wd)
        {
            var wall = drawable as Line;

            if (wall != null)
            {
                var data = DBHelper.GetNODData(CommandJson.AppName, wall.Id.ToString())?.Data?.AsArray();

                var wallParam = JsonConvert.DeserializeObject <Wall>(
                    data[1].Value.ToString()
                    );

                var dir = new Vector2d(wallParam.Dir.X, wallParam.Dir.Y)
                          .GetNormal() * wallParam.Size.H;

                var vertDir = dir.RotateBy(Math.PI / 2)
                              .GetNormal() * wallParam.Size.W * 0.5;

                var startPt = new Point2d(wallParam.Pos.X, wallParam.Pos.Y);
                var endPt   = startPt + dir;

                var poly = new Polyline(4);

                poly.AddVertexAt(poly.NumberOfVertices, startPt + vertDir, 0, 0, 0);
                poly.AddVertexAt(poly.NumberOfVertices, startPt - vertDir, 0, 0, 0);
                poly.AddVertexAt(poly.NumberOfVertices, endPt - vertDir, 0, 0, 0);
                poly.AddVertexAt(poly.NumberOfVertices, endPt + vertDir, 0, 0, 0);
                poly.Closed = true;

                var hatch = new Hatch();

                hatch.SetHatchPattern(HatchPatternType.PreDefined, wallParam.Hatch);
                hatch.PatternAngle = dir.Angle - Math.PI / 2;

                var loop = new HatchLoop(HatchLoopTypes.Polyline);

                for (int i = 0; i < poly.NumberOfVertices; i++)
                {
                    loop.Polyline.Add(new BulgeVertex(poly.GetPoint2dAt(i), poly.GetBulgeAt(i)));
                }

                hatch.AppendLoop(loop);

                poly.WorldDraw(wd);
                hatch.WorldDraw(wd);
            }
            //return base.WorldDraw(drawable, wd);
            return(true);
        }
Exemplo n.º 3
0
            /*重写该方法*/
            public override bool WorldDraw(AcGi.Drawable drawable, AcGi.WorldDraw wd)
            {
                Matrix3d matrix = Matrix3d.Rotation(Math.PI / 2, Vector3d.ZAxis, Point3d.Origin);

                Entity ent1 = drawable as Entity;

                if (ent1.ObjectId != ObjectId.Null)
                {
                    Entity copyEnt = ent1.GetTransformedCopy(matrix);
                    copyEnt.WorldDraw(wd);
                    copyCollection.Add(copyEnt);
                }

                return(base.WorldDraw(drawable, wd));
            }
Exemplo n.º 4
0
        public override bool WorldDraw(AcGi.Drawable drawable, AcGi.WorldDraw wd)
        {
            var donut = drawable as Circle;

            if (donut != null)
            {
                var xdata = donut.GetXData(CommandClass.AppName);
                if (xdata != null && xdata.Length > 0)
                {
                    var outRad    = (double)xdata[0].Value;
                    var outCircle = new Circle(donut.Center, donut.Normal, outRad);
                    outCircle.WorldDraw(wd);

                    var hatch = new Hatch();
                    hatch.SetHatchPattern(HatchPatternType.PreDefined, "BOX");
                    hatch.AppendLoop(HatchLoopTypes.Default, new Curve2dCollection()
                    {
                        new CircularArc2d(new Point2d(donut.Center.X, donut.Center.Y),
                                          donut.Radius),
                    }, new IntegerCollection()
                    {
                        0
                    });
                    hatch.AppendLoop(HatchLoopTypes.Default, new Curve2dCollection()
                    {
                        new CircularArc2d(new Point2d(outCircle.Center.X, outCircle.Center.Y),
                                          outCircle.Radius),
                    }, new IntegerCollection()
                    {
                        0
                    });
                    hatch.WorldDraw(wd);

                    base.WorldDraw(drawable, wd);
                }
            }

            return(false);
        }