Esempio n. 1
1
        public void AdskGreeting()
        {
            // Get the current document and database
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            // Start a transaction
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // Open the current text style for write
                TextStyleTableRecord acTextStyleTblRec;
                acTextStyleTblRec = acTrans.GetObject(acCurDb.Textstyle,OpenMode.ForWrite) as TextStyleTableRecord;

                // Get the current font settings
                Autodesk.AutoCAD.GraphicsInterface.FontDescriptor acFont;
                acFont = acTextStyleTblRec.Font;

                // Update the text style's typeface with "PlayBill"
                Autodesk.AutoCAD.GraphicsInterface.FontDescriptor acNewFont;
                acNewFont = new Autodesk.AutoCAD.GraphicsInterface.FontDescriptor("GOST type A", false,
                                                                    acFont.Italic,acFont.CharacterSet,
                                                                    acFont.PitchAndFamily);
                acTextStyleTblRec.Font = acNewFont;
                acDoc.Editor.Regen();

                // Open the Block table record for read
                BlockTable acBlkTbl;
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,OpenMode.ForRead) as BlockTable;
                // Open the Block table record Model space for write
                BlockTableRecord acBlkTblRec;
                acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],OpenMode.ForWrite) as BlockTableRecord;
                /* Creates a new MText object and assigns it a location,text value and text style */
                MText objText = new MText();
                // Set the default properties for the MText object
                objText.SetDatabaseDefaults();
                objText.Location = new Autodesk.AutoCAD.Geometry.Point3d(2, 2, 0);
                objText.Contents = "Greetings, Welcome to the AutoCAD .NET Developer's Guide";
                // Set the text style for the MText object
                objText.TextStyleId =  acCurDb.Textstyle;
                // Appends the new MText object to model space
                acBlkTblRec.AppendEntity(objText);
                // Appends to new MText object to the active transaction
                acTrans.AddNewlyCreatedDBObject(objText, true);

                // Save the changes and dispose of the transaction
                acTrans.Commit();
            }
        }
Esempio n. 2
0
File: Txt.cs Progetto: 15831944/EM
        updateMText(this ObjectId id, string value, string format = "")
        {
            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    MText  mTxt         = (MText)tr.GetObject(id, OpenMode.ForWrite);
                    string mTxtContents = mTxt.Contents;
                    string mTxtText     = mTxt.Text;

                    if (format == "")
                    {
                        mTxtContents = mTxtContents.Replace(mTxtText, value);
                    }
                    else
                    {
                        mTxtContents = string.Format("{0}{1}}", format, value);
                    }

                    mTxt.Contents = mTxtContents;

                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Txt.cs: line: 742");
            }
        }
Esempio n. 3
0
File: Txt.cs Progetto: 15831944/EM
        setMTextWidth(ObjectId objID, bool Left_Justify, out Point3d pnt3dLoc)
        {
            double dblWidth = 0;

            pnt3dLoc = Pub.pnt3dO;
            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    MText mTxt = (MText)tr.GetObject(objID, OpenMode.ForWrite);
                    dblWidth = mTxt.ActualWidth;
                    Point3d pnt3d = mTxt.Location;
                    if (Left_Justify == true)
                    {
                        pnt3dLoc = Base_Tools45.Math.traverse(pnt3d, mTxt.Rotation, dblWidth / 2 + mTxt.ActualHeight * 0.1);
                    }
                    else
                    {
                        pnt3dLoc = Base_Tools45.Math.traverse(pnt3d, mTxt.Rotation - PI, dblWidth / 2 + mTxt.ActualHeight * 0.1);
                    }

                    mTxt.Location = pnt3d;
                    mTxt.Width    = dblWidth;
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Txt.cs: line: 655");
            }

            return(dblWidth);
        }
Esempio n. 4
0
File: Txt.cs Progetto: 15831944/EM
        handleToMText(Handle handle)
        {
            MText    mTxt = null;
            Database DB   = BaseObjs._db;

            string   strHandle = handle.ToString();
            long     ln        = System.Convert.ToInt64(strHandle, 16);
            Handle   han       = new Handle(ln);
            ObjectId objID     = DB.GetObjectId(false, han, 0);

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    Autodesk.AutoCAD.DatabaseServices.DBObject dbObj = objID.GetObject(OpenMode.ForRead);

                    tr.Commit();
                    mTxt = (MText)dbObj;
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Txt.cs: line: 497");
            }
            return(mTxt);
        }
        /// <summary>
        /// 按照距离绘制分段线并依据用户选择进行跨度标注
        /// </summary>
        /// <param name="pline">多段线</param>
        /// <param name="startPt">起点</param>
        /// <param name="dists">沿曲线长度组成的List</param>
        /// <param name="yOrN">是否标注跨度</param>
        /// <param name="scale">标注比例</param>
        private void CreateSpanLines(Polyline pline, Point3d startPt, List <double> dists, string yOrN, double scale)
        {
            Database db      = pline.Database;
            double   distCum = pline.GetDistAtPoint(startPt);//startPoint到曲线起点的长度
            double   len     = 10 * scale;

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                foreach (double dist in dists)
                {
                    distCum += dist;                                    //累积距离前进
                    Point3d  destPt = pline.GetPointAtDist(distCum);
                    Vector3d drvt   = pline.GetFirstDerivative(destPt); //获取切线
                    Point3d  pt1    = destPt + len / 2 * drvt.GetUnitVector().RotateBy(Math.PI / 2, Vector3d.ZAxis);
                    Point3d  pt2    = destPt - len / 2 * drvt.GetUnitVector().RotateBy(Math.PI / 2, Vector3d.ZAxis);
                    Line     line   = new Line(pt1, pt2); //绘制分段线
                    db.AddToModelSpace(line);
                    if (yOrN == "Y")                      //如果选择标注沿曲线长度
                    {
                        //在分段线旁标注距离
                        MText txt = new MText();
                        txt.SetTextStyle(
                            contents: dist.ToString("F3"),
                            textHeight: 3 * scale,
                            textStyleId: db.Textstyle,
                            attachment: AttachmentPoint.BottomCenter,
                            rotation: drvt.GetAngleTo(Vector3d.XAxis),
                            location: pline.GetPointAtDist(distCum - dist / 2) + 2 * scale * drvt.GetUnitVector().RotateBy(Math.PI / 2, Vector3d.ZAxis)
                            );
                        db.AddToModelSpace(txt);
                    }
                }
                trans.Commit();
            }
        }
Esempio n. 6
0
        private static void GetStrings(Database db, ObjectId layout)
        {
            List <string> textInDwg = new List <string>();

            using (db)
            {
                try
                {
                    using (Transaction tr = db.TransactionManager.StartTransaction())
                    {
                        BlockTableRecord btr = tr.GetObject(layout, OpenMode.ForRead) as BlockTableRecord;
                        foreach (ObjectId entId in btr)
                        {
                            Entity ent = tr.GetObject(entId, OpenMode.ForRead) as Entity;
                            if (ent != null)
                            {
                                MText mtext = ent as MText;
                                if (mtext != null)
                                {
                                    textInDwg.Add(mtext.Text);
                                }
                            }
                        }
                    }
                }
                catch
                {
                }
            }
        }
Esempio n. 7
0
        public Entity DynToStaticEntity(Entity entity)
        {
            MText text = entity as MText;

            if (text != null)
            {
                if (text.HasFields)
                {
                    text.ConvertFieldToText();
                }
                text.Contents = text.Text;
            }
            else
            {
                DBText dbText = entity as DBText;
                if (dbText != null)
                {
                    if (dbText.HasFields)
                    {
                        dbText.ConvertFieldToText();
                    }
                }
            }
            return(entity);
        }
Esempio n. 8
0
 protected override void AddTrailingCodePairs(List <DxfCodePair> pairs, DxfAcadVersion version, bool outputHandles)
 {
     if (MText != null)
     {
         pairs.AddRange(MText.GetValuePairs(version, outputHandles));
     }
 }
Esempio n. 9
0
        public void AddMLeader()
        {
            Database db = HostApplicationServices.WorkingDatabase;

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                //创建3个点,分别表示引线的终点和两个头点
                Point3d ptEnd = new Point3d(90, 0, 0);
                Point3d pt1   = new Point3d(80, 20, 0);
                Point3d pt2   = new Point3d(100, 20, 0);
                MText   mtext = new MText
                {
                    Contents = "多重引线示例"          //文本内容
                };                               //新建多行文本
                MLeader mleader = new MLeader(); //创建多重引线
                //为多重引线添加引线束,引线束由基线和一些单引线构成
                int leaderIndex = mleader.AddLeader();
                //在引线束中添加一单引线
                int lineIndex = mleader.AddLeaderLine(leaderIndex);
                mleader.AddFirstVertex(lineIndex, pt1);  //在单引线中添加引线头点

                mleader.AddLastVertex(lineIndex, ptEnd); //在单引线中添加引线终点
                //在引线束中再添加一单引线,并只设置引线头点
                lineIndex = mleader.AddLeaderLine(leaderIndex);
                mleader.AddFirstVertex(lineIndex, pt2);
                //设置多重引线的注释为多行文本
                mleader.ContentType = ContentType.MTextContent;
                mleader.MText       = mtext;
                //将多重引线添加到模型空间
                db.AddToModelSpace(mleader);
                trans.Commit();
            }
        }
Esempio n. 10
0
        public void PlaceGridElevationText()
        {
            MText mText = new MText()
            {
                TextHeight = 2.5,
                Location   = new Point3d(InsertionPoint.X - 5, InsertionPoint.Y, InsertionPoint.Y),
                Contents   = "00"
            };

            for (int i = 0; i <= HorizontalLineCount / 5; i++)
            {
                MText mt = (MText)mText.Clone();
                mt.Contents = (i * 5).ToString();
                mt.Location = new Point3d(mText.Location.X, mText.Location.Y + (VerticalScale * i * 5), mText.Location.Z);
                ProfileGridDBOjbects.Add(mt);
            }

            MText mTextEnd = (MText)mText.Clone();

            mTextEnd.Location = new Point3d(InsertionPoint.X + (GridLength + 5), InsertionPoint.Y, InsertionPoint.Z);

            for (int i = 0; i <= HorizontalLineCount / 5; i++)
            {
                MText mt = (MText)mTextEnd.Clone();
                mt.Contents = (i * 5).ToString();
                mt.Location = new Point3d(mTextEnd.Location.X, mTextEnd.Location.Y + (VerticalScale * i * 5), mTextEnd.Location.Z);
                ProfileGridDBOjbects.Add(mt);
            }
        }
        public static void ChangeName(Document doc, string layerName)
        {
            Database           db  = doc.Database;
            ObjectIdCollection ids = Selection.SelectNameText(doc, layerName);

            // Start a transaction
            using (Transaction acTrans = db.TransactionManager.StartTransaction())
            {
                foreach (ObjectId id in ids)
                {
                    Entity acEnt = acTrans.GetObject(id, OpenMode.ForWrite) as Entity;

                    MText dm = acEnt as MText;
                    if (dm != null)
                    {
                        dm.Contents = layerName;
                    }
                    else
                    {
                    }
                }

                // Save the new object to the database
                acTrans.Commit();
            }

            //Dispose of the transaction
        }
Esempio n. 12
0
        public void AddLeader()
        {
            Database db = HostApplicationServices.WorkingDatabase;

            using (var trans = db.TransactionManager.StartTransaction())
            {
                //创建一个在原点直径为0.219的圆。
                Circle circle = new Circle();
                circle.Center   = Point3d.Origin;
                circle.Diameter = 0.219;
                //创建一个多行文本并设置其内容为4Xφd±0.005(其中d为圆的直径)
                MText txt = new MText();
                txt.Contents   = "4X" + TextSpecialSymbol.Diameter + circle.Diameter + TextSpecialSymbol.Tolerance + "0.005";
                txt.Location   = new Point3d(1, 1, 0); //文本位置
                txt.TextHeight = 0.2;                  //文本高度
                db.AddToModelSpace(circle, txt);       //将圆和文本添加到模型空间中
                Leader leader = new Leader();          //创建一个引线对象
                //将圆上一点及文本位置作为引线的顶点
                leader.AppendVertex(circle.Center.PolarPoint(Math.PI / 3, circle.Radius));
                leader.AppendVertex(txt.Location);
                db.AddToModelSpace(leader);       //将引线添加到模型空间中
                leader.Dimgap     = 0.1;          //设置引线的文字偏移为0.1
                leader.Dimasz     = 0.1;          //设置引线的箭头大小为0.1
                leader.Annotation = txt.ObjectId; //设置引线的注释对象为文本
                leader.EvaluateLeader();          //计算引线及其关联注释之间的关系
                trans.Commit();                   //提交更改
            }
        }
Esempio n. 13
0
        moveDimPL2(MText mText = null)
        {
            ObjectId idMtxt = ObjectId.Null;

            TypedValue[] tvsTX = null;

            if (mText != null)
            {
                idMtxt = mText.ObjectId;
                tvsTX  = idMtxt.getXData(apps.lnkDimPL).AsArray();
            }
            else
            {
                Editor ed = BaseObjs._editor;
                PromptEntityOptions ppo = new PromptEntityOptions("Select Text to Move: ");
                PromptEntityResult  per = ed.GetEntity(ppo);

                ObjectId id = per.ObjectId;
                if (id is MText)
                {
                    tvsTX = id.getXData(apps.lnkDimPL).AsArray();
                    if (tvsTX == null)
                    {
                        return;
                    }
                    idMtxt = id;
                }
            }
            PromptStatus ps     = PromptStatus.Cancel;
            Point3d      pnt3dX = UserInput.getPoint("Pick desired location for text: ", out ps, osMode: 0);

            modTXlnkDimPl(idMtxt, tvsTX, pnt3dX);
        }
