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

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

            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;
            }

            Gui.TextReport("名称:" + name, txt, 700, 500);
        }
Exemplo n.º 2
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();
         Gui.TextReport("Points", txt, 700, 500);
     }
     catch (System.Exception ex)
     {
         Gui.TextReport("Exception", ex.ToString(), 700, 500);
     }
 }
Exemplo n.º 3
0
        public static void GetEntityPoints()
        {
            var    objId = Interaction.GetEntity("Entity");
            var    sp    = objId.ToCADShape(true);
            string xml   = sp.ToXml();

            Gui.TextReport("Points", xml, 700, 500);
        }
Exemplo n.º 4
0
        public static void GetLinePoints()
        {
            var    objId = Interaction.GetEntity("Entity");
            var    line  = objId.QOpenForRead <Line>();
            string xml   = string.Format("{0},{1}", line.StartPoint, line.EndPoint);

            Gui.TextReport("Points", xml, 700, 500);
        }
Exemplo n.º 5
0
        public static void GetPoint1()
        {
            var    p   = Interaction.GetPoint("Point");
            var    p2  = p.ToWCS();
            var    p3  = p2.ToUCS();
            string txt = string.Format("P1(Original):{0}\nP2(WCS世界坐标):{1}\nP3(UCS局部坐标):{2}", p, p2, p3);

            Gui.TextReport("PT", txt, 700, 500);
        }
        /// <summary>
        /// 获取某图层下所有多边型元素
        /// </summary>
        public static void GetAllShapeByLayer()
        {
            try
            {
                ShapesDefine shape = new ShapesDefine();
                ObjectId[]   objs  = GetAllShape();

                if (objs == null)
                {
                    return;
                }

                foreach (ObjectId objId in objs)
                {
                    //某个元素
                    //Entity ent = (Entity)trans.GetObject(objId, OpenMode.ForWrite);
                    var ent = objId.ToCADShape(true);

                    string pl = ent.Type.ToString();
                    //判断是否为多边型元素
                    if (pl.Contains("Polyline"))// && ent.Points.Count() == 22)
                    {
                        //CADShape sp = new CADShape();
                        // sp.AddPoints(ent as Polyline, true);

                        //add by qclei 2020-04-29 判断是否是封闭的图形
                        //bool bl = PulicGadget.ifColseShape(sp);
                        //if (bl)
                        {
                            //ent.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByBlock, 3); ;

                            //获取图层的名称
                            string name1 = PulicGadget.getShapeName(ent);
                            if (name1 != "")
                            {
                                ent.Name = name1;
                            }
                            shape.addShape(ent);
                        }
                    }
                }

                if (shape.shapelist.Count() > 0)
                {
                    string xml = shape.toXml();
                    Gui.TextReport("GetAllShapeByLayer", xml, 700, 500);
                }
            }
            catch (Autodesk.AutoCAD.BoundaryRepresentation.Exception ex)
            {
                string exm = ex.Message;
                Gui.TextReport("GetAllShapeByLayer 出错:", exm, 700, 500);
            }

            return;
        }
Exemplo n.º 7
0
        public static void Help()
        {
            string txt = "PT:测试获取坐标\n" +
                         "EntityPoints:获取图形的坐标信息\n" +
                         "ColumnPointsEx:获取柱子坐标信息\n" +
                         "Anchors:获取基站坐标信息(某一楼层的)\n" +
                         "AllAnchors:获取基站坐标信息(1F,2F,3F,4F)";

            ;
            Gui.TextReport("Help", txt, 700, 500);
        }
Exemplo n.º 8
0
        public static void GetRoomsInfoEx()
        {
            DateTime start = DateTime.Now;

            TopoInfo floor = GetFloorInfoEx();

            DateTime end = DateTime.Now;
            TimeSpan t   = end - start;
            string   xml = XmlSerializeHelper.GetXmlText(floor);

            Gui.TextReport(floor.Name + "|" + t, xml, 700, 500);
        }
        /// <summary>
        /// 根据“大楼”名称获取相应的图层
        /// </summary>
        public static void GetParkBuild(string buildName)
        {
            ShapesDefine shape = new ShapesDefine();

            shape = GetParkLayerByName(buildName, false);

            if (shape.shapelist.Count() > 0)
            {
                string xml = shape.toXml();
                Gui.TextReport("GetParkBuild", xml, 700, 500);
            }
        }
Exemplo n.º 10
0
        public static void GetParkInfoEx()
        {
            DateTime start = DateTime.Now;

            InitInfo initInfo = CreateInitInfo();

            DateTime end = DateTime.Now;
            TimeSpan t   = end - start;

            string xml = XmlSerializeHelper.GetXmlText(initInfo);

            Gui.TextReport("获取整个园区", xml, 700, 500);
        }
