コード例 #1
0
ファイル: OneArrow.cs プロジェクト: VB6Hobbyst7/AutoCad-1
            public void Calculate(Point3d destPoint)
            {
                _createPLine(Point3d.Origin);
                _createText();

                if (_destPoint != destPoint)
                {
                    _destPoint = destPoint;
                }

                double ang = Vector3d.YAxis.GetAngle2d(_vector);

                Vector3d vector = destPoint - _position;
                //vector.TransformBy(_ucs.Inverse());

                Matrix3d hMat = Matrix3d.Identity;

                hMat   = hMat.PreMultiplyBy(Matrix3d.Rotation(ang, Vector3d.ZAxis, Point3d.Origin));
                vector = vector.TransformBy(hMat.Inverse());

                if (vector.X < 0)
                {
                    //hMat = hMat.PreMultiplyBy(Matrix3d.Mirroring(new Plane(Point3d.Origin, hMat.CoordinateSystem3d.Yaxis, Matrix3d.Identity.CoordinateSystem3d.Zaxis)));
                    hMat = hMat.PreMultiplyBy(Matrix3d.Mirroring(new Plane(Point3d.Origin, _pline.Normal)));
                }

                _text.TransformBy(hMat);
                _text.AdjustAlignment(HostApplicationServices.WorkingDatabase);
                _pline.TransformBy(hMat);

                _text.TextString = Math.Round(Math.Abs(vector.X) * _unitScale, _digitalCount).ToString(_numFormat);

                //_transformThisBy(_ucs.PostMultiplyBy(Matrix3d.Displacement(_position -_origin)));
                _transformThisBy(Matrix3d.Identity.PostMultiplyBy(Matrix3d.Displacement(_position - Point3d.Origin)));
            }
コード例 #2
0
ファイル: InsCell.cs プロジェクト: vildar82/GP_PIK_Acad
        /// <summary>
        /// Тестовая отрисовка ячейки
        /// </summary>
        public void TestDraw()
        {
            var ext = PtCenter.GetRectangleFromCenter(ModuleSize);
            var pl  = ext.GetPolyline();

            EntityHelper.AddEntityToCurrentSpace(pl);
            EntityHelper.AddEntityToCurrentSpace(new DBPoint(PtCenter.Convert3d()));
            var text = new DBText();

            text.TextString     = $"[{Row};{Column}]";
            text.Height         = 1;
            text.Justify        = AttachmentPoint.MiddleCenter;
            text.AlignmentPoint = PtCenter.Convert3d();
            text.AdjustAlignment(HostApplicationServices.WorkingDatabase);
            EntityHelper.AddEntityToCurrentSpace(text);

            var textIndex = new DBText();

            textIndex.TextString     = Index.ToString();
            textIndex.Height         = 0.25;
            textIndex.Justify        = AttachmentPoint.MiddleCenter;
            textIndex.AlignmentPoint = new Point3d(PtCenter.X, PtCenter.Y - 1.5, 0);
            textIndex.AdjustAlignment(HostApplicationServices.WorkingDatabase);
            EntityHelper.AddEntityToCurrentSpace(textIndex);
        }
コード例 #3
0
        /// <summary>
        /// Вставка артиклов цвета - подписей в плитках (поверх панели в форме)
        /// </summary>
        private void InsertTileArticlesToPanelInForm(ObjectId idBlRefMarkArForm)
        {
            if (!_markAR.Album.StartOptions.IsTileArticle)
            {
                return;
            }

            var blRefPanel = idBlRefMarkArForm.GetObject(OpenMode.ForRead) as BlockReference;
            // трансформация блока панели
            var panelTransform = blRefPanel.BlockTransform;

            var ms = blRefPanel.OwnerId.GetObject(OpenMode.ForWrite) as BlockTableRecord;
            var db = ms.Database;
            var t  = db.TransactionManager.TopTransaction;

            for (int i = 0; i < _markAR.MarkSB.Tiles.Count; i++)
            {
                var tile  = _markAR.MarkSB.Tiles[i];
                var paint = _markAR.Paints[i];
                var ptCenterTileInModel = tile.CenterTile.TransformBy(panelTransform);
                var textArticle         = new DBText();
                textArticle.Justify        = AttachmentPoint.MiddleCenter;
                textArticle.AlignmentPoint = ptCenterTileInModel;
                textArticle.AdjustAlignment(db);
                textArticle.Layer      = "0";
                textArticle.ColorIndex = 7;
                textArticle.TextString = paint.Article;
                textArticle.Height     = 40;
                ms.AppendEntity(textArticle);
                t.AddNewlyCreatedDBObject(textArticle, true);
            }
        }
