Ejemplo n.º 1
0
        public override void DrawCADObject(Autodesk.AutoCAD.Interop.AcadDocument AcadDoc)
        {
            double pX = double.Parse(this.X);
            double pY = double.Parse(this.Y);

            double[] InsertPoint = new double[] { pX, pY, 0 };

            string BlockName = "一般管线点";
            int    LayerID   = GetLayerIndex("0", AcadDoc);


            //string TrueType = GetTrueType(this.Type);
            if (this.Type == "雨水篦")
            {
                BlockName = "雨篦";
            }
            else if (this.Type == "检修井")
            {
                BlockName = "排水检修井";
            }
            else if (this.Type == "出水口")
            {
                BlockName = "出水口";
            }
            if (!string.IsNullOrEmpty(this.Type))
            {
                if (this.SURVEY_ID.StartsWith("WS"))
                {
                    LayerID = GetLayerIndex("WSPoint", AcadDoc);
                }
                else if (this.SURVEY_ID.StartsWith("YS"))
                {
                    LayerID = GetLayerIndex("YSPoint", AcadDoc);
                }
            }


            AcadDoc.ActiveLayer = AcadDoc.Layers.Item(LayerID);

            AcadMInsertBlock pAcadMInsertBlock = AcadDoc.ModelSpace.AddMInsertBlock(InsertPoint, BlockName, 1, 1, 1, 0, 1, 1, 1, 1);

            //pAcadMInsertBlock.TrueColor.SetRGB(255, 255, 255);
            AcadDictionary pAcadDictionary = pAcadMInsertBlock.GetExtensionDictionary();

            //pAcadDictionary.AddXRecord(ClassName);
            pAcadDictionary.AddXRecord(this.ID);

            LayerID = GetLayerIndex("0", AcadDoc);
            if (!string.IsNullOrEmpty(this.Type))
            {
                if (this.SURVEY_ID.StartsWith("WS"))
                {
                    LayerID = GetLayerIndex("WSText", AcadDoc);
                }
                else if (this.SURVEY_ID.StartsWith("YS"))
                {
                    LayerID = GetLayerIndex("YSText", AcadDoc);
                }
            }
            AcadDoc.ActiveLayer = AcadDoc.Layers.Item(LayerID);

            AcadText pAcadText = AcadDoc.ModelSpace.AddText(this.SURVEY_ID, InsertPoint, 2.0);

            pAcadDictionary = pAcadText.GetExtensionDictionary();
            //pAcadDictionary.AddXRecord(ClassName);
            pAcadDictionary.AddXRecord(this.ID);
            AcadDoc.Save();
        }
Ejemplo n.º 2
0
        public override void DrawCADObject(Autodesk.AutoCAD.Interop.AcadDocument AcadDoc)
        {
            string Linetype = "合流";
            int    LayerID  = GetLayerIndex("YSLine", AcadDoc);

            if (this.US_SURVEY_ID.StartsWith("WS"))
            {
                LayerID  = GetLayerIndex("WSLine", AcadDoc);
                Linetype = "污水";
            }
            else if (this.US_SURVEY_ID.StartsWith("YS"))
            {
                Linetype = "雨水";
            }
            AcadDoc.ActiveLayer = AcadDoc.Layers.Item(LayerID);

            IPCPoint SPoint = GetPointByID(this.US_SURVEY_ID);
            IPCPoint EPoint = GetPointByID(this.DS_SURVEY_ID);

            double[] StartPoint = new double[3] {
                double.Parse(SPoint.X), double.Parse(SPoint.Y), 0
            };
            double[] EndPoint = new double[3] {
                double.Parse(EPoint.X), double.Parse(EPoint.Y), 0
            };
            AcadLine       pAcadLine       = AcadDoc.ModelSpace.AddLine(StartPoint, EndPoint);
            AcadDictionary pAcadDictionary = pAcadLine.GetExtensionDictionary();

            //pAcadDictionary.AddXRecord(ClassName);
            pAcadDictionary.AddXRecord(ID);

            string MinArrowVal = CIni.ReadINI("DrawCAD", "ArrowMin");
            bool   IsDrawArrow = false;

            if (string.IsNullOrEmpty(MinArrowVal))
            {
                IsDrawArrow = true;
            }
            else
            {
                double MinArrow = double.Parse(MinArrowVal);
                if (pAcadLine.Length < MinArrow)
                {
                    IsDrawArrow = false;
                }
                else
                {
                    IsDrawArrow = true;
                }
            }
            double[] MidPoint = new double[3] {
                (double.Parse(SPoint.X) + double.Parse(EPoint.X)) / 2, (double.Parse(SPoint.Y) + double.Parse(EPoint.Y)) / 2, 0
            };
            if (IsDrawArrow)
            {
                string           WidthValue = this.Width;
                AcadMInsertBlock pBlock     = AcadDoc.ModelSpace.AddMInsertBlock(MidPoint, "GP4", 1, 1, 1, 0, 1, 1, 1, 1);
                pBlock.Rotate(MidPoint, pAcadLine.Angle);
                pAcadDictionary = pBlock.GetExtensionDictionary();
                pAcadDictionary.AddXRecord(ID);
            }
            string MinLableVal = CIni.ReadINI("DrawCAD", "LableMin");

            if (!string.IsNullOrEmpty(MinLableVal))
            {
                double MinLable = double.Parse(MinLableVal);
                if (pAcadLine.Length < MinLable)
                {
                    return;
                }
            }
            string pUS_INVERT_LEVEL = double.Parse(SPoint.INVERT_LEVEL).ToString("0.000");
            string pDS_INVERT_LEVEL = double.Parse(EPoint.INVERT_LEVEL).ToString("0.000");
            string LineLable        = string.Format("{0} {1}m {2}Φ{3} {4}m", Linetype, pUS_INVERT_LEVEL, this.MATERIAL, this.Width, pDS_INVERT_LEVEL);

            LayerID = GetLayerIndex("YSZJ", AcadDoc);
            if (this.US_SURVEY_ID.StartsWith("WS"))
            {
                LayerID = GetLayerIndex("WSZJ", AcadDoc);
            }
            else
            {
                LayerID = GetLayerIndex("YSZJ", AcadDoc);
            }
            AcadDoc.ActiveLayer = AcadDoc.Layers.Item(LayerID);

            AcadText pAcadText = AcadDoc.ModelSpace.AddText(LineLable, MidPoint, 2.0);
            double   LineAngle = pAcadLine.Angle;

            if (LineAngle > Math.PI / 2 && LineAngle < 3 * Math.PI / 2)
            {
                LineAngle = LineAngle - Math.PI;
            }
            pAcadText.Rotate(MidPoint, LineAngle);
            pAcadDictionary = pAcadText.GetExtensionDictionary();
            //pAcadDictionary.AddXRecord(ClassName);
            pAcadDictionary.AddXRecord(ID);
            //}

            AcadDoc.Save();
        }