Пример #1
0
        private void GetEdgeInformation(Polyline pline, ref Curve2dCollection plCurves, ref IntegerCollection edgeTypes)
        {
            int segCount = pline.NumberOfVertices;

            for (int cnt = 0; cnt < segCount; cnt++)
            {
                SegmentType type = pline.GetSegmentType(cnt);

                switch (type)
                {
                case SegmentType.Arc:

                    CircularArc2d arc2d = pline.GetArcSegment2dAt(cnt);

                    plCurves.Add(arc2d);

                    edgeTypes.Add((int)Enum.Parse(typeof(HatchEdgeType),

                                                  HatchEdgeType.CircularArc.ToString()));

                    break;

                case SegmentType.Line:

                    LineSegment2d line2d = pline.GetLineSegment2dAt(cnt);

                    plCurves.Add(line2d);

                    edgeTypes.Add((int)Enum.Parse(typeof(HatchEdgeType),

                                                  HatchEdgeType.Line.ToString()));

                    break;

                case SegmentType.Coincident:

                    break;

                case SegmentType.Empty:

                    break;

                case SegmentType.Point:

                    break;
                }
            }
        }
Пример #2
0
        public static Curve2dCollection To2dCurve(this Grevit.Types.Component curve)
        {
            Curve2dCollection curveArray = new Curve2dCollection();

            if (curve.GetType() == typeof(Grevit.Types.Line))
            {
                Grevit.Types.Line baseline = (Grevit.Types.Line)curve;
                curveArray.Add(new Line2d(baseline.from.ToPoint2d(), baseline.to.ToPoint2d()));
            }
            else if (curve.GetType() == typeof(Grevit.Types.Arc))
            {
                Grevit.Types.Arc baseline = (Grevit.Types.Arc)curve;
                curveArray.Add(new CircularArc2d(baseline.center.ToPoint2d(), baseline.radius, baseline.start, baseline.end, Vector2d.XAxis, true));
            }
            else if (curve.GetType() == typeof(Grevit.Types.Curve3Points))
            {
                Grevit.Types.Curve3Points baseline = (Grevit.Types.Curve3Points)curve;
                curveArray.Add(new CircularArc2d(baseline.a.ToPoint2d(), baseline.c.ToPoint2d(), baseline.b.ToPoint2d()));
            }
            else if (curve.GetType() == typeof(Grevit.Types.PLine))
            {
                Grevit.Types.PLine baseline = (Grevit.Types.PLine)curve;
                for (int i = 0; i < baseline.points.Count - 1; i++)
                {
                    curveArray.Add(new Line2d(baseline.points[i].ToPoint2d(), baseline.points[i + 1].ToPoint2d()));
                }
            }
            else if (curve.GetType() == typeof(Grevit.Types.Spline))
            {
                Grevit.Types.Spline s      = (Grevit.Types.Spline)curve;
                Point2dCollection   points = new Point2dCollection();
                foreach (Grevit.Types.Point p in s.controlPoints)
                {
                    points.Add(p.ToPoint2d());
                }
                DoubleCollection dc = new DoubleCollection();
                foreach (double dbl in s.weights)
                {
                    dc.Add(dbl);
                }
                NurbCurve2d sp = new NurbCurve2d(s.degree, new KnotCollection(), points, dc, s.isPeriodic);
                curveArray.Add(sp);
            }

            return(curveArray);
        }
Пример #3
0
        /// <summary>
        /// Единообразное представление границы штриховки в виде набора некомпозитных кривых
        /// </summary>
        /// <param name="hl"></param>
        /// <returns></returns>
        public static List <Curve2d> GetHatchLoopCurves(HatchLoop hl)
        {
            BulgeVertexCollection bvc = hl.Polyline;
            Curve2dCollection     cc  = hl.Curves;
            //Перевод в общий набор Curve2d
            List <Curve2d> curves = new List <Curve2d>();

            if (bvc != null && bvc.Count > 0)
            {
                Point2d?prevPt              = null;
                double  prevBulge           = 0;
                Action <BulgeVertex> action = new Action <BulgeVertex>(bv =>
                {
                    if (prevPt != null)
                    {
                        Curve2d c = (prevBulge == 0 ?
                                     (Curve2d)(new LineSegment2d(prevPt.Value, bv.Vertex))
                            : (Curve2d)(new CircularArc2d(prevPt.Value, bv.Vertex, prevBulge, false)));
                        curves.Add(c);
                    }
                    prevPt    = bv.Vertex;
                    prevBulge = bv.Bulge;
                });
                foreach (BulgeVertex bv in bvc)
                {
                    action(bv);
                }
                foreach (BulgeVertex bv in bvc)//добавление замыкающего сегмента полилинии
                {
                    action(bv);
                    break;
                }
            }
            else if (cc != null && cc.Count > 0)
            {
                foreach (Curve2d c in cc)
                {
                    curves.Add(c);
                }
            }

            return(curves);
        }
Пример #4
0
        public static Curve2dCollection To2dCurve(this Grevit.Types.Component curve)
        {
            Curve2dCollection curveArray = new Curve2dCollection();

            if (curve.GetType() == typeof(Grevit.Types.Line))
            {
                Grevit.Types.Line baseline = (Grevit.Types.Line)curve;
                curveArray.Add(new Line2d(baseline.from.ToPoint2d(), baseline.to.ToPoint2d()));
            }
            else if (curve.GetType() == typeof(Grevit.Types.Arc))
            {
                Grevit.Types.Arc baseline = (Grevit.Types.Arc)curve;
                curveArray.Add(new CircularArc2d(baseline.center.ToPoint2d(), baseline.radius, baseline.start, baseline.end, Vector2d.XAxis, true));
            }
            else if (curve.GetType() == typeof(Grevit.Types.Curve3Points))
            {
                Grevit.Types.Curve3Points baseline = (Grevit.Types.Curve3Points)curve;
                curveArray.Add(new CircularArc2d(baseline.a.ToPoint2d(), baseline.c.ToPoint2d(), baseline.b.ToPoint2d()));
            }
            else if (curve.GetType() == typeof(Grevit.Types.PLine))
            {
                Grevit.Types.PLine baseline = (Grevit.Types.PLine)curve;
                for (int i = 0; i < baseline.points.Count - 1; i++)
                {
                    curveArray.Add(new Line2d(baseline.points[i].ToPoint2d(), baseline.points[i + 1].ToPoint2d()));
                }
            }
            else if (curve.GetType() == typeof(Grevit.Types.Spline))
            {
                Grevit.Types.Spline s = (Grevit.Types.Spline)curve;
                Point2dCollection points = new Point2dCollection();
                foreach (Grevit.Types.Point p in s.controlPoints) points.Add(p.ToPoint2d());
                DoubleCollection dc = new DoubleCollection();
                foreach (double dbl in s.weights) dc.Add(dbl);
                NurbCurve2d sp = new NurbCurve2d(s.degree, new KnotCollection(), points, dc, s.isPeriodic);
                curveArray.Add(sp);
            }

            return curveArray;
        }