コード例 #4
0
        public IEnumerable <DBText> CreateElevationLabels(Point3d position, double baseElevation, double comparisonElevation)
        {
            /*var volProps = surface.GetVolumeProperties();
             * ObjectId baseSurfaceId = volProps.BaseSurface;
             * ObjectId comparisonSurfaceId = volProps.ComparisonSurface;*/

            Vector3d yaxis = (this.AmountTopRow[0].Bounds.UpperLeft - this.AmountTopRow[0].Bounds.LowerLeft).Normalize();


            DBText topRightText = new DBText();

            topRightText.SetDatabaseDefaults();
            topRightText.Height         = _grideTextHeight;
            topRightText.Rotation       = 0d;
            topRightText.Position       = Point3d.Origin;
            topRightText.HorizontalMode = TextHorizontalMode.TextLeft;
            topRightText.VerticalMode   = TextVerticalMode.TextBottom;
            topRightText.Annotative     = AnnotativeStates.False;
            //topRightText.AddContext(_scale);
            topRightText.AlignmentPoint = position;
            topRightText.AdjustAlignment(HostApplicationServices.WorkingDatabase);

            topRightText.TextString = comparisonElevation.ToString("#0.00", _culture);


            DBText bottomRightText = new DBText();

            bottomRightText.SetDatabaseDefaults();
            bottomRightText.Height         = _grideTextHeight;
            bottomRightText.Rotation       = 0d;
            bottomRightText.Position       = Point3d.Origin;
            bottomRightText.HorizontalMode = TextHorizontalMode.TextLeft;
            bottomRightText.VerticalMode   = TextVerticalMode.TextTop;
            bottomRightText.Annotative     = AnnotativeStates.False;
            //bottomRightText.AddContext(_scale);
            bottomRightText.AlignmentPoint = position;
            bottomRightText.AdjustAlignment(HostApplicationServices.WorkingDatabase);

            bottomRightText.TextString = baseElevation.ToString("#0.00", _culture);


            DBText topLeftText = new DBText();

            topLeftText.SetDatabaseDefaults();
            topLeftText.Height         = _grideTextHeight;
            topLeftText.Rotation       = 0d;
            topLeftText.Position       = Point3d.Origin;
            topLeftText.HorizontalMode = TextHorizontalMode.TextRight;
            topLeftText.VerticalMode   = TextVerticalMode.TextBottom;
            topLeftText.Annotative     = AnnotativeStates.False;
            //topLeftText.AddContext(_scale);
            topLeftText.AlignmentPoint = position;
            topLeftText.AdjustAlignment(HostApplicationServices.WorkingDatabase);

            topLeftText.TextString = (comparisonElevation - baseElevation).ToString("#0.00", _culture);


            return(new[] { topRightText, bottomRightText, topLeftText });
        }
コード例 #5
0
        public static Rectangle3d?GetTextBoxCorners(this DBText text)
        {
            if (!text.Bounds.HasValue)
            {
                return(null);
            }
            DBText cloneText = (DBText)text.Clone();

            Matrix3d mat = Matrix3d.Identity;

            mat = mat.PreMultiplyBy(Matrix3d.Rotation(-text.Rotation, text.Normal, text.Position));

            cloneText.TransformBy(mat);
            cloneText.AdjustAlignment(Tools.GetAcadDatabase());
            if (!cloneText.Bounds.HasValue)
            {
                return(null);
            }

            Extents3d bounds = cloneText.Bounds.Value;

            Point3d min = bounds.MinPoint;
            Point3d max = bounds.MaxPoint;

#if DEBUG1
            if (min.X >= max.X)
            {
                System.Diagnostics.Debugger.Break();
            }
#endif
            Vector3d diametr = max - min;

            //mat = Matrix3d.Identity.PreMultiplyBy(Matrix3d.Rotation(text.Rotation, text.Normal, text.Position));
            mat = mat.Inverse();

            Point3d upperLeft  = new Point3d(min.X, min.Y + diametr.Y, min.Z).TransformBy(mat);
            Point3d upperRight = max.TransformBy(mat);
            Point3d lowerLeft  = min.TransformBy(mat);
            Point3d lowerRight = new Point3d(max.X, max.Y - diametr.Y, max.Z).TransformBy(mat);

            Rectangle3d rec = new Rectangle3d(upperLeft, upperRight, lowerLeft, lowerRight);

#if DEBUG1
            if (rec.LowerLeft.X >= rec.UpperRight.X)
            {
                System.Diagnostics.Debugger.Break();
            }
#endif

            return(rec);
        }
