Esempio n. 1
0
        /// <summary>
        /// 绘制断面、量表
        /// </summary>
        /// <param name="db"></param>
        /// <param name="AnchorPoint"></param>
        public void PlotB(Database db, Point2d AnchorPoint)
        {
            int ScaleB = 50;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTable       blockTbl = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
                BlockTableRecord ms       = tr.GetObject(blockTbl[BlockTableRecord.ModelSpace],
                                                         OpenMode.ForWrite) as BlockTableRecord;
                DimStyleTable dst      = (DimStyleTable)tr.GetObject(db.DimStyleTableId, OpenMode.ForRead);
                string        blkname  = string.Format("T321-C{0}L{1}", Columns, Layers);
                ObjectId      blkRecId = blockTbl[blkname];
                using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(), blkRecId))
                {
                    ms.AppendEntity(acBlkRef);
                    tr.AddNewlyCreatedDBObject(acBlkRef, true);
                }
                tr.Commit();
            }

            // 图名
            TextPloter.PrintTitle(db, "标准横断面", AnchorPoint.Convert2D(0, 20 * ScaleB), ScaleB);
        }
Esempio n. 2
0
        /// <summary>
        /// 绘制平立面
        /// </summary>
        /// <param name="db"></param>
        /// <param name="AnchorPoint"></param>
        public double PlotA(Database db, Point2d AnchorPoint, int ScaleA = 0)
        {
            Transaction      tr       = db.TransactionManager.StartTransaction();
            BlockTable       blockTbl = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
            BlockTableRecord ms       = tr.GetObject(blockTbl[BlockTableRecord.ModelSpace],
                                                     OpenMode.ForWrite) as BlockTableRecord;
            DimStyleTable dst = (DimStyleTable)tr.GetObject(db.DimStyleTableId, OpenMode.ForRead);

            if (ScaleA == 0)
            {
                ScaleA = GetScaleA();
            }
            double dy = ScaleA * -50;

            // 立面图
            ObjectId blkRecId = blockTbl["T321-1"];
            ObjectId HLJJ     = blockTbl["T321-HLJJ"];
            ObjectId QMB      = blockTbl["T321-QMB"];
            ObjectId HL       = blockTbl["T321-HL-C" + Columns.ToString()];
            ObjectId T321PM   = blockTbl["T321-2"];
            ObjectId XZ       = blockTbl["T321-XZ"];
            ObjectId QZC1     = blockTbl["T321-QZ-C1"];
            ObjectId QZC1R    = blockTbl["T321-QZ-C1R"];
            ObjectId QZC2     = blockTbl["T321-QZ-C2"];
            ObjectId QZC2R    = blockTbl["T321-QZ-C2R"];
            ObjectId ZBC1     = blockTbl["T321-ZB-C1"];
            ObjectId ZBC2     = blockTbl["T321-ZB-C2"];
            ObjectId ZBC3     = blockTbl["T321-ZB-C3"];
            ObjectId ZBC3L    = blockTbl["T321-ZB-C3L"];
            ObjectId ZCJ      = blockTbl["T321-ZCJ-2"];
            ObjectId KFLG     = blockTbl["T321-KFLG"];
            ObjectId QMB2     = blockTbl["T321-QMB-2"];
            ObjectId JQXG     = blockTbl["T321-JQXG"];

            // 立面桁架
            for (int i = 0; i < Pieces; i++)
            {
                for (int j = 0; j < Layers; j++)
                {
                    using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(0 + i * 3000, 0 + j * 1500), blkRecId))
                    {
                        ms.AppendEntity(acBlkRef);
                        tr.AddNewlyCreatedDBObject(acBlkRef, true);
                    }
                    if (IsEnhence && i != 0 && i != (Pieces - 1))
                    {
                        if (j == 0)
                        {
                            using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(0 + i * 3000, 0 + j * 1500 - 100), JQXG))
                            {
                                ms.AppendEntity(acBlkRef);
                                tr.AddNewlyCreatedDBObject(acBlkRef, true);
                            }
                        }
                        else if (j == Layers - 1)
                        {
                            using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(0 + i * 3000, 0 + j * 1500 + 1500), JQXG))
                            {
                                ms.AppendEntity(acBlkRef);
                                tr.AddNewlyCreatedDBObject(acBlkRef, true);
                            }
                        }
                    }



                    if (j == 0)
                    {
                        using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(1413 + i * 3000, 328), HLJJ))
                        {
                            ms.AppendEntity(acBlkRef);
                            tr.AddNewlyCreatedDBObject(acBlkRef, true);
                        }
                        using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(1413 + i * 3000, dy), HL))
                        {
                            ms.AppendEntity(acBlkRef);
                            tr.AddNewlyCreatedDBObject(acBlkRef, true);
                        }
                        using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(1413 + 1410 + i * 3000, 328), HLJJ))
                        {
                            ms.AppendEntity(acBlkRef);
                            tr.AddNewlyCreatedDBObject(acBlkRef, true);
                        }
                        using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(1413 + 1410 + i * 3000, dy), HL))
                        {
                            ms.AppendEntity(acBlkRef);
                            tr.AddNewlyCreatedDBObject(acBlkRef, true);
                        }
                        using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(1323 + i * 3000, 553), QMB))
                        {
                            ms.AppendEntity(acBlkRef);
                            tr.AddNewlyCreatedDBObject(acBlkRef, true);
                        }
                    }
                }
            }
            blkRecId = blockTbl["T321-ZCJ-1"];
            double offsetZCJ = 0.0;

            if (Columns != 1)
            {
                for (int i = 0; i < Pieces; i++)
                {
                    if (IsEnhence)
                    {
                        if (i == 0 || i == (Pieces - 1))
                        {
                            offsetZCJ = 0;
                        }
                        else
                        {
                            offsetZCJ = 100;
                        }
                    }
                    using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(910 + i * 3000, (Layers) * 1500 - 70 + offsetZCJ), blkRecId))
                    {
                        ms.AppendEntity(acBlkRef);
                        tr.AddNewlyCreatedDBObject(acBlkRef, true);
                    }
                }
            }

            blkRecId = blockTbl["T321-YTDZ"];
            using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(), blkRecId))
            {
                ms.AppendEntity(acBlkRef);
                tr.AddNewlyCreatedDBObject(acBlkRef, true);
            }
            blkRecId = blockTbl["T321-HL-1"];
            using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(-157, 58), blkRecId))
            {
                ms.AppendEntity(acBlkRef);
                tr.AddNewlyCreatedDBObject(acBlkRef, true);
            }
            using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(-157, dy), HL))
            {
                ms.AppendEntity(acBlkRef);
                tr.AddNewlyCreatedDBObject(acBlkRef, true);
            }



            blkRecId = blockTbl["T321-ITDZ"];
            using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(Pieces * 3000.0), blkRecId))
            {
                ms.AppendEntity(acBlkRef);
                tr.AddNewlyCreatedDBObject(acBlkRef, true);
            }
            blkRecId = blockTbl["T321-QZ"];
            using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(Pieces * 3000.0 + 37, -145), blkRecId))
            {
                ms.AppendEntity(acBlkRef);
                tr.AddNewlyCreatedDBObject(acBlkRef, true);
            }
            using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(-37, -145), blkRecId))
            {
                ms.AppendEntity(acBlkRef);
                tr.AddNewlyCreatedDBObject(acBlkRef, true);
            }
            blkRecId = blockTbl["T321-ZB"];
            using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(Pieces * 3000.0 + 37, -297), blkRecId))
            {
                ms.AppendEntity(acBlkRef);
                tr.AddNewlyCreatedDBObject(acBlkRef, true);
            }
            using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(-37, -297), blkRecId))
            {
                ms.AppendEntity(acBlkRef);
                tr.AddNewlyCreatedDBObject(acBlkRef, true);
            }


            // 平面桁架
            for (int k = 0; k < 2; k++)
            {
                double sidey = (-4200) * k;
                int    dir   = k == 0 ? 1 : -1;
                for (int i = 0; i < Columns; i++)
                {
                    double cy;
                    if (i == 0)
                    {
                        cy = 0;
                    }
                    else if (i == 1)
                    {
                        cy = dir * 450;
                    }
                    else
                    {
                        cy = (450 + 250) * dir;
                    }

                    for (int j = 0; j < Pieces; j++)
                    {
                        using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(j * 3000, dy - 825 + sidey + cy), T321PM))
                        {
                            ms.AppendEntity(acBlkRef);
                            tr.AddNewlyCreatedDBObject(acBlkRef, true);
                        }
                        if (j != 0)
                        {
                            using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(j * 3000, dy - 825 + sidey + cy - 75.3), XZ))
                            {
                                ms.AppendEntity(acBlkRef);
                                tr.AddNewlyCreatedDBObject(acBlkRef, true);
                            }
                        }
                        if (i == 0)
                        {
                            if (Columns != 1)
                            {
                                using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(j * 3000 + 910, dy - 825 + sidey + dir * 450), ZCJ))
                                {
                                    if (dir == -1)
                                    {
                                        acBlkRef.TransformBy(Matrix3d.Mirroring(new Line3d(
                                                                                    AnchorPoint.Convert3D(j * 3000 + 910, dy - 825 + sidey + dir * 450),
                                                                                    AnchorPoint.Convert3D(j * 3000 + 910 + 100, dy - 825 + sidey + dir * 450)
                                                                                    )));
                                    }
                                    ms.AppendEntity(acBlkRef);
                                    tr.AddNewlyCreatedDBObject(acBlkRef, true);
                                }
                            }
                            if (k == 0)
                            {
                                if (j < 0.5 * Pieces)
                                {
                                    using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(j * 3000 + 329, dy - 825 + sidey), KFLG))
                                    {
                                        ms.AppendEntity(acBlkRef);
                                        tr.AddNewlyCreatedDBObject(acBlkRef, true);
                                    }
                                }
                                else
                                {
                                    using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(j * 3000 + 2821, dy - 825 + sidey - 180), QMB2))
                                    {
                                        ms.AppendEntity(acBlkRef);
                                        tr.AddNewlyCreatedDBObject(acBlkRef, true);
                                    }
                                }
                            }
                        }
                    }
                }

                if (Columns == 1)
                {
                    using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(-37, dy - 825 + sidey), QZC1))
                    {
                        ms.AppendEntity(acBlkRef);
                        tr.AddNewlyCreatedDBObject(acBlkRef, true);
                    }
                    using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(Pieces * 3000 + 37, dy - 825 + sidey), QZC1R))
                    {
                        ms.AppendEntity(acBlkRef);
                        tr.AddNewlyCreatedDBObject(acBlkRef, true);
                    }
                    using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(-37, dy - 825 + sidey), ZBC1))
                    {
                        acBlkRef.TransformBy(Matrix3d.Mirroring(new Line3d(
                                                                    AnchorPoint.Convert3D(-37, dy - 825 + sidey),
                                                                    AnchorPoint.Convert3D(-37, dy - 825 + sidey + 100)
                                                                    )));
                        ms.AppendEntity(acBlkRef);
                        tr.AddNewlyCreatedDBObject(acBlkRef, true);
                    }
                    using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(37 + Pieces * 3000, dy - 825 + sidey), ZBC1))
                    {
                        ms.AppendEntity(acBlkRef);
                        tr.AddNewlyCreatedDBObject(acBlkRef, true);
                    }
                }

                else if (Columns == 2)
                {
                    using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(-37, dy - 825 + sidey), QZC1))
                    {
                        ms.AppendEntity(acBlkRef);
                        tr.AddNewlyCreatedDBObject(acBlkRef, true);
                    }
                    using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(-37, dy - 825 + sidey + dir * 450), QZC1))
                    {
                        ms.AppendEntity(acBlkRef);
                        tr.AddNewlyCreatedDBObject(acBlkRef, true);
                    }
                    using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(Pieces * 3000 + 37, dy - 825 + sidey), QZC1R))
                    {
                        ms.AppendEntity(acBlkRef);
                        tr.AddNewlyCreatedDBObject(acBlkRef, true);
                    }
                    using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(Pieces * 3000 + 37, dy - 825 + sidey + dir * 450), QZC1R))
                    {
                        ms.AppendEntity(acBlkRef);
                        tr.AddNewlyCreatedDBObject(acBlkRef, true);
                    }
                    using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(Pieces * 3000 + 37, dy - 825 + sidey + dir * 225), ZBC2))
                    {
                        ms.AppendEntity(acBlkRef);
                        tr.AddNewlyCreatedDBObject(acBlkRef, true);
                    }
                    using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(-37, dy - 825 + sidey + dir * 225), ZBC2))
                    {
                        acBlkRef.TransformBy(Matrix3d.Mirroring(new Line3d(AnchorPoint.Convert3D(-37, dy - 825 + sidey + dir * 225), AnchorPoint.Convert3D(-37, dy - 825 + sidey + dir * 225 + 100))));
                        ms.AppendEntity(acBlkRef);
                        tr.AddNewlyCreatedDBObject(acBlkRef, true);
                    }
                }
                else
                {
                    using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(-37, dy - 825 + sidey), QZC1))
                    {
                        ms.AppendEntity(acBlkRef);
                        tr.AddNewlyCreatedDBObject(acBlkRef, true);
                    }
                    using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(-37, dy - 825 + sidey + dir * (450 + 125)), QZC2))
                    {
                        ms.AppendEntity(acBlkRef);
                        tr.AddNewlyCreatedDBObject(acBlkRef, true);
                    }
                    using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(Pieces * 3000 + 37, dy - 825 + sidey), QZC1R))
                    {
                        ms.AppendEntity(acBlkRef);
                        tr.AddNewlyCreatedDBObject(acBlkRef, true);
                    }
                    using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(Pieces * 3000 + 37, dy - 825 + sidey + dir * (450 + 125)), QZC2R))
                    {
                        ms.AppendEntity(acBlkRef);
                        tr.AddNewlyCreatedDBObject(acBlkRef, true);
                    }

                    using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(Pieces * 3000 + 37, dy - 825 + sidey + dir * 350), ZBC3))
                    {
                        ms.AppendEntity(acBlkRef);
                        tr.AddNewlyCreatedDBObject(acBlkRef, true);
                    }

                    using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(-37, dy - 825 + sidey + dir * 350), ZBC3))
                    {
                        acBlkRef.TransformBy(Matrix3d.Mirroring(new Line3d(
                                                                    AnchorPoint.Convert3D(-37, dy - 825 + sidey + dir * 350),
                                                                    AnchorPoint.Convert3D(-37, dy - 825 + sidey + dir * 350 + 100)
                                                                    )));
                        if (dir == -1)
                        {
                            acBlkRef.TransformBy(Matrix3d.Mirroring(new Line3d(
                                                                        AnchorPoint.Convert3D(-37, dy - 825 + sidey + dir * 350),
                                                                        AnchorPoint.Convert3D(-37 + 100, dy - 825 + sidey + dir * 350)
                                                                        )));
                        }
                        ms.AppendEntity(acBlkRef);
                        tr.AddNewlyCreatedDBObject(acBlkRef, true);
                    }
                }
            }
            tr.Commit();
            tr.Dispose();

            // 标注


            var     DimStyleID = dst["1-" + ScaleA.ToString()];
            Point3d SW         = AnchorPoint.Convert3D();
            Point3d SE         = AnchorPoint.Convert3D(Pieces * 3000.0);
            Point3d NW         = SW.Convert3D(0, Layers * 1400 + (Layers - 1) * 100);
            Point3d NE         = SE.Convert3D(0, Layers * 1400 + (Layers - 1) * 100);
            Point3d CT         = NW.Convert3D(0.5 * Pieces * 3000.0);

            Point3d pNW = SW.Convert3D(0, dy - 825);
            Point3d pNE = SE.Convert3D(0, dy - 825);
            Point3d pSW = pNW.Convert3D(0, -4200);
            Point3d pSE = pNE.Convert3D(0, -4200);
            Point3d pCT = pNW.Convert3D(0.5 * Pieces * 3000.0);

            string stmp = string.Format("{0}×3000=<>", Pieces);

            DimPloter.Dim0(db, NW, NE, NE.Convert3D(0, 10 * ScaleA), DimStyleID, 0, stmp);
            DimPloter.Dim0(db, SW, NW, NW.Convert3D(-10 * ScaleA), DimStyleID, 0.5 * Math.PI);
            DimPloter.Dim0(db, SE, SE.Convert3D(0, 1400), SE.Convert3D(8 * ScaleA), DimStyleID, 0.5 * Math.PI);
            for (int i = 0; i < Layers - 1; i++)
            {
                DimPloter.Dim0(db, SE.Convert3D(0, 1500 * (i + 1) - 100), SE.Convert3D(0, 1500 * (i + 1)), SE.Convert3D(8 * ScaleA), DimStyleID, 0.5 * Math.PI);
                DimPloter.Dim0(db, SE.Convert3D(0, 1500 * (i + 1)), SE.Convert3D(0, 1500 * (i + 1) + 1400), SE.Convert3D(8 * ScaleA), DimStyleID, 0.5 * Math.PI);
            }
            DimPloter.Dim0(db, pSW, pSE, pSW.Convert3D(0, -15 * ScaleA), DimStyleID);
            DimPloter.Dim0(db, pSW, pNW, pNW.Convert3D(-10 * ScaleA), DimStyleID, 0.5 * Math.PI);

            double ymin = pSW.Convert3D(0, -15 * ScaleA).Y;

            // 图名

            TextPloter.PrintTitle(db, "立 面", CT.Convert2D(0, 25 * ScaleA), ScaleA);
            TextPloter.PrintTitle(db, "平 面", pCT.Convert2D(0, 20 * ScaleA), ScaleA);
            double ymax = CT.Convert2D(0, 25 * ScaleA).Y;

            return(ymax - AnchorPoint.Y);
        }