Пример #5
0
        public static void DrawBorder(ArrayList hats, Transaction trans, BlockTableRecord btr, int numSample, Editor ed)
        {
            ArrayList two = new ArrayList();

            System.Collections.Generic.Dictionary <string, string> result = new System.Collections.Generic.Dictionary <string, string>();
            ArrayList attrlist = new ArrayList();

            foreach (Hatch hat in hats)
            {
                ArrayList one = new ArrayList();

                //取得边界数
                int loopNum = hat.NumberOfLoops;
                Point2dCollection     col_point2d = new Point2dCollection();
                BulgeVertexCollection col_ver     = new BulgeVertexCollection();
                Curve2dCollection     col_cur2d   = new Curve2dCollection();

                for (int i = 0; i < loopNum; i++)
                {
                    col_point2d.Clear();
                    HatchLoop hatLoop = null;
                    try
                    {
                        hatLoop = hat.GetLoopAt(i);
                    }
                    catch (System.Exception)
                    {
                        continue;
                    }

                    //如果HatchLoop为PolyLine
                    if (hatLoop.IsPolyline)
                    {
                        col_ver = hatLoop.Polyline;
                        foreach (BulgeVertex vertex in col_ver)
                        {
                            col_point2d.Add(vertex.Vertex);
                        }
                    }
                    //如果HatchLoop为Curves
                    else
                    {
                        col_cur2d = hatLoop.Curves;
                        foreach (Curve2d item in col_cur2d)
                        {
                            Point2d[] M_point2d = item.GetSamplePoints(numSample);
                            foreach (Point2d point in M_point2d)
                            {
                                if (!col_point2d.Contains(point))
                                {
                                    col_point2d.Add(point);
                                }
                            }
                        }
                    }

                    //根据获得的Point2d点集创建闭合Polyline
                    //Polyline pl = new Polyline();
                    //pl.Closed = true;
                    //pl.Color = hat.Color;
                    //PolylineTools.CreatePolyline(pl, col_point2d);
                    //btr.AppendEntity(pl);
                    //trans.AddNewlyCreatedDBObject(pl, true);
                    double[] one_0 = new double[2];

                    foreach (Point2d point in col_point2d)
                    {
                        double X = Math.Round(point.X, 7) + 4000000;
                        double Y = Math.Round(point.Y, 7) + 38500000;

                        //double X = 60146 + 4000000;
                        //double Y = 34953 + 38500000;

                        //  由高斯投影坐标反算成经纬度
                        int      ProjNo; int ZoneWide;                                  ////带宽
                        double[] output = new double[2];
                        double   longitude1, latitude1, longitude0, X0, Y0, xval, yval; //latitude0,
                        double   e1, e2, f, a, ee, NN, T, C, M, D, R, u, fai, iPI;
                        iPI = 0.0174532925199433;                                       ////3.1415926535898/180.0;
                        a   = 6378245.0; f = 1.0 / 298.3;                               //54年北京坐标系参数
                        //a = 6378140.0; f = 1 / 298.257; //80年西安坐标系参数
                        ZoneWide   = 6;                                                 ////6度带宽
                        ProjNo     = (int)(X / 1000000L);                               //查找带号
                        longitude0 = (ProjNo - 1) * ZoneWide + ZoneWide / 2;
                        longitude0 = longitude0 * iPI;                                  //中央经线

                        X0   = ProjNo * 1000000L + 500000L;
                        Y0   = 0;
                        xval = X - X0; yval = Y - Y0; //带内大地坐标
                        e2   = 2 * f - f * f;
                        e1   = (1.0 - Math.Sqrt(1 - e2)) / (1.0 + Math.Sqrt(1 - e2));
                        ee   = e2 / (1 - e2);
                        M    = yval;
                        u    = M / (a * (1 - e2 / 4 - 3 * e2 * e2 / 64 - 5 * e2 * e2 * e2 / 256));
                        fai  = u + (3 * e1 / 2 - 27 * e1 * e1 * e1 / 32) * Math.Sin(2 * u) + (21 * e1 * e1 / 16 - 55 * e1 * e1 * e1 * e1 / 32) * Math.Sin(4 * u)
                               + (151 * e1 * e1 * e1 / 96) * Math.Sin(6 * u) + (1097 * e1 * e1 * e1 * e1 / 512) * Math.Sin(8 * u);
                        C  = ee * Math.Cos(fai) * Math.Cos(fai);
                        T  = Math.Tan(fai) * Math.Tan(fai);
                        NN = a / Math.Sqrt(1.0 - e2 * Math.Sin(fai) * Math.Sin(fai));
                        R  = a * (1 - e2) / Math.Sqrt((1 - e2 * Math.Sin(fai) * Math.Sin(fai)) * (1 - e2 * Math.Sin(fai) * Math.Sin(fai)) * (1 - e2 * Math.Sin
                                                                                                                                                 (fai) * Math.Sin(fai)));
                        D = xval / NN;
                        //计算经度(Longitude) 纬度(Latitude)
                        longitude1 = longitude0 + (D - (1 + 2 * T + C) * D * D * D / 6 + (5 - 2 * C + 28 * T - 3 * C * C + 8 * ee + 24 * T * T) * D
                                                   * D * D * D * D / 120) / Math.Cos(fai);
                        latitude1 = fai - (NN * Math.Tan(fai) / R) * (D * D / 2 - (5 + 3 * T + 10 * C - 4 * C * C - 9 * ee) * D * D * D * D / 24
                                                                      + (61 + 90 * T + 298 * C + 45 * T * T - 256 * ee - 3 * C * C) * D * D * D * D * D * D / 720);
                        //转换为度 DD

                        // 现状图
                        output[0] = longitude1 / iPI + 108.7271360867638 + 0.0002173 - 11 + 0.00061422;
                        output[1] = latitude1 / iPI - 310.2659499330605 + 0.0009752 - 0.0002805;

                        //output[0] = Math.Round(point.X, 7);
                        //output[1] = Math.Round(point.Y, 7);

                        one_0 = new double[2] {
                            output[0], output[1]
                        };

                        one.Add(one_0);
                    }
                } // 单个hatch边界顶点循环结束

                two.Add(one);

                LayerTableRecord ltr = (LayerTableRecord)trans.GetObject(hat.LayerId, OpenMode.ForRead);

                string hatchColor = "hatchColor:" + ltr.Color;
                attrlist.Add(hatchColor);
            } // 所有的Hatch循环结束

            Hashtable geom = new Hashtable();

            geom.Add("rings", two);

            string geomString = string.Empty;

            geomString = JsonConvert.SerializeObject(geom);
            result.Add("geom", geomString);

            //string[] attrlist = new string[] { "componentcategoryType:61" };
            string[] factorid = new string[] { "b73e3fce-8314-4d5b-8e2b-0a3e8844b28b" };
            string   type     = "polygon";
            string   name     = "456";
            string   srid     = "4214";

            string attrlistString = string.Empty;

            attrlistString = JsonConvert.SerializeObject(attrlist);

            string factoridString = string.Empty;

            factoridString = JsonConvert.SerializeObject(factorid);

            result.Add("attrlist", attrlistString);
            result.Add("factorid", factoridString);
            result.Add("type", type);
            result.Add("srid", srid);
            result.Add("name", name);

            string JSONString = string.Empty;

            JSONString = JsonConvert.SerializeObject(result);

            MessageBox.Show(JSONString);

            using (StreamWriter file = new StreamWriter(@"C:\Users\Public\Documents\WriteLines2.json", false))
            {
                file.WriteLine(JSONString);
            }

            ed.WriteMessage("\nFound X:{0} ", JSONString);

            // 发送 开始
            var baseAddress = "http://172.18.84.192:8080/CIM/cim/geom!addCadGeomByType.action";

            var http = (HttpWebRequest)WebRequest.Create(new Uri(baseAddress));

            http.ContentType = "application/x-www-form-urlencoded";
            http.Method      = "POST";

            StringBuilder builder = new StringBuilder();
            int           h       = 0;

            foreach (var item in result)
            {
                if (h > 0)
                {
                    builder.Append("&");
                }
                builder.AppendFormat("{0}={1}", item.Key, item.Value);
                h++;
            }

            //string parsedContent = "srid=4326&attrlist=[\"chColor:51\"]&factorid=[\"b73e3fce-8314-4d5b-8e2b-0a3e8844b28b\"]&type=polygon&geom={\"rings\":[[[60145.4546169,33387.5339155],[59895.3137297,33437.8260557],[59885.7661656,33285.0286724],[59885.4849623,33280.5283488],[59902.1499232,33259.5545569],[59906.5973667,33258.8114325],[60127.4437563,33221.9101578],[60145.4546169,33387.5339155]]]}&name=123";
            ASCIIEncoding encoding = new ASCIIEncoding();

            Byte[] bytes = encoding.GetBytes(builder.ToString());

            Stream newStream = http.GetRequestStream();

            newStream.Write(bytes, 0, bytes.Length);
            newStream.Close();

            try
            {
                var response = http.GetResponse();

                var stream  = response.GetResponseStream();
                var sr      = new StreamReader(stream, Encoding.UTF8);
                var content = sr.ReadToEnd();

                MessageBox.Show(content);
            }
            catch (WebException ex)
            {
                if (ex.Status == WebExceptionStatus.ProtocolError)
                {
                    var response = ex.Response as HttpWebResponse;
                    if (response != null)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            // 发送 结束
        } // 发送方法结束
Пример #6
0
        public void CreateWallPolyLine()
        {
            bool B = true;

            do
            {
                try
                {
                    #region  택한 폴리선에서 각 선들 받기 [edgePtrs]
                    var edgePtrs  = new Curve2dCollection();
                    var edgeTypes = new IntegerCollection();

                    select.Objects <Polyline>().ForEach(p =>
                    {
                        GetEdgeInformation(p, ref edgePtrs, ref edgeTypes);
                    });

                    //using (Transaction t = AC.DB.TransactionManager.StartTransaction())
                    //{
                    //SelectionSet acSSet = SelectPolylines();

                    //if (acSSet == null)
                    //{
                    //    AC.Editor.PostCommandPrompt();
                    //    return;
                    //}

                    //var Polylines = from id in acSSet.GetObjectIds()
                    //                let acEnt = t.GetObject(id, OpenMode.ForWrite) as Entity
                    //                where acEnt is Polyline
                    //                let acPolyLine = acEnt as Polyline
                    //                select acPolyLine;

                    //if (Polylines.Any())
                    //{
                    //    Polylines.ToList().ForEach(p =>
                    //    {
                    //        GetEdgeInformation(p, ref edgePtrs, ref edgeTypes);
                    //    });
                    //}
                    //}
                    #endregion

                    var acPolylines = from a in edgePtrs.Cast <Curve2d>()
                                      orderby a.StartPoint.GetDistanceTo(a.EndPoint) descending
                                      select a;

                    var usedCurve = new List <Point2d>();

                    using (DocumentLock DL = AC.Doc.LockDocument())
                    {
                        acPolylines.Cast <Curve2d>().ToList().ForEach(c =>
                        {
                            var CenterP = point.GetCenterP(c.StartPoint, c.EndPoint);

                            var curves = from a in edgePtrs.Cast <Curve2d>().ToList()
                                         where a != c
                                         select a;

                            // c와 평행한 선을 받음
                            var MatchedCurves                 = from a in curves
                                                        let d = Math.Round(a.GetDistanceTo(c))
                                                                where CADUtil.GetVector(a).GetNormal().IsEqualTo(-CADUtil.GetVector(c).GetNormal())
                                                                where d >= Min && d <= Max
                                                                let cp1                     = CADUtil.GetCenterPoint2d(c)
                                                                                    let cp2 = CADUtil.GetCenterPoint2d(a)
                                                                                              orderby cp1.GetDistanceTo(cp2) ascending
                                                                                              select a;

                            if (MatchedCurves.Any())
                            {
                                //CAD.CreateLine(c.StartPoint, c.EndPoint);

                                bool B1 = true;

                                MatchedCurves.ToList().ForEach(c1 =>
                                {
                                    var cp1 = CADUtil.GetCenterPoint2d(c1);

                                    usedCurve.ForEach(cp2 =>
                                    {
                                        if (cp1.IsEqualTo(cp2))
                                        {
                                            B1 = false;
                                        }
                                    });
                                });

                                if (B1)
                                {
                                    CreateRectangle(c, MatchedCurves.ToList());

                                    usedCurve.Add(CADUtil.GetCenterPoint2d(c));
                                }
                            }
                        });
                    }
                }
                catch
                {
                    B = false;
                }
            } while (B);

            AC.Editor.WriteMessage("\n벽 입력완료 ");
            AC.Editor.PostCommandPrompt();
        }
Пример #7
0
        public static HatchModel Hatch2Model(Hatch dbText)
        {
            HatchModel dbModel = new HatchModel();

            int cont = dbText.NumberOfLoops;

            for (int i = 0; i < cont; i++)
            {
                dbModel.loopPoints.Add(i, new ColorAndPointItemModel());
                HatchLoop loop = dbText.GetLoopAt(i);

                ColorAndPointItemModel cpModel = new ColorAndPointItemModel();
                if (i == 0)
                {
                    cpModel.Color = dbText.ColorIndex == 256 ? MethodCommand.GetLayerColorByID(dbText.LayerId) : System.Drawing.ColorTranslator.ToHtml(dbText.Color.ColorValue);
                }
                else
                {
                    cpModel.Color = "#FFFFFF";
                    //  cpModel.ZIndex = "1";
                }

                //if (loop.Polyline.Count == 3)
                //{
                //}

                if (loop.IsPolyline && loop.Polyline.Count > 3)
                {
                    for (int j = 0; j < loop.Polyline.Count - 1; j++)
                    {
                        BulgeVertex vertex  = loop.Polyline[j];
                        BulgeVertex vertex1 = loop.Polyline[j + 1];
                        if (vertex.Bulge != 0)
                        {
                            cpModel.loopPoints.AddRange(MethodCommand.GetArcPointsByBulge(vertex.Vertex, vertex1.Vertex, vertex.Bulge));
                        }
                        else
                        {
                            cpModel.loopPoints.Add(Point2d2Pointf(vertex.Vertex));
                        }
                    }


                    if (dbText.NumberOfHatchLines > 0)
                    {
                        Line2dCollection cl = dbText.GetHatchLinesData();
                    } //foreach (Line2d itemi in )
                      //{

                    //}
                }
                else
                {
                    Curve2dCollection col_cur2d = loop.Curves;
                    foreach (Curve2d item in col_cur2d)
                    {
                        Point2d[] M_point2d = item.GetSamplePoints(20);
                        foreach (Point2d point in M_point2d)
                        {
                            cpModel.loopPoints.Add(Point2d2Pointf(point));
                        }
                    }
                }

                if (cpModel.loopPoints[0] != cpModel.loopPoints[cpModel.loopPoints.Count - 1])
                {
                    cpModel.loopPoints.Add(cpModel.loopPoints[0]);
                }
                dbModel.loopPoints[i] = cpModel;
            }

            for (int i = 0; i < dbModel.loopPoints.Count; i++)
            {
                for (int j = 0; j < dbModel.loopPoints.Count; j++)
                {
                    if (i != j)
                    {
                        if (MethodCommand.PointsAllInPoints(dbModel.loopPoints[j].loopPoints, dbModel.loopPoints[i].loopPoints))
                        {
                            dbModel.loopPoints[j].ZIndex = "2";
                        }
                    }
                }
            }
            try
            {
                dbModel.Area = dbText.Area;
            }
            catch
            { }
            //   dbModel.Color =
            return(dbModel);
        }
Пример #8
0
        public static HatchModel Hatch2Model(Hatch dbText, AttributeModel atModel)
        {
            HatchModel dbModel = new HatchModel();

            try
            {
                dbModel.Area = dbText.Area;
            }
            catch
            { }

            int    cont  = dbText.NumberOfLoops;
            string color = "";

            for (int i = 0; i < cont; i++)
            {
                dbModel.loopPoints.Add(i, new ColorAndPointItemModel());
                HatchLoop loop = dbText.GetLoopAt(i);

                ColorAndPointItemModel cpModel = new ColorAndPointItemModel();
                if (i == 0)
                {
                    color = cpModel.Color = dbText.ColorIndex == 256 ? MethodCommand.GetLayerColorByID(dbText.LayerId) : System.Drawing.ColorTranslator.ToHtml(dbText.Color.ColorValue);
                }
                else
                {
                    cpModel.Color = "#FFFFFF";
                    //  cpModel.ZIndex = "1";
                }
                if (loop.IsPolyline)
                {
                    for (int j = 0; j < loop.Polyline.Count - 1; j++)
                    {
                        BulgeVertex vertex  = loop.Polyline[j];
                        BulgeVertex vertex1 = loop.Polyline[j + 1];
                        if (vertex.Bulge != 0)
                        {
                            cpModel.loopPoints.AddRange(MethodCommand.GetArcPointsByBulge(vertex.Vertex, vertex1.Vertex, vertex.Bulge));
                        }
                        else
                        {
                            cpModel.loopPoints.Add(Point2d2Pointf(vertex.Vertex));
                        }
                    }


                    if (dbText.NumberOfHatchLines > 0)
                    {
                        Line2dCollection cl = dbText.GetHatchLinesData();
                    } //foreach (Line2d itemi in )
                      //{

                    //}
                }
                else
                {
                    Curve2dCollection col_cur2d = loop.Curves;
                    foreach (Curve2d item in col_cur2d)
                    {
                        Point2d[] M_point2d = item.GetSamplePoints(20);
                        foreach (Point2d point in M_point2d)
                        {
                            cpModel.loopPoints.Add(Point2d2Pointf(point));
                        }
                    }
                }

                if (cpModel.loopPoints[0] != cpModel.loopPoints[cpModel.loopPoints.Count - 1])
                {
                    cpModel.loopPoints.Add(cpModel.loopPoints[0]);
                }
                cpModel.attItemList = new List <AttributeItemModel>();
                foreach (AttributeItemModel item in atModel.attributeItems)
                {
                    string attValue = "";

                    switch (item.AtItemType)
                    {
                    case AttributeItemType.Area:
                        attValue = dbModel.Area.ToString();
                        break;

                    case AttributeItemType.TxtHeight:

                        break;

                    case AttributeItemType.Color:
                        attValue = color;
                        break;

                    case AttributeItemType.Content:

                        break;

                    case AttributeItemType.LayerName:
                        attValue = dbText.Layer;
                        break;

                    case AttributeItemType.LineScale:
                        attValue = dbText.LinetypeScale.ToString();
                        break;

                    case AttributeItemType.LineType:
                        attValue = GetLayerLineTypeByID(dbText);
                        break;

                    case AttributeItemType.Overallwidth:
                        break;

                    case AttributeItemType.TotalArea:
                        attValue = dbModel.Area.ToString();
                        break;
                    }
                    if (!string.IsNullOrEmpty(attValue))
                    {
                        item.AtValue = attValue;
                        cpModel.attItemList.Add(item);
                    }
                    else
                    {
                    }
                }
                dbModel.loopPoints[i] = cpModel;
            }

            for (int i = 0; i < dbModel.loopPoints.Count; i++)
            {
                for (int j = 0; j < dbModel.loopPoints.Count; j++)
                {
                    if (i != j)
                    {
                        if (MethodCommand.PointsAllInPoints(dbModel.loopPoints[j].loopPoints, dbModel.loopPoints[i].loopPoints))
                        {
                            dbModel.loopPoints[j].ZIndex = "2";
                        }
                    }
                }
            }

            //   dbModel.Color =
            return(dbModel);
        }
Пример #9
0
        private ObjectId ProcessEntity(Hatch hatch, BlockTable bt)
        {
            //Для создания контура штриховки
            //Hatch.NumberOfLoops
            //Hatch.GetLoopAt
            //HatchLoop.Polyline!!!

            //Получить полилинии
            List <Polyline> polylines = new List <Polyline>();

            for (int i = 0; i < hatch.NumberOfLoops; i++)
            {
                HatchLoop             hl  = hatch.GetLoopAt(i);
                BulgeVertexCollection bvc = hl.Polyline;
                Curve2dCollection     cc  = hl.Curves;
                Polyline poly             = null;

                if (bvc != null && bvc.Count > 0)
                {
                    //сюда попадет если контур состоит из отрезков и круговых дуг
                    poly = new Polyline();
                    int vertNum = 0;
                    foreach (BulgeVertex bv in bvc)
                    {
                        poly.AddVertexAt(vertNum, bv.Vertex, bv.Bulge, 0, 0);
                        vertNum++;
                    }
                }
                else if (cc != null && cc.Count > 0)
                {
                    //сюда попадет если контур состоит только из отрезков или включает сложные линии (сплайны, эллипсы)
                    poly = new Polyline();
                    //добавить первую вершину
                    //poly.AddVertexAt(0, cc[0].StartPoint, 0, 0, 0);
                    int vertNum = 0;
                    foreach (Curve2d c in cc)
                    {
                        if (c is LinearEntity2d)
                        {
                            //добавить сегмент без кривизны
                            LinearEntity2d l2d = c as LinearEntity2d;
                            poly.AddVertexAt(vertNum, l2d.EndPoint, 0, 0, 0);
                            vertNum++;
                        }
                        else
                        {
                            //просто пропустить эту кривую (может это сплайн или еще чего)
                            //throw new System.Exception("Неверный тип 2d кривой - " + c.GetType().ToString());
                        }
                    }
                }



                if (poly != null && poly.NumberOfVertices > 1)
                {
                    //присвоить слой штриховки
                    poly.LayerId = hatch.LayerId;
                    //замкнуть
                    poly.Closed = true;

                    polylines.Add(poly);
                }
            }

            //Создать новый блок и сохранить в него полилинии
            ObjectId createdBtrId = ObjectId.Null;
            Database db           = bt.Database;

            if (polylines.Count > 0)
            {
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    //Создать новый блок для сохранения замкнутых контуров

                    BlockTableRecord btr = new BlockTableRecord();
                    btr.Name = n.ToString();
                    n++;
                    createdBtrId = bt.Add(btr);
                    tr.AddNewlyCreatedDBObject(btr, true);

                    if (createdBtrId != ObjectId.Null)
                    {
                        foreach (Polyline p in polylines)
                        {
                            btr.AppendEntity(p);
                            tr.AddNewlyCreatedDBObject(p, true);
                        }
                    }


                    tr.Commit();
                }
            }



            return(createdBtrId);
        }
Пример #10
0
        public void Play()
        {
            //Doc = Application.DocumentManager.MdiActiveDocument;
            //Db = Doc.Database;
            //DL = Doc.LockDocument(DocumentLockMode.ProtectedAutoWrite, null, null, true);

            //Editor Editor = Application.DocumentManager.MdiActiveDocument.Editor;

            PromptSelectionResult acPSR = AC.Editor.GetSelection();

            // 선택한 객체를 받음
            if (acPSR.Status == PromptStatus.OK)
            {
                var edgePtrs  = new Curve2dCollection();
                var edgeTypes = new IntegerCollection();

                using (Transaction T = AC.DB.TransactionManager.StartTransaction())
                {
                    BlockTable       BT  = T.GetObject(AC.DB.BlockTableId, OpenMode.ForWrite) as BlockTable;
                    BlockTableRecord BTR = T.GetObject(BT[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;

                    SelectionSet acSSet = acPSR.Value;

                    foreach (var objID in acSSet.GetObjectIds())
                    {
                        var acEnt = T.GetObject(objID, OpenMode.ForWrite) as Entity;

                        if (acEnt is Polyline)
                        {
                            Polyline acPL = acEnt as Polyline;

                            GetEdgeInformation(acPL, ref edgePtrs, ref edgeTypes);
                        }
                    }
                }

                var acPolylines = from a in edgePtrs.Cast <Curve2d>()
                                  orderby a.StartPoint.GetDistanceTo(a.EndPoint) descending
                                  select a;

                //var usedCurve = new List<Curve2d>();
                var usedCurve = new List <Point2d>();

                acPolylines.Cast <Curve2d>().ToList().ForEach(c =>
                {
                    var CenterP = CADUtil.GetCenterPoint2d(c.StartPoint, c.EndPoint);

                    var curves = from a in edgePtrs.Cast <Curve2d>().ToList()
                                 where a != c
                                 select a;

                    // c와 평행한 선을 받음
                    var MatchedCurves                 = from a in curves
                                                let d = a.GetDistanceTo(c)
                                                        where CADUtil.GetVector(a).GetNormal().IsEqualTo(-CADUtil.GetVector(c).GetNormal())
                                                        where d > Min && d < Max
                                                        let cp1                     = CADUtil.GetCenterPoint2d(c)
                                                                            let cp2 = CADUtil.GetCenterPoint2d(a)
                                                                                      orderby cp1.GetDistanceTo(cp2) ascending
                                                                                      select a;

                    if (MatchedCurves.Any())
                    {
                        //CAD.CreateLine(c.StartPoint, c.EndPoint);

                        bool B = true;

                        MatchedCurves.ToList().ForEach(c1 =>
                        {
                            var cp1 = CADUtil.GetCenterPoint2d(c1);

                            usedCurve.ForEach(cp2 =>
                            {
                                if (cp1.IsEqualTo(cp2))
                                {
                                    B = false;
                                }
                            });
                        });

                        if (B)
                        {
                            CreateRectangle(c, MatchedCurves.ToList());

                            usedCurve.Add(CADUtil.GetCenterPoint2d(c));
                        }
                    }
                });
            }
            else
            {
                Application.ShowAlertDialog("Number of objects selected: 0");
            }
        }
Пример #11
0
        void HatchPerimeter(ObjectId entId)
        {
            Document activeDoc = Application.DocumentManager.MdiActiveDocument;

            Database db = activeDoc.Database;

            Editor ed = activeDoc.Editor;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                Hatch hatch = tr.GetObject(entId, OpenMode.ForRead) as Hatch;

                int    nLoops = hatch.NumberOfLoops;
                double totalExternalPerimeter = 0.0;
                double totalInternalPerimeter = 0.0;

                for (int i = 0; i < nLoops; i++)
                {
                    double loopLength = 0.0;

                    HatchLoopTypes hlt = hatch.LoopTypeAt(i);

                    HatchLoop hatchLoop = hatch.GetLoopAt(i);

                    if ((hatch.LoopTypeAt(i) & HatchLoopTypes.Polyline) == HatchLoopTypes.Polyline)
                    {
                        BulgeVertexCollection bulges = hatchLoop.Polyline;
                        int nVertices = bulges.Count;

                        Polyline testPoly = new Polyline(nVertices);

                        for (int vx = 0; vx < bulges.Count; vx++)
                        {
                            BulgeVertex bv = bulges[vx];

                            testPoly.AddVertexAt(vx, bv.Vertex, bv.Bulge, 1.0, 1.0);
                        }

                        LineSegment3d ls = new LineSegment3d();

                        CircularArc3d cs = new CircularArc3d();

                        double d = 0.0, p1 = 0.0, p2 = 1.0;

                        for (int ver = 0; ver < nVertices - 1; ver++)
                        {
                            d = testPoly.GetBulgeAt(ver);

                            if (d <= 1e-5)
                            {
                                ls = testPoly.GetLineSegmentAt(ver);

                                loopLength += ls.Length;
                            }

                            else
                            {
                                Point2d v1 = new Point2d(bulges[ver].Vertex.X, bulges[ver].Vertex.Y);

                                Point2d v2 = new Point2d(bulges[ver + 1].Vertex.X, bulges[ver + 1].Vertex.Y);

                                if (v1.IsEqualTo(v2) == false)
                                {
                                    cs = testPoly.GetArcSegmentAt(ver);

                                    p1 = cs.GetParameterOf(cs.StartPoint);

                                    p2 = cs.GetParameterOf(cs.EndPoint);

                                    loopLength += cs.GetLength
                                                      (p1, p2, Tolerance.Global.EqualPoint);
                                }
                            }
                        }
                    }

                    else
                    {
                        Curve2dCollection curves = hatchLoop.Curves;

                        if (curves != null)
                        {
                            foreach (Curve2d curve in curves)
                            {
                                if (hatchLoop.LoopType == HatchLoopTypes.External)
                                {
                                    totalExternalPerimeter += curve.GetLength(0.0, 1.0);
                                }

                                else
                                {
                                    totalInternalPerimeter += curve.GetLength(0.0, 1.0);
                                }
                            }
                        }
                    }

                    if (nLoops > 1 &&

                        ((hlt & HatchLoopTypes.External) != HatchLoopTypes.External))
                    {
                        totalInternalPerimeter += loopLength;
                    }
                    else
                    {
                        totalExternalPerimeter += loopLength;
                    }
                }
                ed.WriteMessage(string.Format("\nExternal Perimeter : {0}", totalExternalPerimeter));

                ed.WriteMessage(string.Format("\nInternal Perimeter : {0}", totalInternalPerimeter));

                tr.Commit();
            }
        }
Пример #12
0
        // 获取实体信息
        public void GetEntitiesInfo(ArrayList entities, Transaction trans, BlockTableRecord btr, int numSample, Document doc, Editor ed)
        {
            ArrayList uuid      = new ArrayList();
            ArrayList geom      = new ArrayList(); // 坐标点集合
            ArrayList colorList = new ArrayList(); // 颜色集合
            ArrayList type      = new ArrayList(); // 类型集合

            ArrayList layerName = new ArrayList();
            ArrayList tableName = new ArrayList();                                  // 表名

            System.Data.DataTable attributeList      = new System.Data.DataTable(); // 属性集合
            ArrayList             attributeIndexList = new ArrayList();             //属性索引集合

            ArrayList tuliList  = new ArrayList();                                  //图例集合
            string    projectId = "";                                               //项目ID
            string    chartName = "";                                               //表名称
            ArrayList kgGuide   = new ArrayList();                                  //控规引导

            string    srid         = "";                                            //地理坐标系统编号
            ArrayList parentId     = new ArrayList();                               //配套设施所在地块集合
            ArrayList textContent  = new ArrayList();                               // 文字内容(GIS端展示)
            ArrayList blockContent = new ArrayList();                               // 块内容(GIS端展示)

            Dictionary <string, string> result = new Dictionary <string, string>(); // 汇总

            // 遍历所有实体
            foreach (object entity in entities)
            {
                ArrayList singlePositionList = new ArrayList(); // 单个实体坐标点集合

                //取得边界数
                int loopNum = 1;
                if (entity is Hatch)
                {
                    loopNum = (entity as Hatch).NumberOfLoops;
                    type.Add("polygon");
                }

                Point3dCollection     col_point3d = new Point3dCollection();
                BulgeVertexCollection col_ver     = new BulgeVertexCollection();
                Curve2dCollection     col_cur2d   = new Curve2dCollection();

                for (int i = 0; i < loopNum; i++)
                {
                    col_point3d.Clear();
                    HatchLoop hatLoop = null;
                    if (entity is Hatch)
                    {
                        try
                        {
                            hatLoop = (entity as Hatch).GetLoopAt(i);
                        }
                        catch (System.Exception)
                        {
                            continue;
                        }

                        //如果HatchLoop为PolyLine
                        if (hatLoop.IsPolyline)
                        {
                            col_ver = hatLoop.Polyline;
                            foreach (BulgeVertex vertex in col_ver)
                            {
                                col_point3d.Add(new Point3d(vertex.Vertex.X, vertex.Vertex.Y, 0));
                            }
                        }
                    }

                    // 如果实体为Polyline
                    if (entity is Polyline)
                    {
                        // 类型
                        type.Add("polyline");

                        Polyline polyline = (Polyline)entity;

                        int vn = polyline.NumberOfVertices;
                        for (int w = 0; w < vn; w++)
                        {
                            Point2d pt = polyline.GetPoint2dAt(w);

                            col_point3d.Add(new Point3d(pt.X, pt.Y, 0));
                        }
                    }
                    //// 如果实体为Curve
                    //if (entity is Curve)
                    //{
                    //    col_cur2d = hatLoop.Curves;
                    //    foreach (Curve2d item in col_cur2d)
                    //    {
                    //        Point2d[] M_point2d = item.GetSamplePoints(numSample);
                    //        foreach (Point2d pt in M_point2d)
                    //        {
                    //            if (!col_point3d.Contains(new Point3d(pt.X, pt.Y, 0)))
                    //                col_point3d.Add(new Point3d(pt.X, pt.Y, 0));
                    //        }
                    //    }
                    //}
                    // 如果实体为Point2d
                    if (entity is DBPoint)
                    {
                        type.Add("point");

                        DBPoint entity3 = (DBPoint)entity;
                        col_point3d.Add(new Point3d(entity3.Position.X, entity3.Position.Y, 0));
                    }

                    // 如果实体为Point
                    if (entity is Point3d)
                    {
                        type.Add("point");

                        Point3d entity3 = (Point3d)entity;
                        col_point3d.Add(entity3);
                    }

                    // 如果实体为文字
                    if (entity is MText)
                    {
                        type.Add("text");

                        col_point3d.Add(new Point3d((entity as MText).Location.X, (entity as MText).Location.Y, 0));
                    }

                    // 如果实体为文字
                    if (entity is DBText)
                    {
                        type.Add("text");

                        col_point3d.Add(new Point3d((entity as DBText).Position.X, (entity as DBText).Position.Y, 0));
                    }

                    // 块参照
                    if (entity is BlockReference)
                    {
                        type.Add("block");

                        col_point3d.Add(new Point3d((entity as BlockReference).Position.X, (entity as BlockReference).Position.Y, 0));
                    }

                    double[] pointPositionList = new double[2]; //单个点的坐标点集合
                    // 经纬度转换
                    foreach (Point3d point in col_point3d)
                    {
                        pointPositionList = new double[2] {
                            Transform(point)[0], Transform(point)[1]
                        };
                        singlePositionList.Add(pointPositionList);
                    } // 经纬度转换结束
                }     // 单个实体几何坐标数量循环结束

                // UUID
                Entity entityLayer = (Entity)entity;

                Guid guid = new Guid();
                guid = Guid.NewGuid();
                string str = guid.ToString();
                uuid.Add(str);

                // 坐标
                geom.Add(singlePositionList);

                // 颜色
                if (entity is Point3d)
                {
                    colorList.Add("");
                    // 图层名
                    layerName.Add("无");
                }
                else
                {
                    LayerTableRecord ltr = (LayerTableRecord)trans.GetObject(entityLayer.LayerId, OpenMode.ForRead);

                    string color;
                    color = entityLayer.ColorIndex == 256 ? MethodCommand.GetLayerColorByID(entityLayer.LayerId) : ColorTranslator.ToHtml(entityLayer.Color.ColorValue);

                    colorList.Add(color);
                    // 图层名
                    layerName.Add(ltr.Name);
                }

                // 表名
                tableName.Add("a");

                // 属性索引
                // 获取每个闭合多段线对应的个体编号和用地代号
                ArrayList             tagList = new ArrayList();
                PromptSelectionResult psrss   = ed.SelectCrossingPolygon(col_point3d); // 获取闭合区域内实体方法

                if (psrss.Status == PromptStatus.OK)
                {
                    tagList.Clear();

                    SelectionSet SS      = psrss.Value;
                    ObjectId[]   idArray = SS.GetObjectIds();

                    // 如果读取的块参照数量大于1,取中心点在闭合多段线的块参照
                    if (idArray.Length > 1)
                    {
                        for (int i = 0; i < idArray.Length; i++)
                        {
                            Entity ent1 = (Entity)idArray[i].GetObject(OpenMode.ForRead);
                            if (ent1 is BlockReference)
                            {
                                BlockReference ent2 = (BlockReference)ent1;
                                if (IsInPolygon(ent2.Position, col_point3d))
                                {
                                    foreach (ObjectId rt in ((BlockReference)ent1).AttributeCollection)
                                    {
                                        DBObject           dbObj    = trans.GetObject(rt, OpenMode.ForRead) as DBObject;
                                        AttributeReference acAttRef = dbObj as AttributeReference;

                                        tagList.Add(acAttRef.TextString);

                                        //MessageBox.Show("Tag: " + acAttRef.Tag + "\n" +
                                        //                "Value: " + acAttRef.TextString + "\n");
                                    }
                                }
                            }
                        }
                    }
                    // 如果读取的块参照数量等于1,取中心点在闭合多段线的块参照
                    else
                    {
                        for (int i = 0; i < idArray.Length; i++)
                        {
                            Entity ent1 = (Entity)idArray[i].GetObject(OpenMode.ForRead);
                            if (ent1 is BlockReference)
                            {
                                foreach (ObjectId rt in ((BlockReference)ent1).AttributeCollection)
                                {
                                    DBObject           dbObj    = trans.GetObject(rt, OpenMode.ForRead) as DBObject;
                                    AttributeReference acAttRef = dbObj as AttributeReference;

                                    tagList.Add(acAttRef.TextString);
                                }
                            }
                        }
                    }
                }
                // 如果地块编码属性只有两个属性值,attributeIndexList,如果少于2个或者多于2个都视为异常,添加空。
                if (tagList.Count == 2)
                {
                    attributeIndexList.Add(tagList[0] + "_" + tagList[1]);
                }
                else
                {
                    attributeIndexList.Add("");
                }

                // 属性
                readAttributeList attributeListObj = new readAttributeList();
                attributeList = attributeListObj.AttributeList();

                // 配套设施所属的地块UUID

                // 获取块参照的属性值
                ArrayList blockAttribute = new ArrayList();
                // 是否是地块编码本身
                string isBlockNum = "";

                // 如果这个块标注是幼儿园、公厕等,找对对应的地块编号或UUID
                if (entity is BlockReference)
                {
                    // 清除原有内容
                    blockAttribute.Clear();

                    // 如果entity有两个属性值,可以判断这是一个地块编码
                    if (((BlockReference)entity).AttributeCollection.Count == 2)
                    {
                        isBlockNum = "Block";
                    }

                    // 获取地块界限图层上的所有实体
                    ArrayList polylineEntities = new ArrayList();

                    // 找出地块界限里的所有闭合多段线,并判断当前块标注实体是否在某一个闭合多段线内,如果在,找出该闭合多段线内的块参照个体编号
                    TypedValue[] tvs =
                        new TypedValue[1] {
                        new TypedValue(
                            (int)DxfCode.LayerName,
                            "地块界限"
                            )
                    };

                    SelectionFilter       sf  = new SelectionFilter(tvs);
                    PromptSelectionResult psr = ed.SelectAll(sf);

                    if (psr.Status == PromptStatus.OK)
                    {
                        SelectionSet SS      = psr.Value;
                        ObjectId[]   idArray = SS.GetObjectIds();

                        //MessageBox.Show(idArray.Length.ToString());

                        Point3dCollection polylinePoint3d = new Point3dCollection();

                        for (int j = 0; j < idArray.Length; j++)
                        {
                            // 清除原有内容
                            polylinePoint3d.Clear();

                            Entity ent1 = trans.GetObject(idArray[j], OpenMode.ForWrite) as Entity;
                            if (ent1 is Polyline && (ent1 as Polyline).Closed)
                            {
                                Polyline polyline = (Polyline)ent1;

                                int vn = polyline.NumberOfVertices;
                                for (int w = 0; w < vn; w++)
                                {
                                    Point2d pt = polyline.GetPoint2dAt(w);
                                    polylinePoint3d.Add(new Point3d(pt.X, pt.Y, 0));
                                }

                                // 获取闭合多段线(地块)内的所有实体
                                PromptSelectionResult psrss2 = ed.SelectCrossingPolygon(polylinePoint3d);
                                if (psrss2.Status == PromptStatus.OK)
                                {
                                    SelectionSet SS2      = psrss2.Value;
                                    ObjectId[]   idArray2 = SS2.GetObjectIds();

                                    // 如果读取的块参照数量大于1,且包含当前实体,找出当前块参照所在的闭合多段线
                                    if (idArray2.Length > 1)
                                    {
                                        for (int i = 0; i < idArray2.Length; i++)
                                        {
                                            Entity ent2 = (Entity)idArray2[i].GetObject(OpenMode.ForRead);

                                            // 判断是否是配套设施开始
                                            if (ent2 is BlockReference && (ent2 as BlockReference).Position.X == (entity as BlockReference).Position.X)
                                            {
                                                for (int k = 0; k < idArray2.Length; k++)
                                                {
                                                    Entity ent3 = (Entity)idArray2[k].GetObject(OpenMode.ForRead);
                                                    if (ent3 is BlockReference)
                                                    {
                                                        // 判断块参照中心点是否在闭合多段线内,只读取中心点在闭合多段线内的块参照
                                                        if (IsInPolygon((ent3 as BlockReference).Position, polylinePoint3d))
                                                        {
                                                            foreach (ObjectId rt in ((BlockReference)ent3).AttributeCollection)
                                                            {
                                                                DBObject           dbObj    = trans.GetObject(rt, OpenMode.ForRead) as DBObject;
                                                                AttributeReference acAttRef = dbObj as AttributeReference;

                                                                blockAttribute.Add(acAttRef.TextString);
                                                            }
                                                        }
                                                    }
                                                }
                                            } // 判断是否是配套设施结束
                                        }
                                    }
                                } // 获取闭合多段线(地块)内的所有实体结束
                            }
                        }
                    }
                } // 如果这个块标注是幼儿园、公厕等,找对对应的地块编号或UUID 结束

                // 如果地块编码属性只有两个属性值,而且不是地块编码块参照,添加到parentId,如果少于2个或者多于2个都视为异常,添加空。
                if (blockAttribute.Count == 2 && isBlockNum != "Block")
                {
                    parentId.Add(blockAttribute[0] + "_" + blockAttribute[1]);
                }
                else
                {
                    parentId.Add("");
                }

                // 文字内容(GIS端展示)
                if (entity is DBText)
                {
                    textContent.Add((entity as DBText).TextString);
                }
                else if (entity is MText)
                {
                    textContent.Add((entity as MText).Text);
                }
                else if (entity is BlockReference)
                {
                    List <string> singleBlockContent = new List <string>();
                    string        text = "";

                    if ((entity as BlockReference).AttributeCollection.Count > 0)
                    {
                        foreach (ObjectId rt in ((BlockReference)entity).AttributeCollection)
                        {
                            DBObject           dbObj    = trans.GetObject(rt, OpenMode.ForRead) as DBObject;
                            AttributeReference acAttRef = dbObj as AttributeReference;

                            text = text + acAttRef.TextString + "//";
                        }
                        text = text.Substring(0, text.Length - 2);
                    }

                    textContent.Add(text);
                }
                else
                {
                    textContent.Add("");
                }

                // 块内容(GIS端展示)
                if (entity is BlockReference)
                {
                    List <string> singleBlockContent = new List <string>();
                    string        text = "//";

                    foreach (ObjectId rt in ((BlockReference)entity).AttributeCollection)
                    {
                        DBObject           dbObj    = trans.GetObject(rt, OpenMode.ForRead) as DBObject;
                        AttributeReference acAttRef = dbObj as AttributeReference;

                        text = acAttRef.TextString + text;
                        //singleBlockContent.Add(acAttRef.TextString);
                    }
                    blockContent.Add(text);
                    //blockContent.Add(singleBlockContent);
                }
                else
                {
                    blockContent.Add("");
                }
            } // 所有的实体循环结束

            // 图例
            readAttributeList attributeListObj3 = new readAttributeList();

            //tuliList.Add(attributeListObj3.TuliList());
            tuliList.Add("");

            // 项目名
            //string projectIdBaseAddress = "http://172.18.84.70:8081/PDD/pdd/individual-manage!findAllProject.action";
            //var projectIdHttp = (HttpWebRequest)WebRequest.Create(new Uri(projectIdBaseAddress));

            //var response = projectIdHttp.GetResponse();

            //var stream = response.GetResponseStream();
            //var sr = new StreamReader(stream, Encoding.UTF8);
            //var content = sr.ReadToEnd();

            //MessageBox.Show(content);

            projectId = "D3DEC178-2C05-C5F1-F6D3-45729EB9436A";

            // 图表名或者叫文件名
            chartName = Path.GetFileName(ed.Document.Name);

            // 控规引导
            readAttributeList attributeListObj2 = new readAttributeList();

            kgGuide = attributeListObj2.KgGuide();

            //地理坐标系统编号
            srid = "4326";

            // 发文字信息
            RegulatoryPost.FenTuZe.FenTuZe.SendData(result, uuid, geom, colorList, type, layerName, tableName, attributeIndexList, attributeList, tuliList, projectId, chartName, kgGuide, srid, parentId, textContent, blockContent);
        }