コード例 #6
0
ファイル: ColorItem.cs プロジェクト: vildar82/AcadLib
        public void Create(Point2d ptCell, [NotNull] BlockTableRecord cs, [NotNull] Transaction t)
        {
            var cellWidth  = ColorBookHelper.CellWidth;
            var cellHeight = ColorBookHelper.CellHeight;
            var margin     = ColorBookHelper.Margin;
            var marginHalf = margin * 0.5;

            var ptText = new Point3d(ptCell.X + cellWidth * 0.5, ptCell.Y - ColorBookHelper.TextHeight - margin, 0);

            var pl = new Polyline(4);

            pl.AddVertexAt(0, new Point2d(ptCell.X + margin, ptText.Y - marginHalf), 0, 0, 0);
            pl.AddVertexAt(1, new Point2d(ptCell.X + cellWidth - margin, ptText.Y - marginHalf), 0, 0, 0);
            pl.AddVertexAt(2, new Point2d(ptCell.X + cellWidth - margin, ptCell.Y - cellHeight + margin), 0, 0, 0);
            pl.AddVertexAt(3, new Point2d(ptCell.X + margin, ptCell.Y - cellHeight + margin), 0, 0, 0);
            pl.Closed = true;
            pl.SetDatabaseDefaults();
            pl.Color = Color;

            cs.AppendEntity(pl);
            t.AddNewlyCreatedDBObject(pl, true);

            var h = new Hatch();

            h.SetDatabaseDefaults();
            h.SetHatchPattern(HatchPatternType.PreDefined, "Solid");
            h.Annotative = AnnotativeStates.False;

            cs.AppendEntity(h);
            t.AddNewlyCreatedDBObject(h, true);

            h.Associative = true;
            h.AppendLoop(HatchLoopTypes.Default, new ObjectIdCollection(new[] { pl.Id }));
            h.Color = Color;
            h.EvaluateHatch(true);

            var text = new DBText();

            text.SetDatabaseDefaults();
            text.HorizontalMode = TextHorizontalMode.TextCenter;
            text.Annotative     = AnnotativeStates.False;
            text.Height         = ColorBookHelper.TextHeight;
            text.AlignmentPoint = ptText;
            text.AdjustAlignment(cs.Database);
            text.TextStyleId = ColorBookHelper.IdTextStylePik;
            text.TextString  = Name;

            cs.AppendEntity(text);
            t.AddNewlyCreatedDBObject(text, true);
        }
コード例 #7
0
ファイル: VisualHelper.cs プロジェクト: vildar82/AcadLib
        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);
        }
コード例 #8
0
ファイル: OneArrow.cs プロジェクト: VB6Hobbyst7/AutoCad-1
            private void _createText()
            {
                DBText hText = new DBText();

                hText.SetDatabaseDefaults(HostApplicationServices.WorkingDatabase);
                hText.Annotative     = AnnotativeStates.False;
                hText.Height         = _textHeight;
                hText.HorizontalMode = TextHorizontalMode.TextCenter;
                hText.VerticalMode   = TextVerticalMode.TextBase;
                hText.Position       = _pline.StartPoint;
                hText.AlignmentPoint = hText.Position.Add(_pline.GetFirstDerivative(0).Normalize().MultiplyBy(_length / 2d));
                hText.AlignmentPoint = hText.AlignmentPoint.Add(_pline.GetFirstDerivative(0).GetPerpendicularVector().MultiplyBy(hText.Height * 0.1));

                _text = hText;
                _text.AdjustAlignment(HostApplicationServices.WorkingDatabase);
            }