Esempio n. 14
0
        /// <summary>
        /// Creates an MText
        /// </summary>
        /// <param name="pt1">Point of origin</param>
        /// <param name="textVal">Contents of the Mtxt</param>
        /// <param name="layerName"></param>
        /// <param name="colour"></param>
        /// <returns></returns>
        public static Tuple <double, double> DrawText(Point2d pt1, double textHeight, double textWidth, string textVal, string layerName, short colour = 255)
        {
            Tuple <double, double> actualHnW;
            Document doc       = Application.DocumentManager.MdiActiveDocument;
            Database currentDB = doc.Database;

            CreateLayer(layerName, colour);
            Entity entCreated;
            double actualHeight = 0;

            using (Transaction tr = currentDB.TransactionManager.StartTransaction())
            {
                BlockTable       blckTable     = tr.GetObject(currentDB.BlockTableId, OpenMode.ForRead) as BlockTable;
                BlockTableRecord blockTableRec = tr.GetObject(blckTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
                MText            text          = new MText();
                text.Contents   = textVal;
                text.Width      = textWidth;
                text.TextHeight = textHeight;
                text.Location   = new Point3d(pt1.X, pt1.Y, 0);
                text.Layer      = layerName;

                blockTableRec.AppendEntity(text);
                tr.AddNewlyCreatedDBObject(text, true);
                actualHeight = text.ActualHeight;
                tr.Commit();
                actualHnW  = new Tuple <double, double>(text.ActualWidth, text.ActualHeight);
                entCreated = text;
            }
            return(actualHnW);
        }
Esempio n. 15
0
        public RoadInfoItemModel GetRoadItemInfo(MText text)
        {
            RoadInfoItemModel item = new RoadInfoItemModel();

            item.RoadLength = "";
            item.RoadWidth  = "";
            item.RoadType   = "";
            item.ColorIndex = "";

            using (Transaction tran = CadHelper.Instance.Database.TransactionManager.StartTransaction())
            {
                item.RoadName         = text.Text.Replace(" ", "").Replace(" ", "").Replace("\r", "").Replace("\n", "");
                item.RoadNameLocaiton = new List <System.Drawing.PointF>();
                double textLen    = text.TextHeight * item.RoadName.Length + text.LineSpaceDistance * (item.RoadName.Length - 1);
                double partLength = textLen / item.RoadName.Length;

                for (int j = 1; j < item.RoadName.Length + 1; j++)
                {
                    item.RoadNameLocaiton.Add(MethodCommand.GetEndPointByTrigonometricHu(text.Rotation, MethodCommand.Point3d2Pointf(text.Location), partLength * j));
                }

                item.RoadNameLayer = text.Layer;
                item.RoadNameType  = "text";
            }
            return(item);
        }
Esempio n. 16
0
        public static List <MText> TandemText(DataSzuflada dataSzuflada)
        {
            var acMText = new MText();

            acMText.SetDatabaseDefaults();
            acMText.Location = new Point3d(dataSzuflada.Startx + dataSzuflada.Szerokosc + 200, dataSzuflada.Starty + dataSzuflada.Dlugosc, 0);
            acMText.Width    = 800;

            if (dataSzuflada.Spod)
            {
                acMText.Contents = "Elementy szuflady\n" +
                                   dataSzuflada.Numer + "  " + (dataSzuflada.Dlugosc) + "  " + (dataSzuflada.Wysokosc - 40) + "  " + dataSzuflada.Ilosc * 2 + "\n" +
                                   (dataSzuflada.Numer + 1) + "  " + (dataSzuflada.Szerokosc - (dataSzuflada.Grubosc * 2)) + "  " + (dataSzuflada.Wysokosc - 40 - 12 - dataSzuflada.Grubosc) + "  " + dataSzuflada.Ilosc * 2 + "\n" +
                                   "S" + ((dataSzuflada.Numer + 1) / 2) + "  " + (dataSzuflada.Szerokosc - (dataSzuflada.Grubosc * 2)) + "  " + (dataSzuflada.Dlugosc) + "  " + dataSzuflada.Ilosc;
            }
            else
            {
                acMText.Contents = "Elementy szuflady\n" +
                                   dataSzuflada.Numer + "sz  " + (dataSzuflada.Dlugosc) + "  " + (dataSzuflada.Wysokosc - 40) + "  " + dataSzuflada.Ilosc * 2 + "\n" +
                                   (dataSzuflada.Numer + 1) + "sz  " + (dataSzuflada.Szerokosc - (dataSzuflada.Grubosc * 2)) + "  " + (dataSzuflada.Wysokosc - 40 - 12 - dataSzuflada.Grubosc) + "  " + dataSzuflada.Ilosc * 2 + "\n" +
                                   "SH" + ((dataSzuflada.Numer + 1) / 2) + "  " + (dataSzuflada.Dlugosc) + "  " + (dataSzuflada.Szerokosc - (dataSzuflada.Grubosc * 2) + 22) + "  " + dataSzuflada.Ilosc;
            }

            return(new List <MText> {
                acMText
            });
        }
Esempio n. 17
0
        public static void PrintInscriptionsToDXFFile(List <BrickInscription> inscriptions)
        {
            foreach (BrickInscription inscription in inscriptions)
            {
                string brickEditionNumberStr = "#" + inscription.BrickEditionNumber.ToString();

                double brickEditionNumberWidthInInches = BrickInscription.GetTextWidthInInches(brickEditionNumberStr, 0.16557F);
                double countryWidthInInches            = BrickInscription.GetTextWidthInInches(inscription.Country);

                List <EntityObject> entities = new List <EntityObject>();

                MText donorName  = BrickInscription.CreateMTextAtPosition(inscription.DonorName, 0.41, 0.45);
                MText lylric1    = BrickInscription.CreateMTextAtPosition(inscription.LyricLine1, 0.41, 3.01);
                MText lylric2    = BrickInscription.CreateMTextAtPosition(inscription.LyricLine2, 0.41, 2.61);
                MText lylric3    = BrickInscription.CreateMTextAtPosition(inscription.LyricLine3, 0.41, 2.20);
                MText lylric4    = BrickInscription.CreateMTextAtPosition(inscription.LyricLine4, 0.41, 1.79);
                MText artistName = BrickInscription.CreateMTextAtPosition(inscription.ArtistName, 3.12, 1.14);
                Text  country    = BrickInscription.CreateTextAtPosition(inscription.Country, 5.13 - countryWidthInInches, 0.45);
                country.Alignment = TextAlignment.BaselineRight;
                Text brickEditionNumber = BrickInscription.CreateTextAtPosition(brickEditionNumberStr, 5.23 - brickEditionNumberWidthInInches, 3.22, 0.16557);
                brickEditionNumber.Alignment = TextAlignment.BaselineRight;

                entities.Add(donorName);
                entities.Add(lylric1);
                entities.Add(lylric2);
                entities.Add(lylric3);
                entities.Add(lylric4);
                entities.Add(artistName);
                entities.Add(country);
                entities.Add(brickEditionNumber);

                string docName = BrickInscription.GenerateFileNameFromInscription(inscription);
                BrickInscription.CreateDXFDocumentWithEntities(docName, entities);
            }
        }
Esempio n. 18
0
        private void UpdateOffset(int index, ref Point3d location, MText prvText, MText text, bool isHorizontalAligment)
        {
            Double tagWidth     = Math.Abs(text.GeometricExtents.MinPoint.X - text.GeometricExtents.MaxPoint.X),
                   tagPrevWidth = prvText != null?Math.Abs(prvText.GeometricExtents.MinPoint.X - prvText.GeometricExtents.MaxPoint.X) : 0;

            text.Location = location;
            Vector3d[] offset;
            if (isHorizontalAligment)
            {
                offset = new Vector3d[]
                {
                    new Vector3d(0, 0, 0),                               //In
                    new Vector3d(tagPrevWidth + TEXTHEIGHT * 1.5, 0, 0), //Cables
                    new Vector3d(0, TEXTHEIGHT * -1.5d, 0),              //Conector
                    new Vector3d(tagPrevWidth + TEXTHEIGHT * 1.5, 0, 0), //Longitud
                    new Vector3d(0, TEXTHEIGHT * -1.5d, 0),              //e%
                }
            }
            ;
            else
            {
                offset = new Vector3d[]
                {
                    new Vector3d(0, 0, 0),                  //In
                    new Vector3d(0, TEXTHEIGHT * -1.5d, 0), //Cables
                    new Vector3d(0, TEXTHEIGHT * -1.5d, 0), //Conector
                    new Vector3d(0, TEXTHEIGHT * -1.5d, 0), //Longitud
                    new Vector3d(0, TEXTHEIGHT * -1.5d, 0), //e%
                }
            };
            location += offset[index];
        }
Esempio n. 19
0
        public static void Main()
        {
            Document akDoc = Application.DocumentManager.MdiActiveDocument;
            Database akDb  = akDoc.Database;

            using (Transaction akTrans = akDb.TransactionManager.StartTransaction())
            {
                BlockTable akBlkTbl;
                akBlkTbl = akTrans.GetObject(akDb.BlockTableId, OpenMode.ForRead) as BlockTable;

                BlockTableRecord akBlkTblRec;
                akBlkTblRec = akTrans.GetObject(akBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;

                // creating new MText and assigning location and such
                MText objText = new MText();
                objText.SetDatabaseDefaults();
                objText.Location    = new Autodesk.AutoCAD.Geometry.Point3d(12, 12, 0);
                objText.Contents    = "hello";
                objText.TextStyleId = akDb.Textstyle;

                //append new MText object to the Model Space
                akBlkTblRec.AppendEntity(objText);

                //append the new MText object to the active Transaction
                akTrans.AddNewlyCreatedDBObject(objText, true);

                akTrans.Commit();
            }
        }
Esempio n. 20
0
        public static void DrawText(Point2d pt1, double textHeight, double rotation, string textVal, string layerName, short colour = 255)
        {
            Document doc       = Application.DocumentManager.MdiActiveDocument;
            Database currentDB = doc.Database;

            CreateLayer(layerName, colour);
            Entity entCreated;
            double actualHeight = 0;

            using (Transaction tr = currentDB.TransactionManager.StartTransaction())
            {
                BlockTable       blckTable     = tr.GetObject(currentDB.BlockTableId, OpenMode.ForRead) as BlockTable;
                BlockTableRecord blockTableRec = tr.GetObject(blckTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
                MText            text          = new MText();
                text.Contents   = textVal;
                text.Rotation   = rotation;
                text.TextHeight = textHeight;
                text.Location   = new Point3d(pt1.X, pt1.Y, 0);
                text.Layer      = layerName;
                text.Color      = Color.FromColorIndex(ColorMethod.ByLayer, colour);
                blockTableRec.AppendEntity(text);
                tr.AddNewlyCreatedDBObject(text, true);
                actualHeight = text.ActualHeight;
                tr.Commit();
                entCreated = text;
            }
        }
Esempio n. 21
0
        public void addTextToDWG()
        {
            Document doc       = Application.DocumentManager.MdiActiveDocument;
            Editor   ed        = doc.Editor;
            Database workingDB = HostApplicationServices.WorkingDatabase;
            Database db        = new Database(false, true);

            try
            {
                db.ReadDwgFile(filepath, System.IO.FileShare.ReadWrite, false, "");
                db.CloseInput(true);
                HostApplicationServices.WorkingDatabase = db;
            }
            catch (Autodesk.AutoCAD.Runtime.Exception e)
            {
                ed.WriteMessage("\nUnable to open .dwg file : " + e.StackTrace);
                return;
            }

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTable       bt      = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
                BlockTableRecord btr     = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
                MText            objText = new MText();
                objText.SetDatabaseDefaults();
                objText.Location    = new Autodesk.AutoCAD.Geometry.Point3d(2, 2, 0);
                objText.Contents    = "added text in a closed .dwg file!";
                objText.TextStyleId = db.Textstyle;
                btr.AppendEntity(objText);
                tr.AddNewlyCreatedDBObject(objText, true);
                tr.Commit();
            }
            HostApplicationServices.WorkingDatabase = workingDB;
            db.SaveAs(filepath, DwgVersion.Current);
        }
Esempio n. 22
0
        public MText addText()
        {
            MText               tx       = new MText();
            Document            acDoc    = Application.DocumentManager.MdiActiveDocument;
            PromptStringOptions pStrOpts = new PromptStringOptions("\nEnter Text: ");

            pStrOpts.AllowSpaces = true;
            PromptResult pStrRes = acDoc.Editor.GetString(pStrOpts);

            tx.Contents = pStrRes.StringResult;
            tx.Layer    = "DIM";

            //if the angle is between 90 degrees and 270 degrees
            if (angleA > 1.570796327 && angleA < 4.71238898)
            {
                tx.Location   = new Point3d(m_pts[1].X - .25, m_pts[1].Y, 0);
                tx.Attachment = AttachmentPoint.MiddleRight;
            }
            else
            {
                tx.Location   = new Point3d(m_pts[1].X + .25, m_pts[1].Y, 0);
                tx.Attachment = AttachmentPoint.MiddleLeft;
            }

            return(tx);
        }
Esempio n. 23
0
        public PipeItemModel GetPipeItemInfo(Polyline line, List <MText> txtList)
        {
            PipeItemModel item = new PipeItemModel();

            try
            {
                item.PipeLength      = line.Length.ToString();
                item.Style.LineWidth = line.ConstantWidth.ToString();
                item.ColorIndex      = line.ColorIndex == 256 ? MethodCommand.GetLayerColorByID(line.LayerId) : System.Drawing.ColorTranslator.ToHtml(line.Color.ColorValue);
                Document doc = Application.DocumentManager.MdiActiveDocument;
                Database db  = doc.Database;
                using (Transaction tran = db.TransactionManager.StartTransaction())
                {
                    int   vtnum = line.NumberOfVertices;
                    MText mText = MethodCommand.FindMTextIsInPolyineForPipe(line, txtList);
                    if (mText != null)
                    {
                        item.TxtLocation = new System.Drawing.PointF((float)mText.Location.X, (float)mText.Location.Y);
                        item.PipeType    = mText.Text; //Replace(" ", "").Replace(" ", "");
                        item.PipeLayer   = mText.Layer;
                    }
                }
                item.pipeList = PolylineMethod.GetPolyLineInfoPt(line);
            }
            catch
            { }
            return(item);
        }
Esempio n. 24
0
        /// <summary> Adds Entities (text, Attribute Definitions etc)to the block definition. </summary>
        /// <param name="blockDefinitionObjectId"> <see cref="ObjectId"/> for the block definition object. </param>
        /// <param name="entities">                The entities to add to the block. </param>
        /// <returns> true if it succeeds, false if it fails. </returns>
        /// <exception cref="ArgumentNullException">The value of 'blockDefinitionObjectId' cannot be null. </exception>
        public static bool AddEntitiesToBlockDefinition <T>(ObjectId blockDefinitionObjectId, ICollection <T> entities) where T : Entity
        {
            if (blockDefinitionObjectId == null)
            {
                throw new ArgumentNullException("blockDefinitionObjectId");
            }
            if (!blockDefinitionObjectId.IsValid)
            {
                return(false);
            }
            if (entities == null)
            {
                throw new ArgumentNullException("entities");
            }
            if (entities.Count < 1)
            {
                return(false);
            }

            Xpos = 0;
            Ypos = 0;
            bool               workedOk           = false;
            Database           database           = blockDefinitionObjectId.Database;
            TransactionManager transactionManager = database.TransactionManager;

            using (Transaction transaction = transactionManager.StartTransaction())
            {
                if (blockDefinitionObjectId.ObjectClass == (RXObject.GetClass(typeof(BlockTableRecord))))
                {
                    BlockTableRecord blockDefinition =
                        (BlockTableRecord)transactionManager.GetObject(blockDefinitionObjectId, OpenMode.ForWrite, false);
                    if (blockDefinition != null)
                    {
                        foreach (T entity in entities)
                        {
                            DBText text = entity as DBText;
                            if (text != null)
                            {
                                text.Position = new Point3d(Xpos, Ypos, Zpos); incrementXY();
                            }
                            else
                            {
                                MText mText = entity as MText;
                                if (mText != null)
                                {
                                    mText.Location = new Point3d(Xpos, Ypos, Zpos); incrementXY();
                                }
                            }

                            blockDefinition.AppendEntity(entity); // todo: vertical spacing ??

                            transactionManager.AddNewlyCreatedDBObject(entity, true);
                        }
                        workedOk = true;
                    }
                }
                transaction.Commit();
            }
            return(workedOk);
        }
Esempio n. 25
0
        private MText getMtext()
        {
            MText mtext = new MText();

            mtext.Attachment  = AttachmentPoint.MiddleCenter;
            mtext.Location    = ptMtextCenter;
            mtext.TextStyleId = db.GetTextStylePIK();
            mtext.TextHeight  = 2.5;

            int    tileCount     = markSB.Tiles.Count;
            double tileTotalArea = Math.Round(TileCalc.OneTileArea * tileCount, 2);

            string text = $"Швы вертикальные - {Settings.Default.TileSeam} мм, \n" +
                          $"швы горизонтальные {Settings.Default.TileSeam} мм, \n\n" +
                          $"Расход плитки: {Settings.Default.TileLenght}x{Settings.Default.TileHeight}x{Settings.Default.TileThickness} - \n" +
                          $"{tileCount} шт ({tileTotalArea} м\\U+00B2)";

            if (markSB.Windows.Any())
            {
                text += "\n\nОконные блоки в панели:";
                var wins = markSB.Windows.GroupBy(w => w.Mark).OrderBy(w => w.Key);
                foreach (var win in wins)
                {
                    text += $"\n{win.Key} - {win.Count()}шт.";
                    var winFirst = win.First();
                    if (winFirst.IsFireBox)
                    {
                        text += "(Противопожарное, E-30)";
                    }
                }
            }

            mtext.Contents = text;
            return(mtext);
        }
Esempio n. 26
0
        /// <summary>
        /// Создание описания панели на листе шаблона
        /// Должна быть запущена транзакция
        /// </summary>
        public void CreateDescription(Transaction t)
        {
            // Лист
            var layoutId = LayoutManager.Current.GetLayoutId(Settings.Default.SheetTemplateLayoutNameForMarkAR);

            if (layoutId.IsNull)
            {
                error("PanelDescription.CreateDescription() - layoutId.IsNull.");
                return;
            }
            var layout = layoutId.GetObject(OpenMode.ForRead) as Layout;

            using (var btrLayout = layout?.BlockTableRecordId.GetObject(OpenMode.ForWrite) as BlockTableRecord)
            {
                if (btrLayout == null)
                {
                    error("PanelDescription.CreateDescription() - btrLayout == null");
                    return;
                }
                // Добавление мтекста
                MText mtext = getMtext();
                if (mtext != null)
                {
                    btrLayout.AppendEntity(mtext);
                    t.AddNewlyCreatedDBObject(mtext, true);
                }
                // Таблица профилей для панелей с торцевыми плитками
                Table tableProfile = getTableProfile(mtext);
                if (tableProfile != null)
                {
                    btrLayout.AppendEntity(tableProfile);
                    t.AddNewlyCreatedDBObject(tableProfile, true);
                }
            }
        }
Esempio n. 27
0
        public static ObjectId AddName(Database database, Transaction tr, Entity entity, string name)
        {
            ObjectId textId = ObjectId.Null;
            //ObjectId layerId = LayerUtils.AddNewLayer(objectId.Database, LayerNames.NameAnnotation);
            var exts = SafeGetGeometricExtents(entity);

            if (exts != null)
            {
                var txtPosition =
                    new Point3d((exts.Value.MinPoint.X + exts.Value.MaxPoint.X) / 2,
                                (exts.Value.MinPoint.Y + exts.Value.MaxPoint.Y) / 2, 0);

                var mText = new MText
                {
                    Contents = name,
                    Location = txtPosition,
                    //LayerId = layerId,
                    Attachment = AttachmentPoint.MiddleCenter
                };
                mText.SetDatabaseDefaults();
                AddToCurrentDb(tr, database, mText);
                textId = mText.ObjectId;
            }
            return(textId);
        }
Esempio n. 28
0
 public EConsole(SpriteBatch spriteBatch)
 {
     keyboardState = new KeyboardState();
     _spriteBatch  = spriteBatch;
     headLine      = new MText(_spriteBatch, new Vector2(10, 45), "", GameMain.fontTest);
     userinput     = new MInput(_spriteBatch, new Vector2(10, 10), "", GameMain.fontTest, keyboardState);
 }
Esempio n. 29
0
        public void AddStackText()
        {
            Database db = HostApplicationServices.WorkingDatabase;

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                MText mtext = new MText
                {
                    Location = new Point3d(100, 40, 0) //位置
                };                                     //创建多行文本对象
                //创建水平分数形式的堆叠文字
                string firstLine = TextTools.StackText(TextSpecialSymbol.Diameter + "20", "H7", "P7", StackType.HorizontalFraction, 0.5);
                //创建斜分数形式的堆叠文字
                string secondLine = TextTools.StackText(TextSpecialSymbol.Diameter + "20", "H7", "P7", StackType.ItalicFraction, 0.5);
                //创建公差形式的堆叠文字
                string lastLine = TextTools.StackText(TextSpecialSymbol.Diameter + "20", "+0.020", "-0.010", StackType.Tolerance, 0.5);
                //将前面定义的堆叠文字合并,作为多行文本的内容
                mtext.Contents   = firstLine + MText.ParagraphBreak + secondLine + "\n" + lastLine;
                mtext.TextHeight = 5; //文本高度
                mtext.Width      = 0; //文本宽度,设为0表示不会自动换行
                //设置多行文字的对齐方式正中
                mtext.Attachment = AttachmentPoint.MiddleCenter;
                db.AddToModelSpace(mtext); //添加文本到模型空间中
                trans.Commit();            //提交事务处理
            }
        }
Esempio n. 30
0
        }//eof

        private String getSelectedObjectString(Transaction transaction, SelectedObject obj, string prefix = "")
        {
            string output = "";

            if (obj != null)
            {
                DBObject dbObj = transaction.GetObject(obj.ObjectId, OpenMode.ForRead);

                if (dbObj is MText)
                {
                    MText mTxtObj = dbObj as MText;
                    output += prefix + mTxtObj.Contents + "\n";
                }
                else if (dbObj is DBText)
                {
                    DBText dbTxtObj = dbObj as DBText;
                    output += prefix + dbTxtObj.TextString + "\n";
                }
                else
                {
                    Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Unknown type...!");
                }
            }

            return(output);
        } //eof
 public void Awake()
 {
     if (_tag == null)
     {
         _tag = GetComponent <BlockBehaviour>().AddText("class name", Const.KEY_BLOCK_ADDITION_TAG, "");
     }
 }
