Exemplo n.º 1
0
        public static void GetText()
        {
            var p1 = Interaction.GetPoint("坐标1");
            var p2 = Interaction.GetPoint("坐标2");

            string name = "";
            string txt  = "";

            txt += string.Format("p1:{0},p2:{1}\nobjs:\n", p1, p2);
            ObjectId[]   objs = Interaction.GetCrossingSelection(p1, p2);
            CADShapeList sps  = new CADShapeList();

            for (int i = 0; i < objs.Length; i++)
            {
                ObjectId item = objs[i];
                var      sp   = item.ToCADShape(true);
                sps.Add(sp);
                txt += string.Format("{0}\n", sp);
            }

            sps.SortByXY();//按坐标排序
            foreach (CADShape sp in sps)
            {
                if (sp.Text == "AC")
                {
                    continue;;
                }
                name += sp.Text;
            }

            MyTool.TextReport("名称:" + name, txt, 700, 500);
        }
Exemplo n.º 2
0
        public static string GetText(Point3d pt1, Point3d pt2)
        {
            //var p1 = Interaction.GetPoint("坐标1");
            //var p2 = Interaction.GetPoint("坐标2");

            string name = "";

            //string txt = "";
            ObjectId[]   objs = Interaction.GetCrossingSelection(pt1, pt2);
            CADShapeList sps  = new CADShapeList();

            for (int i = 0; i < objs.Length; i++)
            {
                ObjectId item = objs[i];
                var      sp   = item.ToCADShape(true);
                sps.Add(sp);
                //txt += string.Format("{0}\n", sp);
            }

            sps.SortByXY();//按坐标排序
            foreach (CADShape sp in sps)
            {
                if (sp.Text == "AC")
                {
                    continue;;
                }
                name += sp.Text;
            }

            //Gui.TextReport("名称:" + name, txt, 700, 500);
            return(name.Trim());
        }
Exemplo n.º 3
0
        public static void GetAnchors()
        {
            try
            {
                var zero = Interaction.GetPoint("选择原点");
                //string[] keys = { "1F", "2F", "3F", "4F" };
                //var key = Interaction.GetKeywords("\n选择楼层", keys);
                var          anchorObjects = Interaction.GetEntitysByLayers("-人员定位");
                CADShapeList sps           = new CADShapeList();
                for (int i = 0; i < anchorObjects.Length; i++)
                {
                    ObjectId item = anchorObjects[i];
                    var      sp   = item.ToCADShape(true);
                    sps.Add(sp);
                    Interaction.WriteLine(string.Format("{0}({1}/{2})", sp, i + 1, anchorObjects.Length));
                }

                var types = sps.GetTypesEx();

                string typesText = "";
                foreach (var item in types)
                {
                    typesText += item.Key + ",";
                }

                Interaction.Write("Types:" + typesText);

                //var circleList = types["Circle"];
                //var zeroCircle = circleList[0];
                //var zeroP = zeroCircle.GetPoint();

                var pZero = zero.ToCADPoint(false);//获取的坐标原本就是用户坐标系的
                foreach (CADShape sp in sps)
                {
                    sp.SetZero(pZero);
                }

                CADShapeList anchorList = new CADShapeList();
                if (types.ContainsKey("BlockReference"))
                {
                    anchorList = types["BlockReference"];
                }

                CADShapeList textList = new CADShapeList();
                if (types.ContainsKey("MText"))
                {
                    textList.AddRange(types["MText"]);
                }
                if (types.ContainsKey("DBText"))
                {
                    textList.AddRange(types["DBText"]);
                }

                CADAnchorList result = new CADAnchorList();


                List <string> names       = new List <string>();
                CADShapeList  usedText    = new CADShapeList();
                string        repeatNames = "";
                for (int i = 0; i < anchorList.Count; i++)
                {
                    var anchor = anchorList[i];
                    var text   = textList.FindCloset(anchor);
                    if (text != null)
                    {
                        //if (text.Text.Contains(key))
                        {
                            anchor.Text = text.Text;
                            anchor.Name = text.Text;
                            result.Anchors.Add(anchor);

                            if (!names.Contains(anchor.Name))
                            {
                                names.Add(anchor.Name);
                            }
                            else
                            {
                                repeatNames += anchor.Name + ";";
                            }
                            usedText.Add(text);
                        }
                    }
                }

                string noUseNames = "";
                foreach (var item in textList)
                {
                    if (!usedText.Contains(item))
                    {
                        noUseNames += item.Text + ";";
                    }
                }


                result.Anchors.Sort();
                for (int i = 0; i < result.Anchors.Count; i++)
                {
                    result.Anchors[i].Num = i + 1;
                }

                if (repeatNames != "")
                {
                    MyTool.TextReport("重复基站", repeatNames, 700, 500);
                }

                if (noUseNames != "")
                {
                    MyTool.TextReport("遗漏基站", noUseNames, 700, 500);
                }

                var txt = result.ToXml();
                MyTool.TextReport("Anchors", txt, 700, 500);
            }
            catch (System.Exception ex)
            {
                MyTool.TextReport("Exception", ex.ToString(), 700, 500);
            }
        }