コード例 #9
0
        private void addText(double level, Point3d pt)
        {
            DBText text = new DBText();

            text.SetDatabaseDefaults();
            text.TextString     = level.ToString();
            text.Height         = ed.GetCurrentView().Height *HorizontalElevationOptions.Instance.TextHeight;
            text.ColorIndex     = 11;//Color.FromColor(HorizontalElevationOptions.Instance.TextColor);
            text.Position       = pt;
            text.Justify        = AttachmentPoint.MiddleCenter;
            text.AlignmentPoint = pt;
            text.AdjustAlignment(db);

            tm.AddTransient(text, TransientDrawingMode.Main, 0, new IntegerCollection());
            tempTexts.Add(text);
        }
コード例 #10
0
ファイル: ColorItem.cs プロジェクト: vildar82/AcadLib
        public void Create(Point2d ptCell, BlockTableRecord cs, Transaction t)
        {
            var cellWidth = ColorBookHelper.CellWidth;
            var cellHeight = ColorBookHelper.CellHeight;
            var margin = ColorBookHelper.Margin;
            var marginHalf = margin * 0.5;

            Point3d ptText = new Point3d(ptCell.X + cellWidth * 0.5, ptCell.Y - ColorBookHelper.TextHeight-margin, 0);

            Polyline pl = new Polyline(4);
            pl.AddVertexAt(0, new Point2d(ptCell.X+margin, ptText.Y- marginHalf), 0, 0, 0);
            pl.AddVertexAt(1, new Point2d(ptCell.X+cellWidth- margin, ptText.Y- marginHalf), 0, 0, 0);
            pl.AddVertexAt(2, new Point2d(ptCell.X + cellWidth-margin, ptCell.Y-cellHeight+margin), 0, 0, 0);
            pl.AddVertexAt(3, new Point2d(ptCell.X+margin, ptCell.Y - cellHeight+margin), 0, 0, 0);
            pl.Closed = true;
            pl.SetDatabaseDefaults();
            pl.Color = Color;

            cs.AppendEntity(pl);
            t.AddNewlyCreatedDBObject(pl, true);

            Hatch h = new Hatch();
            h.SetDatabaseDefaults();
            h.SetHatchPattern(HatchPatternType.PreDefined, "Solid");
            h.Annotative = AnnotativeStates.False;

            cs.AppendEntity(h);
            t.AddNewlyCreatedDBObject(h, true);

            h.Associative = true;
            h.AppendLoop(HatchLoopTypes.Default, new ObjectIdCollection(new[] { pl.Id }));
            h.Color = Color;
            h.EvaluateHatch(true);

            DBText text = new DBText();
            text.SetDatabaseDefaults();
            text.HorizontalMode = TextHorizontalMode.TextCenter;
            text.Annotative = AnnotativeStates.False;
            text.Height = ColorBookHelper.TextHeight;
            text.AlignmentPoint = ptText;
            text.AdjustAlignment(cs.Database);
            text.TextStyleId = ColorBookHelper.IdTextStylePik;
            text.TextString = Name;

            cs.AppendEntity(text);
            t.AddNewlyCreatedDBObject(text, true);
        }
コード例 #11
0
        private DBText _createDBText(Point3d alignmentPoint, double height)
        {
            ObjectContextManager    ocm   = HostApplicationServices.WorkingDatabase.ObjectContextManager;
            ObjectContextCollection occ   = ocm.GetContextCollection("ACDB_ANNOTATIONSCALES");
            AnnotationScale         scale = (AnnotationScale)occ.CurrentContext;

            DBText text = new DBText();

            text.SetDatabaseDefaults();
            text.Height         = height; /* * scale.DrawingUnits/ scale.PaperUnits;*/
            text.Annotative     = AnnotativeStates.False;
            text.Rotation       = _textRotation;
            text.Position       = Point3d.Origin;
            text.HorizontalMode = TextHorizontalMode.TextMid;
            text.VerticalMode   = TextVerticalMode.TextVerticalMid;
            text.AlignmentPoint = alignmentPoint;
            //text.AddContext(occ.CurrentContext);
            text.AdjustAlignment(HostApplicationServices.WorkingDatabase);

            return(text);
        }