Esempio n. 32
0
 public static MText MText(Point3d pt3, string cont, double th, Database db, AttachmentPoint ap)
 {
     MText mt = new MText();
     mt.SetDatabaseDefaults();
     mt.Location = pt3;
     mt.Contents = cont;
     mt.TextStyleId = db.Textstyle;
     mt.TextHeight = th;
     mt.Attachment = ap;
     return mt;
 }
Esempio n. 33
0
        //--------------------------------------------------------------
        // ����:����һ���鶨�壨����¼��
        // ���ߣ�
        // ���ڣ�2007-7-20
        // ˵����
        //
        //----------------------------------------------------------------
        public ObjectId CreateBlkDef()
        {
            //���庯���ķ���ֵObjectId
            ObjectId blkObjId = new ObjectId();
            Database db = HostApplicationServices.WorkingDatabase;

            // ʹ�� "using"�ؼ���ָ������ı߽�
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                //��ȡ���
                BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForWrite);
                //ͨ������myBlkName�жϿ�����Ƿ��������¼
                if ((bt.Has("myBlkName")))
                {
                    blkObjId = bt["myBlkName"];//����Ѿ����ڣ�ͨ��������ȡ���Ӧ��ObjectId
                }
                else
                {
                    //����һ��Բ
                    Point3d center = new Point3d(10, 10, 0);
                    Circle circle = new Circle(center, Vector3d.ZAxis, 2);
                    circle.ColorIndex = 1;
                    //�����ı�Text:
                    MText text = new MText();
                    text.Contents = " ";
                    text.Location = center;
                    text.ColorIndex = 2;

                    //�����µĿ���¼ myBlkName
                    BlockTableRecord newBtr = new BlockTableRecord();
                    newBtr.Name = "myBlkName";
                    newBtr.Origin = center;
                    //�������¼�����
                    blkObjId = bt.Add(newBtr); // ���ؿ��Ӧ��ObjectId
                    trans.AddNewlyCreatedDBObject(newBtr, true); //Let the transaction know about any object/entity you add to the database!

                    //�����´�����ʵ�嵽����¼
                    newBtr.AppendEntity(circle);
                    newBtr.AppendEntity(text);
                    // ֪ͨ�����´����˶���
                    trans.AddNewlyCreatedDBObject(circle, true);
                    trans.AddNewlyCreatedDBObject(text, true);
                }
                trans.Commit(); //�ύ����
            }
            return blkObjId;
        }
