示例#1
0
 public static void GetColumnPointsEx()
 {
     try
     {
         CADAreaList areaList = new CADAreaList();
         var         zero     = Interaction.GetPoint("ZeroPoint");
         string[]    keys     = { "0:左下", "1:右下", "2:右上", "3:左上" };
         string      p1       = zero.ToString();
         string      p2       = zero.ToUCS().ToString();
         string      p3       = zero.ToWCS().ToString();
         Interaction.WriteLine(string.Format("\n zero [{0},{1},{2}]", p1, p2, p3));
         var key = Interaction.GetKeywords("\nChoose1 Zero Type ", keys);
         if (string.IsNullOrEmpty(key))
         {
             return;
         }
         //var key = Interaction.GetKeywords("\nChoose1 Zero Type ", keys);
         var columns = Interaction.GetEntitysByLayers("COLUMN");
         var area    = columns.ToCADArea(zero.ToCADPoint(true), key, true, true);
         area.Name = "主厂房0m层";
         areaList.Add(area);
         var txt = areaList.ToXml();
         MyTool.TextReport("Points", txt, 700, 500);
     }
     catch (System.Exception ex)
     {
         MyTool.TextReport("Exception", ex.ToString(), 700, 500);
     }
 }
示例#2
0
        public static void GetLinesOfPoint()
        {
            var p = Interaction.GetPoint("GetLineOfPoint");

            //Interaction.GetEntity()
            //Interaction.
            Interaction.GetEntitysByLayers();
            var ids = QuickSelection.SelectAll();

            foreach (ObjectId id in ids)
            {
            }
        }
示例#3
0
        public static void GetColumnPointsEx()
        {
            CADAreaList areaList = new CADAreaList();
            var         zero     = Interaction.GetPoint("ZeroPoint");

            string[] keys = { "0:左下", "1:右下", "2:右上", "3:左上" };
            var      key  = Interaction.GetKeywords("\nChoose Zero Type", keys);

            var columns = Interaction.GetEntitysByLayers("COLUMN");
            var area    = columns.ToCADArea(zero, key);

            area.Name = "主厂房0m层";
            areaList.Add(area);
            var txt = areaList.ToXml();

            Gui.TextReport("Points", txt, 700, 500);
        }
示例#4
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);
            }
        }