コード例 #12
0
        public static Extents3d?GetNotRotatedBounds(this DBText text)
        {
            if (!text.Bounds.HasValue)
            {
                return(null);
            }
            DBText cloneText = (DBText)text.Clone();

            Matrix3d mat = Matrix3d.Identity;

            mat = mat.PreMultiplyBy(Matrix3d.Rotation(-text.Rotation, text.Normal, text.Position));

            cloneText.TransformBy(mat);
            cloneText.AdjustAlignment(Tools.GetAcadDatabase());
            if (!cloneText.Bounds.HasValue)
            {
                return(null);
            }

            Extents3d bounds = cloneText.Bounds.Value;

            return(bounds);
        }
コード例 #13
0
        private static DBText addText(BlockTableRecord btr, Transaction t, Point3d pt, string value, double height,
                                      TextHorizontalMode horMode = TextHorizontalMode.TextCenter)
        {
            // Подпись развертки - номер вида
            DBText text = new DBText();

            text.SetDatabaseDefaults();
            text.Height      = height;
            text.TextStyleId = IdTextStylePik;
            text.TextString  = value;
            if (horMode == TextHorizontalMode.TextLeft)
            {
                text.Position = pt;
            }
            else
            {
                text.HorizontalMode = horMode;
                text.AlignmentPoint = pt;
                text.AdjustAlignment(btr.Database);
            }
            btr.AppendEntity(text);
            t.AddNewlyCreatedDBObject(text, true);
            return(text);
        }
コード例 #14
0
        public IEnumerable <DBText> CreateVolumeLabels(Rectangle3d rectg, Autodesk.Civil.DatabaseServices.TinVolumeSurface surface)
        {
            List <DBText> res           = new List <DBText>();
            Point3d       topPosition   = Point3d.Origin;
            Vector3d      centralVector = rectg.UpperRight - rectg.LowerLeft;

            topPosition = rectg.LowerLeft.Add(centralVector.MultiplyBy(0.5d));
            Point3d bottomPosition = topPosition;

            Autodesk.Civil.DatabaseServices.SurfaceVolumeInfo volumeInfo = new civil.DatabaseServices.SurfaceVolumeInfo();
            try
            {
                volumeInfo = surface.GetBoundedVolumes(rectg.GetPoints(true));
            }
            catch (ArgumentException)
            {
                return(null);
            }
            if (Math.Round(volumeInfo.Fill, 1) > 0d &&
                Math.Round(volumeInfo.Cut, 1) > 0d)
            {
                Vector3d yaxis = rectg.GetLeftVerticalVector().Normalize();
                Matrix3d mat   = Matrix3d.Displacement(yaxis.MultiplyBy(_volumeTextHeight * 0.7));
                topPosition    = topPosition.TransformBy(mat);
                bottomPosition = bottomPosition.TransformBy(mat.Inverse());
            }

            if (Math.Round(volumeInfo.Fill, 1) > 0d)
            {
                DBText topText = new DBText();
                topText.SetDatabaseDefaults();
                topText.Height         = _volumeTextHeight;
                topText.Rotation       = 0d;
                topText.Position       = Point3d.Origin;
                topText.HorizontalMode = TextHorizontalMode.TextCenter;
                topText.VerticalMode   = TextVerticalMode.TextVerticalMid;
                topText.Annotative     = AnnotativeStates.False;
                //topText.AddContext(_scale);
                topText.AlignmentPoint = topPosition;
                topText.AdjustAlignment(HostApplicationServices.WorkingDatabase);

                topText.TextString = '+' + Math.Round(volumeInfo.Fill).ToString("#0.0", _culture);
                res.Add(topText);
            }
            else
            {
                res.Add(null);
            }

            if (Math.Round(volumeInfo.Cut, 1) > 0d)
            {
                DBText bottomText = new DBText();
                bottomText.SetDatabaseDefaults();
                bottomText.Height         = _volumeTextHeight;
                bottomText.Rotation       = 0d;
                bottomText.Position       = Point3d.Origin;
                bottomText.HorizontalMode = TextHorizontalMode.TextCenter;
                bottomText.VerticalMode   = TextVerticalMode.TextVerticalMid;
                bottomText.Annotative     = AnnotativeStates.False;
                //bottomText.AddContext(_scale);
                bottomText.AlignmentPoint = bottomPosition;;
                bottomText.AdjustAlignment(HostApplicationServices.WorkingDatabase);

                bottomText.TextString = Math.Round(-volumeInfo.Cut, 1).ToString("#0.0", _culture);
                res.Add(bottomText);
            }
            else
            {
                res.Add(null);
            }

            if (Math.Round(volumeInfo.Fill, 1) == 0d &&
                Math.Round(volumeInfo.Cut, 1) == 0d)
            {
                DBText centralText = new DBText();
                centralText.SetDatabaseDefaults();
                centralText.Height         = _volumeTextHeight;
                centralText.Rotation       = 0d;
                centralText.Position       = Point3d.Origin;
                centralText.HorizontalMode = TextHorizontalMode.TextCenter;
                centralText.VerticalMode   = TextVerticalMode.TextVerticalMid;
                centralText.Annotative     = AnnotativeStates.False;
                //topText.AddContext(_scale);
                centralText.AlignmentPoint = topPosition;
                centralText.AdjustAlignment(HostApplicationServices.WorkingDatabase);

                centralText.TextString = Math.Round(volumeInfo.Fill).ToString("#0.0", _culture);
                res.Add(centralText);
            }

            return(res);
        }