Esempio n. 34
0
        public void AdskGreeting()
        {
            // Get the current document and database, and start a transaction
            Document acDoc = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            // Starts a new transaction with the Transaction Manager
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                // Open the Block table record for read
                BlockTable acBlkTbl;
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                             OpenMode.ForRead) as BlockTable;

                // Open the Block table record Model space for write
                BlockTableRecord acBlkTblRec;
                acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                                                OpenMode.ForWrite) as BlockTableRecord;

                /* Creates a new MText object and assigns it a location,
                text value and text style */
                MText objText = new MText();

                // Set the default properties for the MText object
                objText.SetDatabaseDefaults();

                // Specify the insertion point of the MText object
                objText.Location = new Autodesk.AutoCAD.Geometry.Point3d(2, 2, 0);

                // Set the text string for the MText object
                objText.Contents = "Greetings, Welcome to the AutoCAD .NET Developer's Guide";

                // Set the text style for the MText object
                objText.TextStyleId = acCurDb.Textstyle;

                // Appends the new MText object to model space
                acBlkTblRec.AppendEntity(objText);

                // Appends to new MText object to the active transaction
                acTrans.AddNewlyCreatedDBObject(objText, true);

                // Saves the changes to the database and closes the transaction
                acTrans.Commit();
            }
        }
        public void TextWrite(double x0, double y0, double z0, double k)
        {
            Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;// Get the current document and database
            DocumentLock myLock = acDoc.LockDocument();
            Database AcDb = acDoc.Database;
            Editor ed = acDoc.Editor;
            double step = 0.5 * k;  //шаг уменьшения размера текста
            double FS1 = k * (5 - 2.3); //Размер стандартного шрифта
            using (Transaction acTrans = AcDb.TransactionManager.StartTransaction())// Start a transaction
            {
                BlockTable acBlkTbl;// Open the Block table record for read
                acBlkTbl = acTrans.GetObject(AcDb.BlockTableId, OpenMode.ForRead) as BlockTable;
                BlockTableRecord acBlkTblRec;// Open the Block table record Model space for write
                acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
                MText[][] MTX = new MText[11][];
                #region MTEXT
                MTX[0] = new MText[7];
                MTX[0][0] = new MyText(new Point3d(x0 + 1 * k, y0 - k, z0), TBx0_0.Text, FS1, AcDb);
                MTX[0][1] = new MyText(new Point3d(x0 + (1 + 10) * k, y0 - k, z0), TBx0_1.Text, FS1, AcDb);
                MTX[0][2] = new MyText(new Point3d(x0 + (1 + 20) * k, y0 - k, z0), TBx0_2.Text, FS1, AcDb);
                MTX[0][3] = new MyText(new Point3d(x0 + (1 + 30) * k, y0 - k, z0), TBx0_3.Text, FS1, AcDb);
                MTX[0][4] = new MyText(new Point3d(x0 + (1 + 40) * k, y0 - k, z0), CBx0_4.Text, FS1, AcDb);
                MTX[0][5] = new MyText(new Point3d(x0 + (1 + 55) * k, y0 - k, z0), TBx0_5.Text, FS1, AcDb);
                MTX[0][6] = new MyText(new Point3d(x0 + 125 * k, y0 - 5 * k, z0), TBx0_6.Text, k * 5, AcDb, AttachmentPoint.MiddleCenter);
                F.MtextSize(MTX[0][6], 115, 10, k, step, 3);

                MTX[1] = new MText[6];
                MTX[1][0] = new MyText(new Point3d(x0 + 1 * k, y0 - (1 + 5) * k, z0), TBx1_0.Text, FS1, AcDb);
                MTX[1][1] = new MyText(new Point3d(x0 + (1 + 10) * k, y0 - (1 + 5) * k, z0), TBx1_1.Text, FS1, AcDb);
                MTX[1][2] = new MyText(new Point3d(x0 + (1 + 20) * k, y0 - (1 + 5) * k, z0), TBx1_2.Text, FS1, AcDb);
                MTX[1][3] = new MyText(new Point3d(x0 + (1 + 30) * k, y0 - (1 + 5) * k, z0), TBx1_3.Text, FS1, AcDb);
                MTX[1][4] = new MyText(new Point3d(x0 + (1 + 40) * k, y0 - (1 + 5) * k, z0), CBx1_4.Text, FS1, AcDb);
                MTX[1][5] = new MyText(new Point3d(x0 + (1 + 55) * k, y0 - (1 + 5) * k, z0), TBx1_5.Text, FS1, AcDb);

                MTX[2] = new MText[7];
                MTX[2][0] = new MyText(new Point3d(x0 + 1 * k, y0 - (1 + 10) * k, z0), TBx2_0.Text, FS1, AcDb);
                MTX[2][1] = new MyText(new Point3d(x0 + (1 + 10) * k, y0 - (1 + 10) * k, z0), TBx2_1.Text, FS1, AcDb);
                MTX[2][2] = new MyText(new Point3d(x0 + (1 + 20) * k, y0 - (1 + 10) * k, z0), TBx2_2.Text, FS1, AcDb);
                MTX[2][3] = new MyText(new Point3d(x0 + (1 + 30) * k, y0 - (1 + 10) * k, z0), TBx2_3.Text, FS1, AcDb);
                MTX[2][4] = new MyText(new Point3d(x0 + (1 + 40) * k, y0 - (1 + 10) * k, z0), СBx2_4.Text, FS1, AcDb);
                MTX[2][5] = new MyText(new Point3d(x0 + (1 + 55) * k, y0 - (1 + 10) * k, z0), TBx2_5.Text, FS1, AcDb);
                MTX[2][6] = new MyText(new Point3d(x0 + 125 * k, y0 - 17.5 * k, z0), TBx2_6.Text, k * 5, AcDb, AttachmentPoint.MiddleCenter);
                F.MtextSize(MTX[2][6], 115, 15, k, step, 4);

                MTX[3] = new MText[6];
                MTX[3][0] = new MyText(new Point3d(x0 + 1 * k, y0 - (1 + 15) * k, z0), TBx3_0.Text, FS1, AcDb);
                MTX[3][1] = new MyText(new Point3d(x0 + (1 + 10) * k, y0 - (1 + 15) * k, z0), TBx3_1.Text, FS1, AcDb);
                MTX[3][2] = new MyText(new Point3d(x0 + (1 + 20) * k, y0 - (1 + 15) * k, z0), TBx3_2.Text, FS1, AcDb);
                MTX[3][3] = new MyText(new Point3d(x0 + (1 + 30) * k, y0 - (1 + 15) * k, z0), TBx3_3.Text, FS1, AcDb);
                MTX[3][4] = new MyText(new Point3d(x0 + (1 + 40) * k, y0 - (1 + 15) * k, z0), CBx3_4.Text, FS1, AcDb);
                MTX[3][5] = new MyText(new Point3d(x0 + (1 + 55) * k, y0 - (1 + 15) * k, z0), TBx3_5.Text, FS1, AcDb);

                MTX[4] = new MText[6];
                MTX[4][0] = new MyText(new Point3d(x0 + k, y0 - 21 * k, z0), "Изм", FS1, AcDb);
                MTX[4][1] = new MyText(new Point3d(x0 + (10 + 1) * k, y0 - 21 * k, z0), "Кол.уч.", FS1, AcDb);
                MTX[4][2] = new MyText(new Point3d(x0 + (20 + 1) * k, y0 - 21 * k, z0), "Лист", FS1, AcDb);
                MTX[4][3] = new MyText(new Point3d(x0 + (30 + 1) * k, y0 - 21 * k, z0), "№ док.", FS1, AcDb);
                MTX[4][4] = new MyText(new Point3d(x0 + (44 + 1) * k, y0 - 21 * k, z0), "Подп.", FS1, AcDb);
                MTX[4][5] = new MyText(new Point3d(x0 + (55 + 1) * k, y0 - 21 * k, z0), "Дата", FS1, AcDb);

                MTX[5] = new MText[7];
                MTX[5][0] = new MyText(new Point3d(x0 + 1 * k, y0 - 26 * k, z0), CBx5_0.Text, FS1, AcDb);
                MTX[5][1] = new MyText(new Point3d(x0 + (0.5 + 20) * k, y0 - 27.5 * k, z0), CBx5_1.Text, FS1, AcDb, AttachmentPoint.MiddleLeft);
                F.MtextSize(MTX[5][1], 19.4, k, 0.1);
                MTX[5][2] = new MyText(new Point3d(x0 + (1 + 55) * k, y0 - (1 + 25) * k, z0), TBx5_2.Text, FS1, AcDb);
                MTX[5][3] = new MyText(new Point3d(x0 + 100 * k, y0 - 32.5 * k, z0), TBx5_3.Text, k * 4.5, AcDb, AttachmentPoint.MiddleCenter);
                F.MtextSize(MTX[5][3], 65, 15, k, step, 4);
                MTX[5][4] = new MyText(new Point3d(x0 + (135 + 1) * k, y0 - 26 * k, z0), "Стадия", FS1, AcDb);
                MTX[5][5] = new MyText(new Point3d(x0 + (150 + 1) * k, y0 - 26 * k, z0), "Лист", FS1, AcDb);
                MTX[5][6] = new MyText(new Point3d(x0 + (165 + 1) * k, y0 - 26 * k, z0), "Листов", FS1, AcDb);

                MTX[6] = new MText[6];
                MTX[6][0] = new MyText(new Point3d(x0 + 1 * k, y0 - (1 + 30) * k, z0), CBx6_0.Text, FS1, AcDb);
                MTX[6][1] = new MyText(new Point3d(x0 + ( 0.5 + 20 ) * k, y0 - 32.5 * k, z0), CBx6_1.Text, FS1, AcDb, AttachmentPoint.MiddleLeft);
                F.MtextSize(MTX[6][1], 19.4, k, 0.1);
                MTX[6][2] = new MyText(new Point3d(x0 + (1 + 55) * k, y0 - (1 + 30) * k, z0), TBx6_2.Text, FS1, AcDb);
                MTX[6][3] = new MyText(new Point3d(x0 + 142.5 * k, y0 - 35 * k, z0), CBx6_3.Text, k * 4, AcDb, AttachmentPoint.MiddleCenter);
                MTX[6][4] = new MyText(new Point3d(x0 + 157.5 * k, y0 - 35 * k, z0), TBx6_4.Text, k * 4, AcDb, AttachmentPoint.MiddleCenter);
                MTX[6][5] = new MyText(new Point3d(x0 + (1 + 175) * k, y0 - 35 * k, z0), TBx6_5.Text, k * 4, AcDb, AttachmentPoint.MiddleCenter);
                MTX[7] = new MText[3];
                MTX[7][0] = new MyText(new Point3d(x0 + 1 * k, y0 - (1 + 35) * k, z0), CBx7_0.Text, FS1, AcDb);
                MTX[7][1] = new MyText(new Point3d(x0 + (0.5 + 20) * k, y0 - 37.5 * k, z0), CBx7_1.Text, FS1, AcDb, AttachmentPoint.MiddleLeft);
                F.MtextSize(MTX[7][1], 19.4, k, 0.1);
                MTX[7][2] = new MyText(new Point3d(x0 + (1 + 55) * k, y0 - (1 + 35) * k, z0), TBx7_2.Text, FS1, AcDb);
                MTX[8] = new MText[5];
                MTX[8][0] = new MyText(new Point3d(x0 + 1 * k, y0 - (1 + 40) * k, z0), CBx8_0.Text, FS1, AcDb);
                MTX[8][1] = new MyText(new Point3d(x0 + (0.5 + 20) * k, y0 - 42.5 * k, z0), CBx8_1.Text, k * 3, AcDb, AttachmentPoint.MiddleLeft);
                F.MtextSize(MTX[8][1], 19.4, k, 0.1);
                MTX[8][2] = new MyText(new Point3d(x0 + (1 + 55) * k, y0 - (1 + 40) * k, z0), TBx8_2.Text, FS1, AcDb);
                MTX[8][3] = new MyText(new Point3d(x0 + 100 * k, y0 - 47.5 * k, z0), TBx8_3.Text, k * 4.5, AcDb, AttachmentPoint.MiddleCenter);
                F.MtextSize(MTX[8][3], 65, 15, k, step, 4);
                MTX[8][4] = new MyText(new Point3d(x0 + 185 * k, y0 - 47.5 * k, z0), TBx8_4.Text, k * 2.3, AcDb, AttachmentPoint.MiddleRight);
                MTX[9] = new MText[3];
                MTX[9][0] = new MyText(new Point3d(x0 + 1 * k, y0 - (1 + 45) * k, z0), CBx9_0.Text, FS1, AcDb);
                MTX[9][1] = new MyText(new Point3d(x0 + (0.5 + 20) * k, y0 - 47.5 * k, z0), CBx9_1.Text, k * 3, AcDb, AttachmentPoint.MiddleLeft);
                F.MtextSize(MTX[9][1], 19.4, k, 0.1);
                MTX[9][2] = new MyText(new Point3d(x0 + (1 + 55) * k, y0 - (1 + 45) * k, z0), TBx9_2.Text, FS1, AcDb);
                MTX[10] = new MText[3];
                MTX[10][0] = new MyText(new Point3d(x0 + 1 * k, y0 - (1 + 50) * k, z0), CBx10_0.Text, FS1, AcDb);
                MTX[10][1] = new MyText(new Point3d(x0 + (0.5 + 20) * k, y0 - 52.5 * k, z0), CBx10_1.Text, k * 3, AcDb, AttachmentPoint.MiddleLeft);
                F.MtextSize(MTX[10][1], 19.4, k, 0.1);
                MTX[10][2] = new MyText(new Point3d(x0 + (1 + 55) * k, y0 - (1 + 50) * k, z0), TBx10_2.Text, FS1, AcDb);

                //номер листа
                //if (isfirsttime && textb1_Copy47.Text != "-1")
                //{
                //    try
                //    {
                //        nomer_lista = int.Parse(textb1_Copy47.Text); isfirsttime = false;
                //    }
                //    catch (System.Exception ex)
                //    {
                //        nomer_lista = -1;
                //        Debug.Print("Обновление нумерации. " + ex.Message);
                //    }
                //}
                //else nomer_lista++;
                #endregion
                //Вставка подписей
                try
                {
                    if (CBx5_1.Text!="")
                        GetSign((int)CBx5_1.SelectedValue, new Point3d(x0 + (0.2 + 40) * k, y0 - (0 + 30) * k, z0));
                    if (CBx6_1.Text != "")
                        GetSign((int)CBx6_1.SelectedValue, new Point3d(x0 + (0.2 + 40) * k, y0 - (0 + 35) * k, z0));
                    if (CBx7_1.Text != "")
                        GetSign((int)CBx7_1.SelectedValue, new Point3d(x0 + (0.2 + 40) * k, y0 - (0 + 40) * k, z0));
                    if (CBx8_1.Text != "")
                        GetSign((int)CBx8_1.SelectedValue, new Point3d(x0 + (0.2 + 40) * k, y0 - (0 + 45) * k, z0));
                    if (CBx9_1.Text != "")
                        GetSign((int)CBx9_1.SelectedValue, new Point3d(x0 + (0.2 + 40) * k, y0 - (0 + 50) * k, z0));
                    if (CBx10_1.Text != "")
                        GetSign((int)CBx10_1.SelectedValue, new Point3d(x0 + (0.2 + 40) * k, y0 - (0 + 55) * k, z0));
                }
                catch (System.Exception SystEx)
                {
                    MessageBox.Show(SystEx.Message);
                }
                //Вставка логотипа
                string blockQualifiedFileName = logoStr;
                string blockName = "ETUlogo";
                Database tmpDb = new Database(false, true);
                tmpDb.ReadDwgFile(blockQualifiedFileName, System.IO.FileShare.Read, true, "");
                double scale = 1.0;
                Matrix3d Transform = Matrix3d.Identity;
                Transform = Transform * Matrix3d.Scaling(scale, Point3d.Origin);
                // add the block to the ActiveDrawing blockTable
                AcDb.Insert(blockName, tmpDb, true);
                Point3d insPt = new Point3d(x0 + 135 * k, y0 - 47.5 * k - 2.5 * k, z0);
                BlockTableRecord btr = (BlockTableRecord)acTrans.GetObject(AcDb.CurrentSpaceId, OpenMode.ForWrite);
                BlockReference br = new BlockReference(Point3d.Origin, acBlkTbl[blockName]);
                br.TransformBy(Matrix3d.Displacement(insPt - Point3d.Origin).PreMultiplyBy(ed.CurrentUserCoordinateSystem));
                btr.AppendEntity(br);
                acTrans.AddNewlyCreatedDBObject(br, true);

                //DBObjectCollection objColl = new DBObjectCollection();
                for (int i = 0; i < MTX.Length; i++)
                    for (int j = 0; j < MTX[i].Length; j++ )
                    {
                        acBlkTblRec.AppendEntity(MTX[i][j]);
                        if (i == 6 && j == 4) listobind = MTX[i][j].Id;

                        acTrans.AddNewlyCreatedDBObject(MTX[i][j], true);
                    }

                //foreach (MText[] ma in MTX)
                //    foreach (MText m in ma)
                //    {
                //        acBlkTblRec.AppendEntity(m);
                //        acTrans.AddNewlyCreatedDBObject(m, true);
                //    }
                //foreach (Entity en in objColl)
                //{
                //    acBlkTblRec.AppendEntity(en);
                //    acTrans.AddNewlyCreatedDBObject(en, true);
                //}
                acTrans.Commit();
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            char splitChar = ' ';
            Document acDoc = ACApp.DocumentManager.MdiActiveDocument;
            DocumentLock myLock = acDoc.LockDocument();
            Database acCurDb = acDoc.Database;
            Editor ded = acDoc.Editor;
            Point3d LeftTop = new Point3d(P1.X - 20 * K, P1.Y + 5 * K, P1.Z); //левая верхняя вершина 1 листа
            Point3d RightBottom = new Point3d(P2.X + 190 * K, P3.Y - A * K, P2.Z);//правая нижняя вершина 1 листа
            double W = Math.Abs(LeftTop.X - RightBottom.X), iW = W - K * 25; //W - ширина листа, iW - ширина внутренней области листа
            double X = RightBottom.X + 5 * K;
            double k = 0, MX0 = P1.X, MY = P1.Y - 5 * K, MZ = P1.Z, MX;
            double wc = 180; //ширина колонки
            double maxhc_f = P1.Y - P2.Y + 35 * K, maxhc = P1.Y - P2.Y - 20 * K; //высоты колонки
            k = Math.Floor(iW / (K * (wc + 5))); //кол-во колонок
            double fields = (iW - k * wc * K) / (k + 1); //ширина полей м/у колонками
            MX = MX0 + fields + K * wc / 2;
            MText[] MTx = new MText[20];
            for (int i = 0; i < MTx.Length; i++) MTx[i] = new MText();
            string intext = SpecifyTextBox.Text.Replace("\r\n\r", " ").Trim();
            string[] text = intext.Split(splitChar);
            int q = 0, ci = 0, all_ci = 0, list_count = 1;//счетчик для массива строк и счетчик колонок, счетчик листов
            while (q < text.Length)
            {
                if (ci < k) //если есть место для колонки - создаем
                {
                    ci++;
                    all_ci++;
                    F.SetMText(MTx[all_ci - 1], new Point3d(MX + K * (fields + wc) * (ci - 1), MY, MZ), "", K * 4, acCurDb, AttachmentPoint.TopCenter);
                    MTx[all_ci - 1].Width = wc * K;
                    if ((MTx[all_ci - 1].Location.X + wc * K / 2) < P2.X) MTx[all_ci - 1].Height = maxhc_f;
                    else MTx[all_ci - 1].Height = maxhc;
                }
                else //иначе создаем новый лист
                {
                    DrawBorders(new Point3d(X, RightBottom.Y, RightBottom.Z));
                    MX0 = X + 20 * K;
                    MX = MX0 + fields + K * wc / 2;
                    ci = 0; //индекс колонки в текущем листе
                    X += W + 5 * K;
                    continue;
                }
                while (MTx[all_ci - 1].ActualHeight < MTx[all_ci - 1].Height && q < text.Length)
                {
                    MTx[all_ci - 1].Contents += text[q] + splitChar; q++;
                }
            }

            // Start a transaction
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                BlockTable acBlkTbl;// Open the Block table record for read
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable;
                BlockTableRecord acBlkTblRec;// Open the Block table record Model space for write
                acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
                for (int i = 0; i < all_ci; i++)
                {
                    TextEditor ted = TextEditor.CreateTextEditor(MTx[i]);
                    ted.SelectAll();
                    foreach (TextEditorParagraph p in ted.Selection.Paragraphs)
                    {
                        p.Alignment = TextEditorParagraph.AlignmentType.AlignmentJustify;
                    }
                    ted.Close(TextEditor.ExitStatus.ExitSave);
                    acBlkTblRec.AppendEntity(MTx[i]);
                    acTrans.AddNewlyCreatedDBObject(MTx[i], true);
                }
                acTrans.Commit();
            }
        }
        private void DrawLDTable(Point3d pt)
        {
            Document myDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            DocumentLock myLock = myDoc.LockDocument();
            Database acCurDb = myDoc.Database;
            Editor ed = myDoc.Editor;
            List<Line> lines = new List<Line>();
            double x0 = pt.X, y0 = pt.Y - 10 * K, z0 = pt.Z;
            //double height = y0 - k * 55;
            #region Objects
            lines.Add(new Line(new Point3d(x0, y0, z0), new Point3d(x0, y0 - 15 * K, z0)));
            lines.Add(new Line(new Point3d(x0, y0, z0), new Point3d(x0 + 185 * K, y0, z0)));
            lines.Add(new Line(new Point3d(x0, y0 - 15 * K, z0), new Point3d(x0 + 185 * K, y0 - 15 * K, z0)));
            lines.Add(new Line(new Point3d(x0 + 60 * K, y0, z0), new Point3d(x0 + 60 * K, y0 - 15 * K, z0)));
            lines.Add(new Line(new Point3d(x0 + 155 * K, y0, z0), new Point3d(x0 + 155 * K, y0 - 15 * K, z0)));
            lines.Add(new Line(new Point3d(x0 + 185 * K, y0, z0), new Point3d(x0 + 185 * K, y0 - 15 * K, z0)));
            MText Header = new MyText(new Point3d(x0 + 92.5 * K, pt.Y - 5 * K, z0), "Ведомость прилагаемых документов", K * 4, acCurDb, AttachmentPoint.MiddleCenter);
            MText Text1 = new MyText(new Point3d(x0 + 30 * K, y0 - 7.5 * K, z0), "Обозначение", K * 4, acCurDb, AttachmentPoint.MiddleCenter);
            MText Text2 = new MyText(new Point3d(x0 + 107.5 * K, y0 - 7.5 * K, z0), "Наименование", K * 4, acCurDb, AttachmentPoint.MiddleCenter);
            MText Text3 = new MyText(new Point3d(x0 + 170 * K, y0 - 7.5 * K, z0), "Примечание", K * 4, acCurDb, AttachmentPoint.MiddleCenter);
            MText[,] texts = new MText[LDIList.Count, 3];
            double realH = y0 - 15 * K;
            int i = 0, thisRows = 0, thisRows2 = 0, rowsCount = 0; //счетчик  thisRows - в столбце Наименований, thisRows2 - примечаний

            //считаем кол-во строк
            for (i = 0; i < LDIList.Count; i++)
            {
                texts[i, 0] = new MyText(new Point3d(x0 + 30 * K, realH - 3 * K, z0), LDIList[i].Label, 3 * K, acCurDb, AttachmentPoint.TopCenter);
                texts[i, 1] = new MyText(new Point3d(x0 + (60 + 2.5) * K, realH - 3 * K, z0), LDIList[i].Name, 3 * K, acCurDb, AttachmentPoint.TopLeft);
                thisRows = (int)RowCount(texts[i, 1], 90);
                texts[i, 1].LineSpaceDistance = 8;
                texts[i, 2] = new MyText(new Point3d(x0 + (155 + 1) * K, realH - 3 * K, z0), LDIList[i].Note, 3 * K, acCurDb, AttachmentPoint.TopLeft);
                thisRows2 = (int)RowCount(texts[i, 2], 28);
                texts[i, 2].LineSpaceDistance = 8;
                thisRows = Math.Max(thisRows, thisRows2);
                for (int x = 0; x < thisRows; x++)
                {
                    lines.Add(new Line(new Point3d(x0, realH - 8 * K, z0), new Point3d(x0 + 185 * K, realH - 8 * K, z0)));
                    realH -= 8 * K;
                }
                rowsCount += thisRows;
            }
            lines.Add(new Line(new Point3d(x0, y0 - 15 * K, z0), new Point3d(x0, y0 - K * (15 + 8 * rowsCount), z0)));
            lines.Add(new Line(new Point3d(x0 + 60 * K, y0 - 15 * K, z0), new Point3d(x0 + 60 * K, y0 - K * (15 + 8 * rowsCount), z0)));
            lines.Add(new Line(new Point3d(x0 + 155 * K, y0 - 15 * K, z0), new Point3d(x0 + 155 * K, y0 - K * (15 + 8 * rowsCount), z0)));
            lines.Add(new Line(new Point3d(x0 + 185 * K, y0 - 15 * K, z0), new Point3d(x0 + 185 * K, y0 - K * (15 + 8 * rowsCount), z0)));

            #endregion
            BlockTableRecord btr;
            BlockTable bt;
            DBObjectCollection ObjColl = new DBObjectCollection(); //коллекция объектов
            #region AddObjects to collection
            ObjColl.Add(Text1); ObjColl.Add(Text2); ObjColl.Add(Text3); ObjColl.Add(Header);
            foreach (MText m in texts) ObjColl.Add(m);
            foreach (Line l in lines) ObjColl.Add(l);
            #endregion

            Database wbd = HostApplicationServices.WorkingDatabase;
            wbd.LineWeightDisplay = true;
            Transaction trans = wbd.TransactionManager.StartTransaction();
            bt = (BlockTable)trans.GetObject(wbd.BlockTableId, OpenMode.ForRead);
            btr = (BlockTableRecord)trans.GetObject(wbd.CurrentSpaceId, OpenMode.ForWrite);
            foreach (Entity ent in ObjColl)
            {
                btr.AppendEntity(ent);
                trans.AddNewlyCreatedDBObject(ent, true);
            }
            trans.Commit();
            trans.Dispose();
        }