Exemplo n.º 11
0
        public static void GetExtentPoints()
        {
            var      objId = Interaction.GetEntity("Entity");
            CADShape shape = objId.ToCADShape(true);

            if (shape != null)
            {
                string xml = shape.ToXml();
                Gui.TextReport("Points", xml, 700, 500);
            }
            else
            {
                Gui.TextReport("Points", "NULL", 700, 500);
            }
        }
Exemplo n.º 12
0
        public static void GetRoomInfo()
        {
            DateTime start = DateTime.Now;

            TopoInfo topoInfo = GetRoomEx();

            DateTime end = DateTime.Now;
            TimeSpan t   = end - start;
            string   xml = "";

            if (topoInfo != null)
            {
                xml = XmlSerializeHelper.GetXmlText(topoInfo, true);
            }
            Gui.TextReport(topoInfo.Name + "|" + t, xml, 700, 500);
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
        public static void TextReport(string title, string content, double width, double height, bool modal = false, bool writeFile = true)
        {
            try
            {
                string[] list = new string[] { "D", "E", "F", "G", "H" };//C盘没有权限
                string   path = "";
                string   name = title;
                name = name.Replace("\\", "_");
                name = name.Replace("/", "_");
                name = name.Replace(":", "_");
                name = name.Replace("*", "_");
                name = name.Replace("?", "_");
                name = name.Replace("\"", "_");
                name = name.Replace("<", "_");
                name = name.Replace(">", "_");
                name = name.Replace("|", "_");
                for (int i = 0; i < list.Length; i++)
                {
                    if (Directory.Exists(list[i] + ":\\"))
                    {
                        path = list[i] + ":\\TextReport\\" + name + ".txt";
                        break;
                    }
                }

                FileInfo fi = new FileInfo(path);
                if (fi.Directory.Exists == false)
                {
                    fi.Directory.Create();
                }

                if (writeFile)
                {
                    File.WriteAllText(path, content);
                    content = path + "\n" + content;
                }

                Gui.TextReport(title, content, width, height, modal);
            }
            catch (System.Exception ex)
            {
                Gui.TextReport("错误", ex.ToString(), width, height, modal);
            }
        }
Exemplo n.º 15
0
        public static void GetShapeInfo()
        {
            var id = Interaction.GetEntity("Select:");
            var sp = id.ToCADShape(true);

            //add by qclei 2020-04-29 判断是否是封闭的图形
            //bool bl = PulicGadget.ifColseShape(sp);
            //if (bl)
            {
                string name = PulicGadget.getShapeName(sp);
                if (name != "")
                {
                    sp.Name = name;
                }
                var xml = sp.ToXml();

                Gui.TextReport("ShapeInfo", xml, 700, 500);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// 手动获取多个“多边型”图形
        /// </summary>
        public static void GetAllShapeByManual()
        {
            ShapesDefine shape = new ShapesDefine();

            int iCount = 1;

            while (true)
            {
                string sel = string.Format("Select {0} :", iCount.ToString());
                var    id  = Interaction.GetEntity(sel);

                if (id.Handle.Value != 0)
                {
                    var sp = id.ToCADShape(true);

                    //add by qclei 2020-04-29 判断是否是封闭的图形
                    //bool bl = PulicGadget.ifColseShape(sp);
                    //if (bl)
                    {
                        string name = PulicGadget.getShapeName(sp);
                        if (name != "")
                        {
                            sp.Name = name;
                        }
                        shape.addShape(sp);
                        iCount++;
                    }
                }
                else
                {
                    break;
                }
            }

            if (shape.shapelist.Count() > 0)
            {
                string xml = shape.toXml();
                Gui.TextReport("ShapeInfos", xml, 700, 500);
            }
        }
Exemplo n.º 17
0
        public static void GetInitInfo()
        {
            DateTime start = DateTime.Now;

            string txt = Interaction.GetString("输入园区名称");

            if (string.IsNullOrEmpty(txt))
            {
                txt = "园区";
            }

            TopoInfo floor = GetFloorInfo();

            InitInfo initInfo = CreateInitInfo(floor, txt);

            DateTime end = DateTime.Now;
            TimeSpan t   = end - start;

            string xml = XmlSerializeHelper.GetXmlText(initInfo);

            Gui.TextReport(floor.Name + "|" + t, xml, 700, 500);
        }
Exemplo n.º 18
0
 public static void TextReport()
 {
     Gui.TextReport("title", "content", 200, 300, false);
 }
Exemplo n.º 19
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 = types["MText"];
                }

                CADAnchorList result = new CADAnchorList();

                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);
                        }
                    }
                }

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

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