コード例 #15
0
ファイル: AcadEntity.cs プロジェクト: tevfikoguz/XCOM
        public static DBText CreateText(Database db, Point3d pt, string text, double textHeight, double rotation, double widthFactor, TextHorizontalMode horizontalMode, TextVerticalMode verticalMode, ObjectId textStyleId, ObjectId layerId)
        {
            using (CurrentDB curr = new CurrentDB(db))
            {
                DBText dbtext = new DBText();
                dbtext.SetDatabaseDefaults(db);

                dbtext.TextString = text;
                dbtext.Position   = pt;

                dbtext.Height      = textHeight;
                dbtext.Rotation    = rotation;
                dbtext.WidthFactor = widthFactor;

                if (horizontalMode == TextHorizontalMode.TextLeft)
                {
                    if (verticalMode == TextVerticalMode.TextTop)
                    {
                        dbtext.Justify = AttachmentPoint.TopLeft;
                    }
                    else if (verticalMode == TextVerticalMode.TextBase)
                    {
                        dbtext.Justify = AttachmentPoint.BaseLeft;
                    }
                    else if (verticalMode == TextVerticalMode.TextBottom)
                    {
                        dbtext.Justify = AttachmentPoint.BottomLeft;
                    }
                    else
                    {
                        dbtext.Justify = AttachmentPoint.MiddleLeft;
                    }
                }
                else if (horizontalMode == TextHorizontalMode.TextRight)
                {
                    if (verticalMode == TextVerticalMode.TextTop)
                    {
                        dbtext.Justify = AttachmentPoint.TopRight;
                    }
                    else if (verticalMode == TextVerticalMode.TextBase)
                    {
                        dbtext.Justify = AttachmentPoint.BaseRight;
                    }
                    else if (verticalMode == TextVerticalMode.TextBottom)
                    {
                        dbtext.Justify = AttachmentPoint.BottomRight;
                    }
                    else
                    {
                        dbtext.Justify = AttachmentPoint.MiddleRight;
                    }
                }
                else if (horizontalMode == TextHorizontalMode.TextMid || horizontalMode == TextHorizontalMode.TextCenter)
                {
                    if (verticalMode == TextVerticalMode.TextTop)
                    {
                        dbtext.Justify = AttachmentPoint.TopCenter;
                    }
                    else if (verticalMode == TextVerticalMode.TextBase)
                    {
                        dbtext.Justify = AttachmentPoint.BaseCenter;
                    }
                    else if (verticalMode == TextVerticalMode.TextBottom)
                    {
                        dbtext.Justify = AttachmentPoint.BottomCenter;
                    }
                    else
                    {
                        dbtext.Justify = AttachmentPoint.MiddleCenter;
                    }
                }
                else if (horizontalMode == TextHorizontalMode.TextAlign)
                {
                    if (verticalMode == TextVerticalMode.TextTop)
                    {
                        dbtext.Justify = AttachmentPoint.TopAlign;
                    }
                    else if (verticalMode == TextVerticalMode.TextBase)
                    {
                        dbtext.Justify = AttachmentPoint.BaseAlign;
                    }
                    else if (verticalMode == TextVerticalMode.TextBottom)
                    {
                        dbtext.Justify = AttachmentPoint.BottomAlign;
                    }
                    else
                    {
                        dbtext.Justify = AttachmentPoint.MiddleAlign;
                    }
                }
                else if (horizontalMode == TextHorizontalMode.TextFit)
                {
                    if (verticalMode == TextVerticalMode.TextTop)
                    {
                        dbtext.Justify = AttachmentPoint.TopFit;
                    }
                    else if (verticalMode == TextVerticalMode.TextBase)
                    {
                        dbtext.Justify = AttachmentPoint.BaseFit;
                    }
                    else if (verticalMode == TextVerticalMode.TextBottom)
                    {
                        dbtext.Justify = AttachmentPoint.BottomFit;
                    }
                    else
                    {
                        dbtext.Justify = AttachmentPoint.MiddleFit;
                    }
                }

                if (horizontalMode != TextHorizontalMode.TextLeft || verticalMode != TextVerticalMode.TextBase)
                {
                    dbtext.AlignmentPoint = pt;
                    dbtext.AdjustAlignment(db);
                }

                if (!textStyleId.IsNull)
                {
                    dbtext.TextStyleId = textStyleId;
                }

                if (!layerId.IsNull)
                {
                    dbtext.LayerId = layerId;
                }

                return(dbtext);
            }
        }