Esempio n. 38
0
        private static Extents3d createChangePlan(List<ChangePanel> chPanels, Point3d ptPlan, ObjectId idBtrFloor,
                                                    BlockTableRecord btr,Transaction t)
        {
            // Вставить блок монтажки
            var blRefFloor = new BlockReference(ptPlan, idBtrFloor);
            btr.AppendEntity(blRefFloor);
            t.AddNewlyCreatedDBObject(blRefFloor, true);

            // Обвести облачком каждую панель с изменившейся покраской
            foreach (var chPanel in chPanels)
            {
                // Границы монт. панели на монт. плане в координатах Модели.
                var extMP = chPanel.ExtMountPanel;
                extMP.TransformBy(blRefFloor.BlockTransform);

                Point3d ptCloudMin;
                Point3d ptCloudMax;
                Point3d ptText;

                if (chPanel.IsHorizontal)
                {
                    ptCloudMin = new Point3d(extMP.MinPoint.X + 150, extMP.MinPoint.Y - 150, 0);
                    ptCloudMax = new Point3d(extMP.MaxPoint.X - 150, extMP.MaxPoint.Y + 150, 0);
                    ptText = new Point3d(ptCloudMin.X, ptCloudMin.Y - 100, 0);
                }
                else
                {
                    ptCloudMin = new Point3d(extMP.MinPoint.X - 150, extMP.MinPoint.Y + 150, 0);
                    ptCloudMax = new Point3d(extMP.MaxPoint.X + 150, extMP.MaxPoint.Y - 150, 0);
                    ptText = new Point3d(ptCloudMax.X+100, ptCloudMin.Y+(ptCloudMax.Y-ptCloudMin.Y)*0.5, 0);
                }
                var extCloud = new Extents3d(ptCloudMin, ptCloudMax);

                // Полилиния облака изменения
                var pl = extCloud.GetPolyline();
                var plCloud = getCloudPolyline(pl);
                plCloud.SetDatabaseDefaults();
                plCloud.Color = ColorChange;
                btr.AppendEntity(plCloud);
                t.AddNewlyCreatedDBObject(plCloud, true);

                // Текст изменения
                MText text = new MText();
                text.SetDatabaseDefaults();
                text.Color = ColorChange;
                text.TextHeight = 250;
                text.Contents = $"Старая марка покраски: {chPanel.PaintOld}, \n\rНовая марка покраски: {chPanel.PaintNew} " +
                    $"\n\rПанель: {chPanel.MarkSb}";
                text.Location = ptText;
                btr.AppendEntity(text);
                t.AddNewlyCreatedDBObject(text, true);

                chPanel.PanelMount.SetPaintingToAttr(chPanel.PanelAKR.MarkAr);
            }
            // Разбить
            //blRefFloor.ExplodeToOwnerSpace();
            return blRefFloor.GeometricExtents;
        }
        private void DrawVRCTable(Point3d pt, int ListIndex)
        {
            Document myDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            DocumentLock myLock = myDoc.LockDocument();
            Database acCurDb = myDoc.Database;
            Editor ed = myDoc.Editor;
            List<Line> lines = new List<Line>();
            DBObjectCollection ObjColl = new DBObjectCollection();
            double x0 = pt.X, y0 = pt.Y - 10 * K, z0 = pt.Z;
            #region Objects
            lines.Add(new Line(new Point3d(x0, y0, z0), new Point3d(x0, y0 - 15 * K, z0)));
            lines.Add(new Line(new Point3d(x0, y0, z0), new Point3d(x0 + 185 * K, y0, z0)));
            lines.Add(new Line(new Point3d(x0, y0 - 15 * K, z0), new Point3d(x0 + 185 * K, y0 - 15 * K, z0)));
            lines.Add(new Line(new Point3d(x0 + 15 * K, y0, z0), new Point3d(x0 + 15 * K, y0 - 15 * K, z0)));
            lines.Add(new Line(new Point3d(x0 + 155 * K, y0, z0), new Point3d(x0 + 155 * K, y0 - 15 * K, z0)));
            lines.Add(new Line(new Point3d(x0 + 185 * K, y0, z0), new Point3d(x0 + 185 * K, y0 - 15 * K, z0)));
            MText Header = new MyText(new Point3d(x0 + 92.5 * K, pt.Y - 5 * K, z0), "Ведомость рабочих чертежей", K * 4, acCurDb, AttachmentPoint.MiddleCenter);
            MText Text1 = new MyText(new Point3d(x0 + 7.5 * K, y0 - 7.5 * K, z0), "Лист", K * 4, acCurDb, AttachmentPoint.MiddleCenter);
            MText Text2 = new MyText(new Point3d(x0 + 85 * K, y0 - 7.5 * K, z0), "Наименование", K * 4, acCurDb, AttachmentPoint.MiddleCenter);
            MText Text3 = new MyText(new Point3d(x0 + 170 * K, y0 - 7.5 * K, z0), "Примечание", K * 4, acCurDb, AttachmentPoint.MiddleCenter);
            MText[,] texts = new MText[WDIList.Count, 3];
            for (int v = 0; v < WDIList.Count; v++)
            {
                texts[v, 0] = new MText();
                texts[v, 1] = new MText();
                texts[v, 2] = new MText();
            }
            double realH = y0 - 15 * K;
            int i = 0, thisRows = 0, thisRows2 = 0, rowsCount = 0; //счетчик  thisRows - в столбце Наименований, thisRows2 - примечаний
            double h = 0, hm;
            i = ListIndex;
            h += (P1.Y - pt.Y) + 25 * K;
            if (185 * K + pt.X <= P2.X + 185 * K) //если есть место для колонки
            {
                if (185 * K + pt.X < P2.X) //колонка левее штампа
                    hm = P1.Y - P3.Y;
                else hm = P1.Y - P3.Y - 55 * K;

                while (h < hm && i < WDIList.Count)
                {
                    texts[i, 0] = new MyText(new Point3d(x0 + 7.5 * K, realH - 3 * K, z0), WDIList[i].PNum, 3 * K, acCurDb, AttachmentPoint.TopLeft);
                    texts[i, 1] = new MyText(new Point3d(x0 + (15 + 2.5) * K, realH - 3 * K, z0), WDIList[i].Name, 3 * K, acCurDb, AttachmentPoint.TopLeft);
                    thisRows = (int)RowCount(texts[i, 1], 135);
                    texts[i, 1].LineSpaceDistance = 8;
                    texts[i, 2] = new MyText(new Point3d(x0 + (155 + 1) * K, realH - 3 * K, z0), WDIList[i].Note, 3 * K, acCurDb, AttachmentPoint.TopLeft);
                    thisRows2 = (int)RowCount(texts[i, 2], 28);
                    texts[i, 2].LineSpaceDistance = 8;
                    thisRows = Math.Max(thisRows, thisRows2);
                    if (h + thisRows * 8 * K > hm) break;
                    ObjColl.Add(texts[i, 0]);
                    ObjColl.Add(texts[i, 1]);
                    ObjColl.Add(texts[i, 2]);

                    for (int x = 0; x < thisRows; x++)
                    {
                        lines.Add(new Line(new Point3d(x0, realH - 8 * K, z0), new Point3d(x0 + 185 * K, realH - 8 * K, z0)));
                        realH -= 8 * K;
                    }
                    rowsCount += thisRows;
                    h += thisRows * 8 * K;
                    i++;
                }

                lines.Add(new Line(new Point3d(x0, y0 - 15 * K, z0), new Point3d(x0, y0 - K * (15 + 8 * rowsCount), z0)));
                lines.Add(new Line(new Point3d(x0 + 15 * K, y0 - 15 * K, z0), new Point3d(x0 + 15 * K, y0 - K * (15 + 8 * rowsCount), z0)));
                lines.Add(new Line(new Point3d(x0 + 155 * K, y0 - 15 * K, z0), new Point3d(x0 + 155 * K, y0 - K * (15 + 8 * rowsCount), z0)));
                lines.Add(new Line(new Point3d(x0 + 185 * K, y0 - 15 * K, z0), new Point3d(x0 + 185 * K, y0 - K * (15 + 8 * rowsCount), z0)));

            #endregion
                BlockTableRecord btr;
                BlockTable bt;
                //DBObjectCollection ObjColl = new DBObjectCollection(); //коллекция объектов
                #region AddObjects to collection
                ObjColl.Add(Text1); ObjColl.Add(Text2); ObjColl.Add(Text3); ObjColl.Add(Header);
                //for (int m=0; m<i; m++)
                //foreach (MText m in texts) ObjColl.Add(m);
                foreach (Line l in lines) ObjColl.Add(l);
                #endregion

                Database wbd = HostApplicationServices.WorkingDatabase;
                wbd.LineWeightDisplay = true;
                Transaction trans = wbd.TransactionManager.StartTransaction();
                bt = (BlockTable)trans.GetObject(wbd.BlockTableId, OpenMode.ForRead);
                btr = (BlockTableRecord)trans.GetObject(wbd.CurrentSpaceId, OpenMode.ForWrite);
                foreach (Entity ent in ObjColl)
                {
                    btr.AppendEntity(ent);
                    trans.AddNewlyCreatedDBObject(ent, true);
                }
                trans.Commit();
                trans.Dispose();

                if (i < WDIList.Count)
                    DrawVRCTable(new Point3d(pt.X + 186 * K, pt.Y, pt.Z), i);
            }
            else if (i < WDIList.Count && PageW >= 185)//места для колонки нет - создаем новый лист
            {
                DrawBorders(new Point3d(P1.X + (-10 + PageW) * K, P1.Y + (5 - PageH) * K, P1.Z));
                DrawVRCTable(P1, i);
            }
            else MessageBox.Show("Лист слишком узок для таблицы");
        }
Esempio n. 40
0
 private MText GetMText(string text, Point3d origin)
 {
     MText mText = new MText();
     mText.Contents = text;
     mText.Location = origin;
     mText.TextHeight = 0.07;
     mText.Attachment = AttachmentPoint.MiddleCenter;
     return mText;
 }
Esempio n. 41
0
 /// <summary>
 /// Установка параметров MText.
 /// </summary>
 /// <param name="mt">Объект MText</param>
 /// <param name="pt3">Местоположение</param>
 /// <param name="cont">Содержимое</param>
 /// <param name="th">Высота текста</param>
 /// <param name="db">База данных документа</param>
 public static void SetMText(MText mt, Point3d pt3, string cont, double th, Database db)
 {
     mt.SetDatabaseDefaults();
     mt.Location = pt3;
     mt.Contents = cont;
     mt.TextStyleId = db.Textstyle;
     mt.TextHeight = th;
 }
Esempio n. 42
0
 /// <summary>
 /// Установка параметров MText.
 /// </summary>
 /// <param name="mt">Объект MText</param>
 /// <param name="pt3">Местоположение</param>
 /// <param name="cont">Содержимое</param>
 /// <param name="th">Высота текста</param>
 /// <param name="db">База данных документа</param>
 /// <param name="ap">Точка выравнивания</param>
 /// <param name="ang">Угол поворота текста (в градусах)</param>
 public static void SetMText(MText mt, Point3d pt3, string cont, double th, Database db, AttachmentPoint ap, double ang)
 {
     mt.SetDatabaseDefaults();
     mt.Location = pt3;
     mt.Contents = cont;
     mt.TextStyleId = db.Textstyle;
     mt.TextHeight = th;
     mt.Attachment = ap;
     mt.Rotation = ang * Math.PI / 180;
 }
