Esempio n. 1
0
        private bool InternReadBlockEntities(ref int rlngIdx, ref AcadBlock robjAcadBlock, ref string nrstrErrMsg)
        {
            nrstrErrMsg = null;
            bool             dblnError            = default(bool);
            bool             dblnStop             = default(bool);
            AcadPolyfaceMesh dobjAcadPolyfaceMesh = default(AcadPolyfaceMesh);
            AcadPolygonMesh  dobjAcadPolygonMesh  = default(AcadPolygonMesh);
            Acad3DPolyline   dobjAcad3DPolyline   = default(Acad3DPolyline);
            AcadPolyline     dobjAcadPolyline     = default(AcadPolyline);

            while (rlngIdx <= mlngSecEnd && !dblnError && !dblnStop)
            {
                int    dlngCode2  = Conversions.ToInteger(mobjDictReadCodes[rlngIdx]);
                object dvarValue2 = RuntimeHelpers.GetObjectValue(mobjDictReadValues[rlngIdx]);
                if (dlngCode2 == 0 && Operators.ConditionalCompareObjectEqual(dvarValue2, "ENDBLK", TextCompare: false))
                {
                    dblnStop = true;
                }
                InternIncreaseIndex(ref rlngIdx, 1);
                if (dblnStop)
                {
                    continue;
                }
                object left = dvarValue2;
                if (Operators.ConditionalCompareObjectEqual(left, "ARC", TextCompare: false))
                {
                    dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadArc(mobjAcadDatabase, ref rlngIdx, ref robjAcadBlock, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                    InternCheckIndex(rlngIdx);
                }
                else if (Operators.ConditionalCompareObjectEqual(left, "CIRCLE", TextCompare: false))
                {
                    dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadCircle(mobjAcadDatabase, ref rlngIdx, ref robjAcadBlock, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                    InternCheckIndex(rlngIdx);
                }
                else if (Operators.ConditionalCompareObjectEqual(left, "LINE", TextCompare: false))
                {
                    dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadLine(mobjAcadDatabase, ref rlngIdx, ref robjAcadBlock, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                    InternCheckIndex(rlngIdx);
                }
                else if (Operators.ConditionalCompareObjectEqual(left, "POINT", TextCompare: false))
                {
                    dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadPoint(mobjAcadDatabase, ref rlngIdx, ref robjAcadBlock, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                    InternCheckIndex(rlngIdx);
                }
                else if (Operators.ConditionalCompareObjectEqual(left, "XLINE", TextCompare: false))
                {
                    dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadXline(mobjAcadDatabase, ref rlngIdx, ref robjAcadBlock, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                    InternCheckIndex(rlngIdx);
                }
                else if (Operators.ConditionalCompareObjectEqual(left, "RAY", TextCompare: false))
                {
                    dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadRay(mobjAcadDatabase, ref rlngIdx, ref robjAcadBlock, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                    InternCheckIndex(rlngIdx);
                }
                else if (Operators.ConditionalCompareObjectEqual(left, "LWPOLYLINE", TextCompare: false))
                {
                    dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadLWPolyline(mobjAcadDatabase, ref rlngIdx, ref robjAcadBlock, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                    InternCheckIndex(rlngIdx);
                }
                else if (Operators.ConditionalCompareObjectEqual(left, "POLYLINE", TextCompare: false))
                {
                    int dlngAcadPolylineIdx = rlngIdx;
                    dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadPolyline(ref dobjAcadPolyline, ref dobjAcad3DPolyline, ref dobjAcadPolygonMesh, ref dobjAcadPolyfaceMesh, mobjAcadDatabase, ref rlngIdx, ref robjAcadBlock, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                    InternCheckIndex(rlngIdx);
                    if (dblnError)
                    {
                        continue;
                    }
                    bool dblnAcadPolyline = true;
                    while (rlngIdx <= mlngSecEnd && !dblnError && dblnAcadPolyline)
                    {
                        dlngCode2  = Conversions.ToInteger(mobjDictReadCodes[rlngIdx]);
                        dvarValue2 = RuntimeHelpers.GetObjectValue(mobjDictReadValues[rlngIdx]);
                        if (dlngCode2 != 0)
                        {
                            nrstrErrMsg = "Fehlender Objektnamencode in Zeile " + Conversions.ToString(checked (rlngIdx * 2 + 1)) + ".";
                            dblnError   = true;
                            continue;
                        }
                        InternIncreaseIndex(ref rlngIdx, 1);
                        object left2 = dvarValue2;
                        if (Operators.ConditionalCompareObjectEqual(left2, "VERTEX", TextCompare: false))
                        {
                            dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadVertex(mobjAcadDatabase, ref rlngIdx, ref dobjAcadPolyline, ref dobjAcad3DPolyline, ref dobjAcadPolygonMesh, ref dobjAcadPolyfaceMesh, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                            InternCheckIndex(rlngIdx);
                        }
                        else if (Operators.ConditionalCompareObjectEqual(left2, "SEQEND", TextCompare: false))
                        {
                            AcadDatabase       vobjAcadDatabase       = mobjAcadDatabase;
                            AcadBlockReference robjAcadBlockReference = null;
                            AcadMInsertBlock   robjAcadMInsertBlock   = null;
                            dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadSequenceEnd(vobjAcadDatabase, ref rlngIdx, ref robjAcadBlockReference, ref robjAcadMInsertBlock, ref dobjAcadPolyline, ref dobjAcad3DPolyline, ref dobjAcadPolygonMesh, ref dobjAcadPolyfaceMesh, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                            InternCheckIndex(rlngIdx);
                            dblnAcadPolyline = false;
                            dobjAcadPolyline?.FriendCalcSize();
                            dobjAcad3DPolyline?.FriendCalcSize();
                            dobjAcadPolyline     = null;
                            dobjAcad3DPolyline   = null;
                            dobjAcadPolygonMesh  = null;
                            dobjAcadPolyfaceMesh = null;
                        }
                        else
                        {
                            nrstrErrMsg = "Polylinie ohne Sequenzende ab Zeile " + Conversions.ToString(dlngAcadPolylineIdx) + ".";
                            dblnError   = true;
                        }
                    }
                }
                else if (Operators.ConditionalCompareObjectEqual(left, "MTEXT", TextCompare: false))
                {
                    dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadMText(mobjAcadDatabase, ref rlngIdx, ref robjAcadBlock, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                    InternCheckIndex(rlngIdx);
                }
                else if (Operators.ConditionalCompareObjectEqual(left, "TEXT", TextCompare: false))
                {
                    dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadText(mobjAcadDatabase, ref rlngIdx, ref robjAcadBlock, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                    InternCheckIndex(rlngIdx);
                }
                else if (Operators.ConditionalCompareObjectEqual(left, "ATTDEF", TextCompare: false))
                {
                    dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadAttributeDefinition(mobjAcadDatabase, ref rlngIdx, ref robjAcadBlock, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                    InternCheckIndex(rlngIdx);
                }
                else if (Operators.ConditionalCompareObjectEqual(left, "INSERT", TextCompare: false))
                {
                    dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadBlockReference(mobjAcadDatabase, ref rlngIdx, ref robjAcadBlock, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                    InternCheckIndex(rlngIdx);
                }
                else if (Operators.ConditionalCompareObjectEqual(left, "SHAPE", TextCompare: false))
                {
                    dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadShape(mobjAcadDatabase, ref rlngIdx, ref robjAcadBlock, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                    InternCheckIndex(rlngIdx);
                }
                else if (Operators.ConditionalCompareObjectEqual(left, "ELLIPSE", TextCompare: false))
                {
                    dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadEllipse(mobjAcadDatabase, ref rlngIdx, ref robjAcadBlock, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                    InternCheckIndex(rlngIdx);
                }
                else if (Operators.ConditionalCompareObjectEqual(left, "HATCH", TextCompare: false))
                {
                    dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadHatch(mobjAcadDatabase, ref rlngIdx, ref robjAcadBlock, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                    InternCheckIndex(rlngIdx);
                }
                else if (Operators.ConditionalCompareObjectEqual(left, "SPLINE", TextCompare: false))
                {
                    dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadSpline(mobjAcadDatabase, ref rlngIdx, ref robjAcadBlock, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                    InternCheckIndex(rlngIdx);
                }
                else if (Operators.ConditionalCompareObjectEqual(left, "TRACE", TextCompare: false))
                {
                    dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadTrace(mobjAcadDatabase, ref rlngIdx, ref robjAcadBlock, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                    InternCheckIndex(rlngIdx);
                }
                else if (Operators.ConditionalCompareObjectEqual(left, "SOLID", TextCompare: false))
                {
                    dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadSolid(mobjAcadDatabase, ref rlngIdx, ref robjAcadBlock, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                    InternCheckIndex(rlngIdx);
                }
                else
                {
                    dblnError = !hwpDxf_ReadEnt.BkDXFReadEnt_AcadUnknownEnt(mlngSecEnd, Conversions.ToString(dvarValue2), mobjAcadDatabase, ref rlngIdx, ref robjAcadBlock, mobjDictReadCodes, mobjDictReadValues, ref nrstrErrMsg);
                    InternCheckIndex(rlngIdx);
                }
            }
            bool InternReadBlockEntities = !dblnError;

            dobjAcadPolyfaceMesh = null;
            dobjAcadPolygonMesh  = null;
            dobjAcad3DPolyline   = null;
            dobjAcadPolyline     = null;
            return(InternReadBlockEntities);
        }
Esempio n. 2
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();
        }
Esempio n. 3
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();
        }