コード例 #16
0
 private static DBText addText(BlockTableRecord btr, Transaction t, Point3d pt, string value, double height,
     TextHorizontalMode horMode = TextHorizontalMode.TextCenter)
 {
     // Подпись развертки - номер вида
     DBText text = new DBText();
     text.SetDatabaseDefaults();
     text.Height = height;
     text.TextStyleId = IdTextStylePik;
     text.TextString = value;
     if (horMode == TextHorizontalMode.TextLeft)
     {
         text.Position = pt;
     }
     else
     {
         text.HorizontalMode = horMode;
         text.AlignmentPoint = pt;
         text.AdjustAlignment(btr.Database);
     }
     btr.AppendEntity(text);
     t.AddNewlyCreatedDBObject(text, true);
     return text;
 }
コード例 #17
0
        private IEnumerable <Entity> _createAttrute(Point3d alignmentPoint, string prefix, Matrix3d transform)
        {
            alignmentPoint = alignmentPoint.TransformBy(Matrix3d.Displacement(transform.CoordinateSystem3d.Yaxis.MultiplyBy(2.0d * 0.2)));

            AttributeDefinition ad = new AttributeDefinition();

            ad.SetDatabaseDefaults(Tools.GetAcadDatabase());
            ad.Verifiable     = true;
            ad.Tag            = "отклонение_" + prefix;
            ad.TextString     = "12";
            ad.Annotative     = AnnotativeStates.False;
            ad.Height         = 2.0d;
            ad.HorizontalMode = TextHorizontalMode.TextLeft;
            ad.VerticalMode   = TextVerticalMode.TextBottom;
            ad.Position       = Point3d.Origin;
            ad.TransformBy(transform);
            ad.Position       = alignmentPoint;
            ad.AlignmentPoint = alignmentPoint;
            ad.AdjustAlignment(Tools.GetAcadDatabase());

            DBText adPrefix = new DBText();

            adPrefix.SetDatabaseDefaults(Tools.GetAcadDatabase());
            adPrefix.TextString     = prefix;
            adPrefix.Height         = 2.0d;
            adPrefix.Annotative     = AnnotativeStates.False;
            adPrefix.HorizontalMode = TextHorizontalMode.TextRight;
            adPrefix.VerticalMode   = TextVerticalMode.TextBottom;
            adPrefix.Position       = Point3d.Origin;
            adPrefix.TransformBy(transform);
            adPrefix.AlignmentPoint = alignmentPoint;
            adPrefix.AdjustAlignment(Tools.GetAcadDatabase());

            Rectangle3d?rectg = adPrefix.GetTextBoxCorners();
            Polyline    bound = new Polyline(5);

            bound.AddVertexAt(0, rectg.Value.LowerLeft.Add((rectg.Value.UpperLeft - rectg.Value.LowerLeft).Normalize().Negate().MultiplyBy(adPrefix.Height * 0.1)));
            bound.AddVertexAt(1, rectg.Value.UpperLeft.Add((rectg.Value.UpperLeft - rectg.Value.LowerLeft).Normalize().MultiplyBy(adPrefix.Height * 0.1)));
            bound.AddVertexAt(2, rectg.Value.UpperRight.Add((rectg.Value.UpperRight - rectg.Value.LowerRight).Normalize().MultiplyBy(adPrefix.Height * 0.1)));
            bound.AddVertexAt(3, rectg.Value.LowerRight.Add((rectg.Value.UpperRight - rectg.Value.LowerRight).Normalize().Negate().MultiplyBy(adPrefix.Height * 0.1)));
            bound.AddVertexAt(4, rectg.Value.LowerLeft.Add((rectg.Value.UpperLeft - rectg.Value.LowerLeft).Normalize().Negate().MultiplyBy(adPrefix.Height * 0.1)));

            Vector3d vector = rectg.Value.LowerRight - rectg.Value.LowerLeft;

            if (!transform.CoordinateSystem3d.Xaxis.IsCodirectionalTo(vector))
            {
                Plane    plane = new Plane(alignmentPoint, transform.CoordinateSystem3d.Yaxis, transform.CoordinateSystem3d.Zaxis);
                Matrix3d mat   = Matrix3d.Mirroring(plane);
                ad.TransformBy(mat);
                ad.AdjustAlignment(Tools.GetAcadDatabase());
                adPrefix.TransformBy(mat);
                adPrefix.AdjustAlignment(Tools.GetAcadDatabase());
                bound.TransformBy(mat);
            }

            yield return(ad);

            yield return(adPrefix);

            yield return(bound);
        }