Esempio n. 43
0
        //This function returns the ObjectId for the BlockTableRecord called "EmployeeBlock",
        //creating it if necessary.  The block contains three entities - circle, text
        //and ellipse.
        public ObjectId CreateEmployeeDefinition()
        {
            ObjectId newBtrId = new ObjectId(); //The return value for this function
            Database db = HostApplicationServices.WorkingDatabase; //save some space

            // The "using" keyword used below automatically calls "Dispose"
            // on the "trans" object.
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                //Now, drill into the database and obtain a reference to the BlockTable
                BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForWrite);
                if ((bt.Has("EmployeeBlock")))
                {
                    newBtrId = bt["EmployeeBlock"];
                }
                else
                {
                    Point3d center = new Point3d(10, 10, 0); // convenient declaration...
                    //  Declare and define the entities we want to add:
                    //Circle:
                    Circle circle = new Circle(center, Vector3d.ZAxis, 2);
                    //Text:
                    MText text = new MText();
                    text.Contents = "Earnest Shackleton";
                    text.Location = center;
                    //Ellipse:
                    Ellipse ellipse = new Ellipse(center, Vector3d.ZAxis, new Vector3d(3, 0, 0), 0.5, 0, 0);

                    //Next, create a layer with the helper function, and assign
                    //the layer to our entities.
                    ObjectId empId = CreateLayer();
                    text.LayerId = empId;
                    circle.LayerId = empId;
                    ellipse.LayerId = empId;
                    //Set the color for each entity irrespective of the layer's color.
                    text.ColorIndex = 2;
                    circle.ColorIndex = 1;
                    ellipse.ColorIndex = 3;

                    //Create a new block definition called EmployeeBlock
                    BlockTableRecord newBtr = new BlockTableRecord();
                    newBtr.Name = "EmployeeBlock";
                    newBtrId = bt.Add(newBtr); //Add the block, and set the id as the return value of our function
                    trans.AddNewlyCreatedDBObject(newBtr, true); //Let the transaction know about any object/entity you add to the database!

                    newBtr.AppendEntity(circle); //Append our entities...
                    newBtr.AppendEntity(text);
                    newBtr.AppendEntity(ellipse);
                    trans.AddNewlyCreatedDBObject(circle, true); //Again, let the transaction know about our newly added entities.
                    trans.AddNewlyCreatedDBObject(text, true);
                    trans.AddNewlyCreatedDBObject(ellipse, true);
                }
                trans.Commit(); //All done, no errors?  Go ahead and commit!
            }
            return newBtrId;
        }
Esempio n. 44
0
        private MText getMtext()
        {
            MText mtext = new MText();
            mtext.Attachment = AttachmentPoint.MiddleCenter;
            mtext.Location = ptMtextCenter;
            mtext.TextStyleId = db.GetTextStylePIK();
            mtext.TextHeight = 2.5;

            int tileCount = markSB.Tiles.Count;
            double tileTotalArea = Math.Round(TileCalc.OneTileArea * tileCount, 2);

            string text = $"Швы вертикальные - {Settings.Default.TileSeam} мм, \n" +
                          $"швы горизонтальные {Settings.Default.TileSeam} мм, \n\n" +
                          $"Расход плитки: {Settings.Default.TileLenght}x{Settings.Default.TileHeight}x{Settings.Default.TileThickness} - \n" +
                          $"{tileCount} шт ({tileTotalArea} м\\U+00B2)";
            if (markSB.Windows.Any())
            {
                text += "\n\nОконные блоки в панели:";
                var wins = markSB.Windows.GroupBy(w => w.Mark).OrderBy(w => w.Key);
                foreach (var win in wins)
                {
                    text += $"\n{win.Key} - {win.Count()}шт.";
                    var winFirst = win.First();
                    if (winFirst.IsFireBox)
                    {
                        text += "(Противопожарное, E-30)";
                    }
                }
            }

            mtext.Contents = text;
            return mtext;
        }
Esempio n. 45
0
        public void ExecuteCommand()
        {
            string elementType;
            string floorNumber;
            int currentNumber;
            StopStatus stopStatus = new StopStatus();

            PromptResult elementPromptResult = GetElementTypeToSign();
            if (elementPromptResult.Status != PromptStatus.OK)
                return;
            elementType = elementPromptResult.StringResult;

            PromptResult floorNumberPromptResult = GetFloorNumber();
            if (floorNumberPromptResult.Status != PromptStatus.OK)
                return;
            floorNumber = floorNumberPromptResult.StringResult;

            PromptIntegerResult startingNumberPromptResult = GetStartingNumber();
            if (startingNumberPromptResult.Status != PromptStatus.OK)
                return;
            currentNumber = startingNumberPromptResult.Value;

            while (!stopStatus.IsStopped())
            {
                Transaction trans = db.TransactionManager.StartTransaction();

                MText signText = new MText();
                SignWallColumnJig signTextJig = new SignWallColumnJig(signText, stopStatus);

                signText.Contents = GetText(elementType, currentNumber, floorNumber);
                currentNumber++;
                try
                {
                    BlockTableRecord blockTableRecord = trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;

                    blockTableRecord.AppendEntity(signText);
                    trans.AddNewlyCreatedDBObject(signText, true);

                    PromptStatus promptStatus = PromptStatus.Keyword;
                    while (promptStatus == PromptStatus.Keyword && !stopStatus.IsStopped())
                    {
                        PromptResult promptResult = editor.Drag(signTextJig);
                        promptStatus = promptResult.Status;
                        if (promptStatus != PromptStatus.OK && promptStatus != PromptStatus.Keyword)
                            return;
                    }

                    if (stopStatus.IsStopped())
                        trans.Abort();
                    else
                        trans.Commit();
                }
                catch (System.Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message, "error");
                }
                finally
                {
                    trans.Dispose();
                }
            }
        }
        private void button12_Click(object sender, EventArgs e)
        {
            this.Hide();

            string textM = "";
            double pointX = 0, pointY = 0;

            Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            using (DocumentLock doclock = acDoc.LockDocument())
            {
                // Старт транзакции
                using (Transaction trans = acCurDb.TransactionManager.StartTransaction())
                {
                    // Запрос выбора объектов в области чертежа
                    PromptSelectionResult acSSPrompt = acDoc.Editor.GetSelection();

                    // Если статус запроса равен OK, объекты выбраны
                    if (acSSPrompt.Status == PromptStatus.OK)
                    {
                        SelectionSet acSSet = acSSPrompt.Value;
                        // Перебор объектов в наборе
                        foreach (SelectedObject acSSObj in acSSet)
                        {
                            // Проверка, нужно убедиться в правильности полученного объекта
                            if (acSSObj != null)
                            {
                                // Открытие объекта для чтения
                                Line acEnt = trans.GetObject(acSSObj.ObjectId, OpenMode.ForRead) as Line;
                                if (acEnt != null)
                                {

                                    int indS = Data.pathPoints.FindIndex(item => item == acEnt.StartPoint);
                                    int indE = Data.pathPoints.FindIndex(item => item == acEnt.EndPoint);

                                    pointX = acEnt.StartPoint.X;
                                    pointY = acEnt.StartPoint.Y;

                                    List<string> tmp = new List<string>();
                                    tmp = Data.pathName[indS];

                                    foreach (String str in tmp)
                                    {
                                        if (Data.pathName[indE].Contains(str))
                                            textM = String.Concat(textM, "/", str);
                                    }

                                }
                            }
                        }
                    }

                    BlockTableRecord btr;
                    BlockTable bt;
                    DBObjectCollection ObjColl = new DBObjectCollection();
                    MText objText = new MText();
                    objText.SetDatabaseDefaults();
                    objText.Location = new Point3d(pointX, pointY + 5, 0);
                    objText.Contents = textM;
                    objText.TextStyleId = acCurDb.Textstyle;
                    objText.TextHeight = 3;
                    objText.Height = 25;
                    objText.Width = 25;
                    ObjColl.Add(objText);

                    Database wbd = HostApplicationServices.WorkingDatabase;

                    bt = (BlockTable)trans.GetObject(wbd.BlockTableId, OpenMode.ForRead);
                    btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
                    foreach (Entity ent in ObjColl)
                    {
                        btr.AppendEntity(ent);
                        trans.AddNewlyCreatedDBObject(ent, true);
                    }
                    trans.Commit();
                    trans.Dispose();
                }
            }

            this.Show();
        }
 private double RowCount(MText mtx, float width)
 {
     double lh = double.Parse(tbLH.Text), rows;
     double hb = mtx.ActualHeight;
     mtx.Width = width;
     rows = Math.Round(mtx.ActualHeight / (hb + lh));
     if (rows >= 1) return rows;
     else return 1;
 }
        public void JoinText()
        {
            var acObjList = new List<Entity>();
            var acObjList_Mtext = new List<String>();
            Document acDoc = acApp.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                BlockTable acBlkTbl;
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                    OpenMode.ForRead) as BlockTable;
                BlockTableRecord acBlkTblRec;
                acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                    OpenMode.ForWrite) as BlockTableRecord;

                // Request Mtext object to be selected
                PromptSelectionResult acSSPrompt = acDoc.Editor.GetSelection();

                // If OK
                if (acSSPrompt.Status == PromptStatus.OK)
                {

                    SelectionSet acSSet = acSSPrompt.Value;

                    // Step through the objects
                    foreach (SelectedObject acSSobj in acSSet)
                    {
                        // Check if valid
                        if (acSSobj != null)
                        {
                            // Open object for read
                            Entity acEnt = acTrans.GetObject(acSSobj.ObjectId,
                                OpenMode.ForRead) as Entity;

                            if (acEnt != null)
                            {
                                // Seperate out text and mtext entities
                                if (acEnt.GetType() == typeof(MText) || acEnt.GetType() == typeof(DBText))
                                {
                                    // add entity to array
                                    acObjList.Add(acEnt);
                                }
                            }
                        }
                    }
                }

                if (acObjList.Count != 0)
                {
                    //TO-DO:
                    //iterate through acObjList if object is mtext save over to acObjMtext
                    //if objuect is DBtext then convert to mtext and save over to acObjMtext
                    MText acNewMText = new MText();
                    ObjectId objId;
                    Point3d acPosition = new Point3d();

                    //get the insertion point of the new mtext block based on the first selected block of text
                    //TO-DO in future figure out which text is the on top in the drawing and use that point
                    if (acObjList[0].GetType() == typeof(DBText))
                    {
                        DBText tempDBtext = acTrans.GetObject(acObjList[0].ObjectId, OpenMode.ForRead) as DBText;
                        acPosition = tempDBtext.Position;
                    }
                    else if (acObjList[0].GetType() == typeof(MText))
                    {
                        MText tempMtext = acTrans.GetObject(acObjList[0].ObjectId, OpenMode.ForRead) as MText;
                        acPosition = tempMtext.Location;
                    }
                    else
                    {
                        acPosition = new Point3d(0, 0, 0);
                    }
                    //iterate though the list of entities and use properties of the first Mtext entity found
                    //for the new mtext entity

                    try
                    {
                        MText firstMtext = (MText)acObjList.Find(x => x.GetType() == typeof(MText));
                        //set relevant properties to the new mtext entity
                        acNewMText.SetDatabaseDefaults();
                        acNewMText.Location = acPosition;
                        acNewMText.TextHeight = firstMtext.TextHeight;
                        acNewMText.TextStyleId = firstMtext.TextStyleId;
                        acNewMText.Width = firstMtext.Width;
                        acNewMText.Layer = firstMtext.Layer;
                    }
                    catch (System.Exception)
                    {
                        //set relevant properties to the new mtext entity
                        MText firstMtext = new MText();
                        acNewMText.SetDatabaseDefaults();
                        acNewMText.Location = acPosition;
                    }

                    //iterate though each entity add the entities text to the acObjList_Mtext based on
                    //if the entity is DBText or Mtext
                    foreach (Entity acEnt in acObjList)
                    {
                        //test to see if acEnt is Mtext
                        if (acEnt.GetType() == typeof(MText))
                        {
                            //add text contents to acObjList_Mtest
                            MText acMtextTemp = acTrans.GetObject(acEnt.ObjectId, OpenMode.ForRead) as MText;
                            acObjList_Mtext.Add(acMtextTemp.Text);
                        }
                        //if acEnt is not mtext
                        else if (acEnt.GetType() == typeof(DBText))
                        {
                            //add text contents to acObjList_Mtext
                            DBText acDBText = acTrans.GetObject(acEnt.ObjectId, OpenMode.ForWrite) as DBText;
                            acObjList_Mtext.Add(acDBText.TextString);
                        }
                    }

                    //check to make sure that the List acObjList_Mtext is not empty
                    if (acObjList_Mtext.Count != 0)
                    {
                        //add all strings stored in acObjList_Mtext to the new acNewMtext entity
                        string tempStr = "";
                        foreach (string str in acObjList_Mtext)
                        {
                            tempStr += str;
                            tempStr += "\\P";
                        }
                        acNewMText.Contents = tempStr;
                        objId = acBlkTblRec.AppendEntity(acNewMText);
                        acTrans.AddNewlyCreatedDBObject(acNewMText, true);
                    }

                    //remove initially selected objects from the database.
                    for (int i = 0; i < acObjList.Count; i++)
                    {
                        Entity acEnt = acTrans.GetObject(acObjList[i].ObjectId, OpenMode.ForWrite) as Entity;
                        acEnt.Erase();
                        acEnt.Dispose();
                    }
                    acTrans.Commit();
                }
            }
        }
