예제 #1
0
        public static Circle CreateCircle(double radius, [NotNull] VisualOption opt)
        {
            var c = new Circle(opt.Position, Vector3d.ZAxis, radius);

            SetEntityOpt(c, opt);
            return(c);
        }
예제 #2
0
        public static void SetEntityOpt([CanBeNull] this Entity ent, VisualOption opt)
        {
            if (ent == null)
            {
                return;
            }
            if (opt.Color != null)
            {
                ent.Color = opt.Color;
            }
            if (opt.Transparency.Alpha != 0)
            {
                ent.Transparency = opt.Transparency;
            }
            if (opt.LineWeight.HasValue)
            {
                ent.LineWeight = opt.LineWeight.Value;
            }
            if (opt.TextHeight.HasValue)
            {
                switch (ent)
                {
                case DBText t:
                    t.Height = opt.TextHeight.Value;
                    break;

                case MText mt:
                    mt.TextHeight = opt.TextHeight.Value;
                    break;
                }
            }
        }
예제 #3
0
        public static Polyline CreatePolyline([NotNull] List <Point2d> points, VisualOption opt)
        {
            var pts = DistincPoints(points);
            var pl  = new Polyline();

            for (var i = 0; i < pts.Length; i++)
            {
                pl.AddVertexAt(i, pts[i], 0, 0, 0);
            }

            pl.Closed = true;
            SetEntityOpt(pl, opt);
            return(pl);
        }
예제 #4
0
        public static MText CreateMText(string text, [NotNull] VisualOption opt, double height, AttachmentPoint justify)
        {
            var mtext = new MText
            {
                Location    = opt.Position,
                TextStyleId = GetTextStyleId(Application.DocumentManager.MdiActiveDocument),
                Attachment  = justify,
                TextHeight  = height,
                Contents    = text,
                Color       = opt.Color
            };

            return(mtext);
        }
예제 #5
0
        public static DBText CreateText(string text, [NotNull] VisualOption opt, double height, AttachmentPoint justify)
        {
            var doc    = Application.DocumentManager.MdiActiveDocument;
            var db     = doc.Database;
            var dbText = new DBText();

            SetEntityOpt(dbText, opt);
            dbText.TextStyleId    = GetTextStyleId(doc);
            dbText.Position       = opt.Position;
            dbText.TextString     = text;
            dbText.Height         = height;
            dbText.Justify        = justify;
            dbText.AlignmentPoint = opt.Position;
            dbText.AdjustAlignment(db);
            return(dbText);
        }
예제 #6
0
        public static Hatch CreateHatch([NotNull] List <Point2d> points, VisualOption opt)
        {
            var pts = DistincPoints(points);

            // Штриховка
            var ptCol = new Point2dCollection(pts)
            {
                points[0]
            };
            var dCol = new DoubleCollection(new double[points.Count]);
            var h    = new Hatch();

            h.SetHatchPattern(HatchPatternType.PreDefined, "SOLID");
            SetEntityOpt(h, opt);
            h.AppendLoop(HatchLoopTypes.Default, ptCol, dCol);
            return(h);
        }