コード例 #18
0
ファイル: JigText.cs プロジェクト: 15831944/EM
        protected override bool Update()
        {
            // Set properties on our text object
            DBText txt = (DBText)Entity;

            txt.Position       = _position;
            txt.Height         = _txtSize;
            txt.Rotation       = _angle;
            txt.HorizontalMode = _align;
            if (_align != TextHorizontalMode.TextLeft)
            {
                txt.AlignmentPoint = _position;
                txt.AdjustAlignment(_db);
            }

            // Set the bold and/or italic properties on the style

            if (_toggleBold || _toggleItalic)
            {
                TextStyleTable tab =
                    (TextStyleTable)_tr.GetObject(
                        _db.TextStyleTableId, OpenMode.ForRead);

                TextStyleTableRecord style =
                    (TextStyleTableRecord)_tr.GetObject(
                        txt.TextStyleId, OpenMode.ForRead);

                // A bit convoluted, but this check will tell us whether the new style is bold/italic

                bool bold   = !(style.Font.Bold == _toggleBold);
                bool italic = !(style.Font.Italic == _toggleItalic);
                _toggleBold   = false;
                _toggleItalic = false;

                // Get the new style name based on the old name and
                // a suffix ("_BOLD", "_ITALIC" or "_BOLDITALIC")

                var oldName = style.Name.Split(new[] {
                    '_'
                });
                string newName =
                    string.Format("{0}{1}", oldName[0], bold || italic ? string.Format("_{0}{1}", bold ? "BOLD" : "", italic ? "ITALIC" : "") : "");

                // We only create a duplicate style if one doesn't already exist

                if (tab.Has(newName))
                {
                    txt.TextStyleId = tab[newName];
                }
                else
                {
                    // We have to create a new style - clone the old one
                    TextStyleTableRecord newStyle =
                        (TextStyleTableRecord)style.Clone();

                    // Set a new name to avoid duplicate keys

                    newStyle.Name = newName;

                    // Create a new font based on the old one, but with our values for bold & italic

                    FontDescriptor oldFont = style.Font;
                    FontDescriptor newFont =
                        new FontDescriptor(
                            oldFont.TypeFace, bold, italic,
                            oldFont.CharacterSet, oldFont.PitchAndFamily);

                    // Set it on the style

                    newStyle.Font = newFont;

                    // Add the new style to the text style table and
                    // the transaction

                    tab.UpgradeOpen();
                    ObjectId styleId = tab.Add(newStyle);
                    _tr.AddNewlyCreatedDBObject(newStyle, true);

                    // And finally set the new style on our text object

                    txt.TextStyleId = styleId;
                }
            }

            return(true);
        }