Esempio n. 49
0
 /// <summary>
 /// Изменение размера MText
 /// </summary>
 /// <param name="text">Объект MText</param>
 /// <param name="w">Ширина</param>
 /// <param name="h">Высота</param>
 /// <param name="k">Коэффициент увеличения</param>
 /// <param name="step">Шаг уменьшения</param>
 /// <param name="min1">Минимальная высота</param>
 public static void MtextSize(MText text, double w, double h, double k, double step, double min1)
 {
     bool isOverride = text.ActualWidth > w * k;
     while (text.TextHeight > min1 * k && isOverride)
     {
         if (text.ActualWidth >= w * k) { text.TextHeight -= step; isOverride = true; }
         else isOverride = false;
     }
     text.Width = w * k;
     while (text.TextHeight > 2 * k && isOverride)
     {
         if (text.ActualWidth >= w * k || text.ActualHeight >= h * k) { text.TextHeight -= step; isOverride = true; }
         else isOverride = false;
     }
 }
        //Рисуем таблицу щитка.
        private void b_paint_Click(object sender, EventArgs e)
        {
            this.Hide();
            Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            using (DocumentLock doclock = acDoc.LockDocument())
            {
                using (Transaction trans = acCurDb.TransactionManager.StartTransaction())
                {

                    PromptPointResult pPtRes;
                    PromptPointOptions pPtOpts = new PromptPointOptions("");
                    pPtOpts.Message = "\nВведи точку: ";
                    pPtRes = acDoc.Editor.GetPoint(pPtOpts);
                    // pPtRes.Value - точка типа Point3D
                    Data.table_x = pPtRes.Value.X;
                    Data.table_y = pPtRes.Value.Y;

                    BlockTableRecord btr;
                    BlockTable bt;
                    DBObjectCollection ObjColl = new DBObjectCollection();

                    //ObjColl.Add(new Line(new Point3d(Data.table_x, Data.table_y, 0), new Point3d(Data.table_x, Data.table_y, 0)));

                    //Вставили шапку таблицы.
                    ObjColl.Add(new Line(new Point3d(Data.table_x, Data.table_y, 0), new Point3d(Data.table_x + 285, Data.table_y, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x, Data.table_y - 50, 0), new Point3d(Data.table_x + 285, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 101, Data.table_y - 15, 0), new Point3d(Data.table_x + 285, Data.table_y - 15, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x, Data.table_y, 0), new Point3d(Data.table_x, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 25, Data.table_y, 0), new Point3d(Data.table_x + 25, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 58, Data.table_y, 0), new Point3d(Data.table_x + 58, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 63, Data.table_y, 0), new Point3d(Data.table_x + 63, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 96, Data.table_y, 0), new Point3d(Data.table_x + 96, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 101, Data.table_y, 0), new Point3d(Data.table_x + 101, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 106, Data.table_y - 15, 0), new Point3d(Data.table_x + 106, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 123, Data.table_y - 15, 0), new Point3d(Data.table_x + 123, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 136, Data.table_y - 15, 0), new Point3d(Data.table_x + 136, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 161, Data.table_y - 15, 0), new Point3d(Data.table_x + 161, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 174, Data.table_y, 0), new Point3d(Data.table_x + 174, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 197, Data.table_y - 15, 0), new Point3d(Data.table_x + 197, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 210, Data.table_y, 0), new Point3d(Data.table_x + 210, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 226, Data.table_y - 15, 0), new Point3d(Data.table_x + 226, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 238, Data.table_y - 15, 0), new Point3d(Data.table_x + 238, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 250, Data.table_y - 15, 0), new Point3d(Data.table_x + 250, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 285, Data.table_y, 0), new Point3d(Data.table_x + 285, Data.table_y - 50, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 239, Data.table_y - 32, 0), new Point3d(Data.table_x + 249, Data.table_y - 32, 0)));

                    #region Текст в шапке
                    MText objText = new MText();
                    objText.SetDatabaseDefaults();
                    objText.Location = new Point3d(Data.table_x + 2, Data.table_y - 1, 0);
                    objText.Contents = "Распреде-\nлительное устройство";
                    objText.TextStyleId = acCurDb.Textstyle;
                    objText.TextHeight = 3;
                    objText.Height = 50;
                    objText.Width = 25;
                    ObjColl.Add(objText);

                    MText objText1 = new MText();
                    objText1.SetDatabaseDefaults();
                    objText1.TextStyleId = acCurDb.Textstyle;
                    objText1.TextHeight = 3;
                    objText1.Location = new Point3d(Data.table_x + 27, Data.table_y - 1, 0);
                    objText1.Contents = "Аппарат отходящей линии /ввода/, обозначение, тип, Iном, A, расцепитель или плавкая вставка, А.";
                    objText1.Height = 50;
                    objText1.Width = 31;
                    ObjColl.Add(objText1);

                    MText objText2 = new MText();
                    objText2.SetDatabaseDefaults();
                    objText2.TextStyleId = acCurDb.Textstyle;
                    objText2.TextHeight = 3;
                    objText2.Location = new Point3d(Data.table_x + 65, Data.table_y - 1, 0);
                    objText2.Contents = "Пусковой аппарат, обозначение, тип, Iном, A, расцепитель или плавкая вставка А, уставка теплового реле А.";
                    objText2.Height = 50;
                    objText2.Width = 31;
                    ObjColl.Add(objText2);

                    MText objText3 = new MText();
                    objText3.SetDatabaseDefaults();
                    objText3.TextStyleId = acCurDb.Textstyle;
                    objText3.TextHeight = 3;
                    objText3.Location = new Point3d(Data.table_x + 108, Data.table_y - 18, 0);
                    objText3.Contents = "Обозна-\nчение";
                    objText3.Height = 35;
                    objText3.Width = 17;
                    ObjColl.Add(objText3);

                    MText objText4 = new MText();
                    objText4.SetDatabaseDefaults();
                    objText4.TextStyleId = acCurDb.Textstyle;
                    objText4.TextHeight = 3;
                    objText4.Location = new Point3d(Data.table_x + 125, Data.table_y - 18, 0);
                    objText4.Contents = "Марка";
                    objText4.Height = 35;
                    objText4.Width = 13;
                    ObjColl.Add(objText4);

                    MText objText5 = new MText();
                    objText5.SetDatabaseDefaults();
                    objText5.TextStyleId = acCurDb.Textstyle;
                    objText5.TextHeight = 3;
                    objText5.Location = new Point3d(Data.table_x + 138, Data.table_y - 18, 0);
                    objText5.Contents = "Количество, число жил и сечение";
                    objText5.Height = 35;
                    objText5.Width = 25;
                    ObjColl.Add(objText5);

                    MText objText6 = new MText();
                    objText6.SetDatabaseDefaults();
                    objText6.TextStyleId = acCurDb.Textstyle;
                    objText6.TextHeight = 3;
                    objText6.Location = new Point3d(Data.table_x + 162, Data.table_y - 18, 0);
                    objText6.Contents = "Длина, м.";
                    objText6.Height = 35;
                    objText6.Width = 13;
                    ObjColl.Add(objText6);

                    MText objText7 = new MText();
                    objText7.SetDatabaseDefaults();
                    objText7.TextStyleId = acCurDb.Textstyle;
                    objText7.TextHeight = 3;
                    objText7.Location = new Point3d(Data.table_x + 175, Data.table_y - 18, 0);
                    objText7.Contents = "Обозначение на плане";
                    objText7.Height = 35;
                    objText7.Width = 23;
                    ObjColl.Add(objText7);

                    MText objText8 = new MText();
                    objText8.SetDatabaseDefaults();
                    objText8.TextStyleId = acCurDb.Textstyle;
                    objText8.TextHeight = 3;
                    objText8.Location = new Point3d(Data.table_x + 198, Data.table_y - 18, 0);
                    objText8.Contents = "Длина, м.";
                    objText8.Height = 35;
                    objText8.Width = 13;
                    ObjColl.Add(objText8);

                    MText objText9 = new MText();
                    objText9.SetDatabaseDefaults();
                    objText9.TextStyleId = acCurDb.Textstyle;
                    objText9.TextHeight = 3;
                    objText9.Location = new Point3d(Data.table_x + 212, Data.table_y - 18, 0);
                    objText9.Contents = "Обозна-\nчение";
                    objText9.Height = 35;
                    objText9.Width = 16;
                    ObjColl.Add(objText9);

                    MText objText10 = new MText();
                    objText10.SetDatabaseDefaults();
                    objText10.TextStyleId = acCurDb.Textstyle;
                    objText10.TextHeight = 3;
                    objText10.Location = new Point3d(Data.table_x + 227, Data.table_y - 18, 0);
                    objText10.Contents = "Pуст. или Pном., КВт";
                    objText10.Height = 35;
                    objText10.Width = 12;
                    ObjColl.Add(objText10);

                    MText objText11 = new MText();
                    objText11.SetDatabaseDefaults();
                    objText11.TextStyleId = acCurDb.Textstyle;
                    objText11.TextHeight = 3;
                    objText11.Location = new Point3d(Data.table_x + 239, Data.table_y - 18, 0);
                    objText11.Contents = "Iрасч. или Iном. Iпуск., А.";
                    objText11.Height = 35;
                    objText11.Width = 12;
                    ObjColl.Add(objText11);

                    MText objText12 = new MText();
                    objText12.SetDatabaseDefaults();
                    objText12.TextStyleId = acCurDb.Textstyle;
                    objText12.TextHeight = 3;
                    objText12.Location = new Point3d(Data.table_x + 252, Data.table_y - 18, 0);
                    objText12.Contents = "Наименование, тип, обозначение чертежа, принципиальной схемы.";
                    objText12.Height = 35;
                    objText12.Width = 35;
                    ObjColl.Add(objText12);

                    DBText acText = new DBText();
                    acText.SetDatabaseDefaults();
                    acText.Position = new Point3d(Data.table_x + 62, Data.table_y - 48, 0);
                    acText.Height = 3;
                    acText.TextString = "Участок сети 1";
                    acText.Rotation = 1.570796; //Это 90 градусов в радианах.
                    ObjColl.Add(acText);

                    DBText acText1 = new DBText();
                    acText1.SetDatabaseDefaults();
                    acText1.Rotation = 1.570796;
                    acText1.Height = 3;
                    acText1.Position = new Point3d(Data.table_x + 100, Data.table_y - 48, 0);
                    acText1.TextString = "Участок сети 2";
                    ObjColl.Add(acText1);

                    DBText acText2 = new DBText();
                    acText2.SetDatabaseDefaults();
                    acText2.Rotation = 1.570796;
                    acText2.Height = 3;
                    acText2.Position = new Point3d(Data.table_x + 105, Data.table_y - 48, 0);
                    acText2.TextString = "Участок сети";
                    ObjColl.Add(acText2);

                    DBText acText3 = new DBText();
                    acText3.SetDatabaseDefaults();
                    acText3.Height = 3;
                    acText3.Position = new Point3d(Data.table_x + 123, Data.table_y - 8, 0);
                    acText3.TextString = "Кабель, провод";
                    ObjColl.Add(acText3);
                    //acText.WidthFactor = 0.5;

                    DBText acText4 = new DBText();
                    acText4.SetDatabaseDefaults();
                    acText4.Height = 3;
                    acText4.Position = new Point3d(Data.table_x + 185, Data.table_y - 8, 0);
                    acText4.TextString = "Труба";
                    ObjColl.Add(acText4);

                    DBText acText5 = new DBText();
                    acText5.SetDatabaseDefaults();
                    acText5.Height = 3;
                    acText5.Position = new Point3d(Data.table_x + 230, Data.table_y - 8, 0);
                    acText5.TextString = "Электроприемник";
                    ObjColl.Add(acText5);
                    #endregion

                    Data.table_y = Data.table_y - 30;
                    double table_xx = Data.table_x, table_yy = Data.table_y - 20;

                    #region Вставляем строки таблицы
                    for (int j = 0; j < dataGridView1.Rows.Count - 1; j++)
                    {
                        Data.table_y = Data.table_y - 20;

                        if (dataGridView1.Rows[j].Cells["Ветвь"].Value.ToString() == "Главная линия")
                        {
                            Line l_gl = new Line(new Point3d(Data.table_x + 25, Data.table_y - 20, 0), new Point3d(Data.table_x + 210, Data.table_y - 20, 0));
                            l_gl.LineWeight = LineWeight.LineWeight050;
                            l_gl.ColorIndex = 4;
                            ObjColl.Add(l_gl);
                        }

                        if (dataGridView1.Rows[j].Cells["Ветвь"].Value.ToString() == "Ответвление")
                        {
                            Line l_gl = new Line(new Point3d(Data.table_x + 62, Data.table_y, 0), new Point3d(Data.table_x + 60, Data.table_y - 2, 0));
                            l_gl.LineWeight = LineWeight.LineWeight050;
                            l_gl.ColorIndex = 4;
                            ObjColl.Add(l_gl);

                            Line l_gl1 = new Line(new Point3d(Data.table_x + 60, Data.table_y - 2, 0), new Point3d(Data.table_x + 60, Data.table_y - 20, 0));
                            l_gl1.LineWeight = LineWeight.LineWeight050;
                            l_gl1.ColorIndex = 4;
                            ObjColl.Add(l_gl1);

                            Line l_gl2 = new Line(new Point3d(Data.table_x + 60, Data.table_y - 20, 0), new Point3d(Data.table_x + 210, Data.table_y - 20, 0));
                            l_gl2.LineWeight = LineWeight.LineWeight050;
                            l_gl2.ColorIndex = 4;
                            ObjColl.Add(l_gl2);
                        }

                        if (dataGridView1.Rows[j].Cells["Род тока"].Value.ToString() == "1")
                        {
                            ObjColl.Add(new Line(new Point3d(Data.table_x + 51, Data.table_y - 17.5, 0), new Point3d(Data.table_x + 49, Data.table_y - 22.5, 0)));
                        }

                        if (dataGridView1.Rows[j].Cells["Род тока"].Value.ToString() == "3")
                        {
                            ObjColl.Add(new Line(new Point3d(Data.table_x + 51, Data.table_y - 17.5, 0), new Point3d(Data.table_x + 49, Data.table_y - 22.5, 0)));
                            ObjColl.Add(new Line(new Point3d(Data.table_x + 52, Data.table_y - 17.5, 0), new Point3d(Data.table_x + 50, Data.table_y - 22.5, 0)));
                            ObjColl.Add(new Line(new Point3d(Data.table_x + 50, Data.table_y - 17.5, 0), new Point3d(Data.table_x + 48, Data.table_y - 22.5, 0)));
                        }

                        ObjColl.Add(new Line(new Point3d(Data.table_x + 25, Data.table_y, 0), new Point3d(Data.table_x + 25, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 58, Data.table_y, 0), new Point3d(Data.table_x + 58, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 63, Data.table_y, 0), new Point3d(Data.table_x + 63, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 96, Data.table_y, 0), new Point3d(Data.table_x + 96, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 101, Data.table_y, 0), new Point3d(Data.table_x + 101, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 106, Data.table_y, 0), new Point3d(Data.table_x + 106, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 123, Data.table_y, 0), new Point3d(Data.table_x + 123, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 136, Data.table_y, 0), new Point3d(Data.table_x + 136, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 161, Data.table_y, 0), new Point3d(Data.table_x + 161, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 174, Data.table_y, 0), new Point3d(Data.table_x + 174, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 197, Data.table_y, 0), new Point3d(Data.table_x + 197, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 210, Data.table_y, 0), new Point3d(Data.table_x + 210, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 226, Data.table_y, 0), new Point3d(Data.table_x + 226, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 238, Data.table_y, 0), new Point3d(Data.table_x + 238, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 250, Data.table_y, 0), new Point3d(Data.table_x + 250, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 285, Data.table_y, 0), new Point3d(Data.table_x + 285, Data.table_y - 20, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 101, Data.table_y - 10, 0), new Point3d(Data.table_x + 210, Data.table_y - 10, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 210, Data.table_y - 20, 0), new Point3d(Data.table_x + 285, Data.table_y - 20, 0)));

                        DBText acText6 = new DBText();
                        acText6.SetDatabaseDefaults();
                        acText6.Height = 3;
                        acText6.Position = new Point3d(Data.table_x + 27, Data.table_y - 14, 0);
                        acText6.TextString = dataGridView1.Rows[j].Cells["Аппарат"].Value.ToString();
                        ObjColl.Add(acText6);

                        DBText acText7 = new DBText();
                        acText7.SetDatabaseDefaults();
                        acText7.Height = 3;
                        acText7.Position = new Point3d(Data.table_x + 27, Data.table_y - 18, 0);
                        acText7.TextString = dataGridView1.Rows[j].Cells["Ток"].Value.ToString();
                        ObjColl.Add(acText7);

                        DBText acText8 = new DBText();
                        acText8.SetDatabaseDefaults();
                        acText8.Height = 3;
                        acText8.Position = new Point3d(Data.table_x + 60, Data.table_y - 18, 0);
                        acText8.TextString = dataGridView1.Rows[j].Cells["Фаза"].Value.ToString();
                        ObjColl.Add(acText8);

                        DBText acText9 = new DBText();
                        acText9.SetDatabaseDefaults();
                        acText9.Height = 3;
                        acText9.Position = new Point3d(Data.table_x + 65, Data.table_y - 18, 0);
                        acText9.TextString = dataGridView1.Rows[j].Cells["Пусковой аппарат 1"].Value.ToString();
                        ObjColl.Add(acText9);

                        DBText acText10 = new DBText();
                        acText10.SetDatabaseDefaults();
                        acText10.Height = 3;
                        acText10.Position = new Point3d(Data.table_x + 65, Data.table_y - 14, 0);
                        acText10.TextString = dataGridView1.Rows[j].Cells["Пусковой аппарат 2"].Value.ToString();
                        ObjColl.Add(acText10);

                        DBText acText11 = new DBText();
                        acText11.SetDatabaseDefaults();
                        acText11.Height = 3;
                        acText11.Position = new Point3d(Data.table_x + 65, Data.table_y - 10, 0);
                        acText11.TextString = dataGridView1.Rows[j].Cells["Пусковой аппарат 3"].Value.ToString();
                        ObjColl.Add(acText11);

                        DBText acText12 = new DBText();
                        acText12.SetDatabaseDefaults();
                        acText12.Height = 3;
                        acText12.Position = new Point3d(Data.table_x + 108, Data.table_y - 8, 0);
                        acText12.TextString = dataGridView1.Rows[j].Cells["Обозначение 1"].Value.ToString();
                        ObjColl.Add(acText12);

                        DBText acText13 = new DBText();
                        acText13.SetDatabaseDefaults();
                        acText13.Height = 3;
                        acText13.Position = new Point3d(Data.table_x + 125, Data.table_y - 8, 0);
                        acText13.TextString = dataGridView1.Rows[j].Cells["Марка 1"].Value.ToString();
                        ObjColl.Add(acText13);

                        DBText acText14 = new DBText();
                        acText14.SetDatabaseDefaults();
                        acText14.Height = 3;
                        acText14.Position = new Point3d(Data.table_x + 138, Data.table_y - 8, 0);
                        acText14.TextString = dataGridView1.Rows[j].Cells["Жилы 1"].Value.ToString() + "x" + dataGridView1.Rows[j].Cells["Сечение 1"].Value.ToString();
                        ObjColl.Add(acText14);

                        DBText acText15 = new DBText();
                        acText15.SetDatabaseDefaults();
                        acText15.Height = 3;
                        acText15.Position = new Point3d(Data.table_x + 163, Data.table_y - 8, 0);
                        acText15.TextString = dataGridView1.Rows[j].Cells["Длина 1"].Value.ToString();
                        ObjColl.Add(acText15);

                        DBText acText16 = new DBText();
                        acText16.SetDatabaseDefaults();
                        acText16.Height = 3;
                        acText16.Position = new Point3d(Data.table_x + 108, Data.table_y - 18, 0);
                        acText16.TextString = dataGridView1.Rows[j].Cells["Обозначение 2"].Value.ToString();
                        ObjColl.Add(acText16);

                        DBText acText17 = new DBText();
                        acText17.SetDatabaseDefaults();
                        acText17.Height = 3;
                        acText17.Position = new Point3d(Data.table_x + 125, Data.table_y - 18, 0);
                        acText17.TextString = dataGridView1.Rows[j].Cells["Марка 2"].Value.ToString();
                        ObjColl.Add(acText17);

                        DBText acText18 = new DBText();
                        acText18.SetDatabaseDefaults();
                        acText18.Height = 3;
                        acText18.Position = new Point3d(Data.table_x + 138, Data.table_y - 18, 0);
                        if (dataGridView1.Rows[j].Cells["Жилы 2"].Value.ToString() + "x" + dataGridView1.Rows[j].Cells["Сечение 2"].Value.ToString() != "x")
                            acText18.TextString = dataGridView1.Rows[j].Cells["Жилы 2"].Value.ToString() + "x" + dataGridView1.Rows[j].Cells["Сечение 2"].Value.ToString();
                        else
                            acText18.TextString = "";
                        ObjColl.Add(acText18);

                        DBText acText19 = new DBText();
                        acText19.SetDatabaseDefaults();
                        acText19.Height = 3;
                        acText19.Position = new Point3d(Data.table_x + 163, Data.table_y - 18, 0);
                        acText19.TextString = dataGridView1.Rows[j].Cells["Длина 2"].Value.ToString();
                        ObjColl.Add(acText19);

                        DBText acText20 = new DBText();
                        acText20.SetDatabaseDefaults();
                        acText20.Height = 3;
                        acText20.Position = new Point3d(Data.table_x + 212, Data.table_y - 12, 0);
                        acText20.TextString = dataGridView1.Rows[j].Cells["Обознач. прием."].Value.ToString();
                        ObjColl.Add(acText20);

                        DBText acText21 = new DBText();
                        acText21.SetDatabaseDefaults();
                        acText21.Height = 3;
                        acText21.Position = new Point3d(Data.table_x + 228, Data.table_y - 12, 0);
                        acText21.TextString = dataGridView1.Rows[j].Cells["P"].Value.ToString();
                        ObjColl.Add(acText21);

                        DBText acText22 = new DBText();
                        acText22.SetDatabaseDefaults();
                        acText22.Height = 3;
                        acText22.Position = new Point3d(Data.table_x + 240, Data.table_y - 12, 0);
                        acText22.TextString = dataGridView1.Rows[j].Cells["I"].Value.ToString();
                        ObjColl.Add(acText22);

                        DBText acText23 = new DBText();
                        acText23.SetDatabaseDefaults();
                        acText23.Height = 3;
                        acText23.Position = new Point3d(Data.table_x + 252, Data.table_y - 12, 0);
                        acText23.TextString = dataGridView1.Rows[j].Cells["Наим. прием."].Value.ToString();
                        ObjColl.Add(acText23);

                        DBText acText24 = new DBText();
                        acText24.SetDatabaseDefaults();
                        acText24.Height = 3;
                        acText24.Position = new Point3d(Data.table_x + 103, Data.table_y - 8, 0);
                        acText24.TextString = "1";
                        ObjColl.Add(acText24);

                        DBText acText25 = new DBText();
                        acText25.SetDatabaseDefaults();
                        acText25.Height = 3;
                        acText25.Position = new Point3d(Data.table_x + 103, Data.table_y - 18, 0);
                        acText25.TextString = "2";
                        ObjColl.Add(acText25);
                    }
                    #endregion

                    Line l_ver = new Line(new Point3d(table_xx + 25, table_yy - 20, 0), new Point3d(table_xx + 25, Data.table_y - 26.5, 0));
                    l_ver.LineWeight = LineWeight.LineWeight050;
                    l_ver.ColorIndex = 4;
                    ObjColl.Add(l_ver);

                    Line l_ver1 = new Line(new Point3d(Data.table_x + 22.5, Data.table_y - 26.5, 0), new Point3d(Data.table_x + 27.5, Data.table_y - 26.5, 0));
                    l_ver1.LineWeight = LineWeight.LineWeight100;
                    l_ver1.ColorIndex = 4;
                    ObjColl.Add(l_ver1);

                    ObjColl.Add(new Line(new Point3d(Data.table_x, table_yy, 0), new Point3d(Data.table_x, Data.table_y - 20, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x, Data.table_y - 20, 0), new Point3d(Data.table_x + 63, Data.table_y - 20, 0)));

                    Database wbd = HostApplicationServices.WorkingDatabase;

                    bt = (BlockTable)trans.GetObject(wbd.BlockTableId, OpenMode.ForRead);
                    btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
                    foreach (Entity ent in ObjColl)
                    {
                        btr.AppendEntity(ent);
                        trans.AddNewlyCreatedDBObject(ent, true);
                    }
                    trans.Commit();
                    trans.Dispose();
                }
            }
            this.Show();
        }
        private void paint_Click(object sender, EventArgs e)
        {
            this.Hide();
            Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;

            using (DocumentLock doclock = acDoc.LockDocument())
            {
                using (Transaction trans = acCurDb.TransactionManager.StartTransaction())
                {

                    PromptPointResult pPtRes;
                    PromptPointOptions pPtOpts = new PromptPointOptions("");
                    pPtOpts.Message = "\nВведи точку: ";
                    pPtRes = acDoc.Editor.GetPoint(pPtOpts);
                    // pPtRes.Value - точка типа Point3D
                    Data.table_x = pPtRes.Value.X - 185;
                    Data.table_y = pPtRes.Value.Y;

                    BlockTableRecord btr;
                    BlockTable bt;
                    DBObjectCollection ObjColl = new DBObjectCollection();

                    //ObjColl.Add(new Line(new Point3d(Data.table_x, Data.table_y, 0), new Point3d(Data.table_x, Data.table_y, 0)));

                    //Вставили шапку таблицы.
                    ObjColl.Add(new Line(new Point3d(Data.table_x, Data.table_y, 0), new Point3d(Data.table_x + 185, Data.table_y, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x, Data.table_y - 15, 0), new Point3d(Data.table_x + 185, Data.table_y - 15, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x, Data.table_y, 0), new Point3d(Data.table_x, Data.table_y - 15, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 185, Data.table_y, 0), new Point3d(Data.table_x + 185, Data.table_y - 15, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 20, Data.table_y, 0), new Point3d(Data.table_x + 20, Data.table_y - 15, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 130, Data.table_y, 0), new Point3d(Data.table_x + 130, Data.table_y - 15, 0)));
                    ObjColl.Add(new Line(new Point3d(Data.table_x + 140, Data.table_y, 0), new Point3d(Data.table_x + 140, Data.table_y - 15, 0)));

                    #region Текст в шапке
                    MText objText = new MText();
                    objText.SetDatabaseDefaults();
                    objText.Location = new Point3d(Data.table_x + 2, Data.table_y - 1, 0);
                    objText.Contents = "Поз.\nОбозна-\nчение";
                    objText.TextStyleId = acCurDb.Textstyle;
                    objText.TextHeight = 3;
                    objText.Height = 15;
                    objText.Width = 20;
                    ObjColl.Add(objText);

                    MText objText1 = new MText();
                    objText1.SetDatabaseDefaults();
                    objText1.TextStyleId = acCurDb.Textstyle;
                    objText1.TextHeight = 3;
                    objText1.Location = new Point3d(Data.table_x + 65, Data.table_y - 6, 0);
                    objText1.Contents = "Наименование";
                    objText1.Height = 15;
                    objText1.Width = 110;
                    ObjColl.Add(objText1);

                    MText objText2 = new MText();
                    objText2.SetDatabaseDefaults();
                    objText2.TextStyleId = acCurDb.Textstyle;
                    objText2.TextHeight = 3;
                    objText2.Location = new Point3d(Data.table_x + 132, Data.table_y - 6, 0);
                    objText2.Contents = "Кол.";
                    objText2.Height = 15;
                    objText2.Width = 10;
                    ObjColl.Add(objText2);

                    MText objText3 = new MText();
                    objText3.SetDatabaseDefaults();
                    objText3.TextStyleId = acCurDb.Textstyle;
                    objText3.TextHeight = 3;
                    objText3.Location = new Point3d(Data.table_x + 143, Data.table_y - 6, 0);
                    objText3.Contents = "Примечание";
                    objText3.Height = 15;
                    objText3.Width = 45;
                    ObjColl.Add(objText3);

                    #endregion

                    Data.table_y = Data.table_y - 8;
                    double table_xx = Data.table_x, table_yy = Data.table_y - 20;

                    #region Вставляем строки таблицы
                    for (int j = 0; j < dataGridView1.Rows.Count - 1; j++)
                    {
                        Data.table_y = Data.table_y - 7;

                        ObjColl.Add(new Line(new Point3d(Data.table_x, Data.table_y, 0), new Point3d(Data.table_x, Data.table_y - 7, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 20, Data.table_y, 0), new Point3d(Data.table_x + 20, Data.table_y - 7, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 130, Data.table_y, 0), new Point3d(Data.table_x + 130, Data.table_y - 7, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 140, Data.table_y, 0), new Point3d(Data.table_x + 140, Data.table_y - 7, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x + 185, Data.table_y, 0), new Point3d(Data.table_x + 185, Data.table_y - 7, 0)));
                        ObjColl.Add(new Line(new Point3d(Data.table_x, Data.table_y - 7, 0), new Point3d(Data.table_x + 185, Data.table_y - 7, 0)));

                        DBText acText6 = new DBText();
                        acText6.SetDatabaseDefaults();
                        acText6.Height = 3;
                        acText6.Position = new Point3d(Data.table_x + 2, Data.table_y - 5, 0);
                        acText6.TextString = dataGridView1.Rows[j].Cells["Обозначение"].Value.ToString();
                        ObjColl.Add(acText6);

                        DBText acText7 = new DBText();
                        acText7.SetDatabaseDefaults();
                        acText7.Height = 3;
                        acText7.Position = new Point3d(Data.table_x + 21, Data.table_y - 5, 0);
                        acText7.TextString = dataGridView1.Rows[j].Cells["Наименование"].Value.ToString();
                        ObjColl.Add(acText7);

                        DBText acText8 = new DBText();
                        acText8.SetDatabaseDefaults();
                        acText8.Height = 3;
                        acText8.Position = new Point3d(Data.table_x + 132, Data.table_y - 5, 0);
                        acText8.TextString = dataGridView1.Rows[j].Cells["Кол"].Value.ToString();
                        ObjColl.Add(acText8);

                        DBText acText9 = new DBText();
                        acText9.SetDatabaseDefaults();
                        acText9.Height = 3;
                        acText9.Position = new Point3d(Data.table_x + 141, Data.table_y - 5, 0);
                        acText9.TextString = dataGridView1.Rows[j].Cells["Примечание"].Value.ToString();
                        ObjColl.Add(acText9);
                    }
                    #endregion

                    ObjColl.Add(new Line(new Point3d(Data.table_x, Data.table_y - 7, 0), new Point3d(Data.table_x + 185, Data.table_y - 7, 0)));

                    Database wbd = HostApplicationServices.WorkingDatabase;

                    bt = (BlockTable)trans.GetObject(wbd.BlockTableId, OpenMode.ForRead);
                    btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
                    foreach (Entity ent in ObjColl)
                    {
                        btr.AppendEntity(ent);
                        trans.AddNewlyCreatedDBObject(ent, true);
                    }
                    trans.Commit();
                    trans.Dispose();
                }
            }
            this.Show();
        }
Esempio n. 52
0
        private Table getTableProfile(MText mtext)
        {
            double lenProfile = 0;
            if (markSB.IsEndLeftPanel || markSB.IsEndRightPanel)
            {
                lenProfile = Math.Round(markSB.HeightPanelByTile * 0.001, 1);
            }
            else if (markSB.MarkSbName.StartsWith("ОЛ", StringComparison.OrdinalIgnoreCase))
            {
                // Длина панели ???
                lenProfile = Math.Round(
                               (markSB.ExtentsTiles.MaxPoint.X - markSB.ExtentsTiles.MinPoint.X
                                  + Settings.Default.TileLenght + Settings.Default.TileSeam)
                                  * 0.001, 1)
                                  * ((markSB.StoreyTypePanel == EnumStorey.Upper)? 1: 2);
            }
            else
            {
                return null;
            }

            double xTable = ptMtextCenter.X - 35;
            Point3d ptTable;
            if (mtext != null)
            {
                ptTable = new Point3d(xTable, 28.0, 0.0);
                //// Определение границ тексчта
                //try
                //{
                //   var extMText = mtext.GeometricExtents;
                //   ptTable = new Point3d(xTable, extMText.MinPoint.Y-15, 0.0);
                //}
                //catch
                //{
                //   ptTable = new Point3d(xTable, 28.0, 0.0);
                //}
            }
            else
            {
                ptTable = ptMtextCenter;
            }

            Table table = new Table();
            table.Position = ptTable;
            table.TableStyle = db.GetTableStylePIK();

            table.SetSize(3, 3);

            table.DeleteRows(0, 1);

            table.Rows[0].Height = 8;

            table.Columns[0].Width = 30;
            table.Columns[1].Width = 20;
            table.Columns[2].Width = 20;

            table.Columns[0].Alignment = CellAlignment.MiddleCenter;
            table.Columns[1].Alignment = CellAlignment.MiddleCenter;
            table.Columns[2].Alignment = CellAlignment.MiddleCenter;

            table.Cells[0, 0].TextString = "Наименование";
            table.Cells[0, 1].TextString = "Цвет";
            table.Cells[0, 2].TextString = "Кол-во, м.п.";

            table.Cells[1, 0].TextString = "АА-1347"; //markSB.Album.AlbumInfo?.ProfileTile?.ProfileTileName;// "АА-1347";
            table.Cells[1, 1].TextString = "RAL-7044";// markSB.Album.AlbumInfo?.ProfileTile?.ProfileTileMark;// "RAL-7044";
            table.Cells[1, 2].TextString = lenProfile.ToString();

            table.Rows[1].Borders.Bottom.LineWeight = LineWeight.LineWeight030;

            return table;
        }