Esempio n. 1
0
        public static void SaveSelection()
        {
            var ids = Interaction.GetPickSet();

            if (ids.Length == 0)
            {
                Interaction.WriteLine("No entity selected.");
                return;
            }
            string name = Interaction.GetString("\nSelection name");

            if (name == null)
            {
                return;
            }
            if (CustomDictionary.GetValue("Selections", name) != string.Empty)
            {
                Interaction.WriteLine("Selection with the same name already exists.");
                return;
            }
            var    handles   = ids.QSelect(x => x.Handle.Value.ToString()).ToArray();
            string dictValue = string.Join("|", handles);

            CustomDictionary.SetValue("Selections", name, dictValue);
        }
Esempio n. 2
0
        /// <summary>
        /// 多个实体,输入编号逐个查看
        /// </summary>
        /// <param name="ids">实体ID数组</param>
        /// <param name="action">动作</param>
        public static void ZoomHighlightView(List <ObjectId> ids, Action <int> action = null) // newly 20130815
        {
            if (ids.Count > 0)
            {
                List <ObjectId> highlightIds = new List <ObjectId>();
                while (true)
                {
                    string input = Interaction.GetString("\n输入编号查看,按回车退出");
                    if (input == null)
                    {
                        break;
                    }
                    var index = Convert.ToInt32(input);
                    if (index <= 0 || index > ids.Count)
                    {
                        Interaction.WriteLine("编号不在范围内。");
                        continue;
                    }

                    if (action != null)
                    {
                        action(index);
                    }
                    highlightIds.Clear();
                    highlightIds.Add(ids[index - 1]);
                    Interaction.ZoomObjects(highlightIds);
                    Interaction.HighlightObjects(highlightIds);
                }
            }
        }
Esempio n. 3
0
        public static void ShowExtents() // newly 20130815
        {
            var ids     = Interaction.GetSelection("\nSelect entity");
            var extents = ids.GetExtents();
            var rectId  = Draw.Rectang(extents.MinPoint, extents.MaxPoint);

            Interaction.GetString("\nPress ENTER to exit");
            rectId.QOpenForWrite(x => x.Erase());
        }
Esempio n. 4
0
        public static void AddCircle()
        {
            var p      = Interaction.GetPoint("Point");
            var radius = Interaction.GetString("Radius");
            var cid    = Draw.Circle(p.ToWCS(), radius.ToInt());
            var zeroSp = cid.ToCADShape(true);

            Interaction.Write(zeroSp.GetPoint().ToString());
        }
Esempio n. 5
0
        public static void GetParkInfo()
        {
            string parkName = Interaction.GetString("输入厂区名称(默认:厂区A)");

            if (string.IsNullOrEmpty(parkName))
            {
                parkName = "厂区A";
            }
            GetCADOtherCommands.GetParkInfoEx(parkName, 0);
        }
Esempio n. 6
0
        public static void GetAllFloors()
        {
            string buildingName = Interaction.GetString("输入大楼名称(默认:大楼X)");

            if (string.IsNullOrEmpty(buildingName))
            {
                buildingName = "大楼X";
            }
            int count = (int)Interaction.GetValue("输入大楼楼层(默认:5)", 5);

            GetCADOtherCommands.GetAllFloors(buildingName, count, "");
        }
Esempio n. 7
0
        public static void GetParkInfoEx()
        {
            string parkName = Interaction.GetString("输入厂区名称(默认:厂区A)");

            if (string.IsNullOrEmpty(parkName))
            {
                parkName = "厂区A";
            }
            int count = (int)Interaction.GetValue("输入最大大楼楼层(默认:10)", 10);

            GetCADOtherCommands.GetParkInfoEx(parkName, count);
        }
Esempio n. 8
0
        public static void GetOneFloorWithRoot()
        {
            string txt = Interaction.GetString("输入厂区名称(默认:厂区A)");

            if (string.IsNullOrEmpty(txt))
            {
                txt = "厂区A";
            }
            var entityId = Interaction.GetEntity("选择一个机房(用来获取楼层的Layer)");
            var entity   = entityId.QOpenForRead <Entity>();

            GetCADOtherCommands.GetOneFloorWithRoot(entity.Layer, txt);
            return;
        }
Esempio n. 9
0
        public static void CopyCircle()
        {
            var entityId = Interaction.GetEntity("Circle");
            var entity   = entityId.QOpenForRead <Circle>();

            if (entity == null)
            {
                Interaction.Write("Not Circle");
                return;
            }
            var p      = entity.GetCenter();
            var radius = Interaction.GetString("Radius");
            var cid    = Draw.Circle(p, radius.ToInt());
            var zeroSp = cid.ToCADShape(true);

            Interaction.Write(zeroSp.GetPoint().ToString());
        }
Esempio n. 10
0
        private static TopoInfo GetFloor()
        {
            string txt = Interaction.GetString("输入楼层名称");

            if (string.IsNullOrEmpty(txt))
            {
                txt = "楼层1";
            }

            var       p1  = Interaction.GetPoint("楼层坐标1");
            PointInfo pi1 = GetPointInfo(p1);

            var       p2  = Interaction.GetPoint("楼层坐标2");
            PointInfo pi2 = GetPointInfo(p2);

            TopoInfo topoInfo = GetTopoInfo(txt, AreaTypes.楼层, pi1, pi2);

            Interaction.WriteLine(string.Format("{0} {1} {2}\n", pi1, pi2, txt));
            //Interaction.WriteLine("");
            return(topoInfo);
        }
Esempio n. 11
0
        public static TopoInfo GetFloorInfoEx()
        {
            roomCount = 0;
            TopoInfo floor = GetFloorEx();
            //string xml1 = XmlSerializeHelper.GetXmlText(floor);
            //Gui.TextReport("楼层", xml1, 700, 500);
            string txt = "";

            do
            {
                TopoInfo topoInfo = GetRoomEx();//一个点弄错了要从头开始
                if (topoInfo == null)
                {
                    break;                  //这里是出口
                }
                floor.AddChild(topoInfo);
                txt = Interaction.GetString("继续?(y)");
            }while (string.IsNullOrEmpty(txt) || txt != "n");
            //while (true);
            return(floor);
        }
Esempio n. 12
0
        private static TopoInfo GetFloorEx()
        {
            string txt = Interaction.GetString("输入楼层名称");

            if (string.IsNullOrEmpty(txt))
            {
                txt = "楼层1";
            }

            int pCout            = 0;
            List <PointInfo> pis = new List <PointInfo>();

            while (true)
            {
                pCout++;
                var p1 = Interaction.GetPoint("楼层坐标" + pCout);
                if (double.IsNaN(p1.X))
                {
                    if (pis.Count >= 2)
                    {
                        break; //出口
                    }
                    else
                    {
                        continue;
                    }
                }
                PointInfo pi1 = GetPointInfo(p1);
                pis.Add(pi1);
            }

            //var p2 = Interaction.GetPoint("楼层坐标2");
            //PointInfo pi2 = GetPointInfo(p2);

            TopoInfo topoInfo = GetTopoInfo(txt, AreaTypes.楼层, pis);

            Interaction.WriteLine(string.Format("{0} {1} {2}\n", pis.First(), pis.Last(), txt));
            //Interaction.WriteLine("");
            return(topoInfo);
        }
Esempio n. 13
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);
        }
Esempio n. 14
0
        private static TopoInfo GetRoom()
        {
            roomCount++;

            var p1 = Interaction.GetPoint("房间坐标1");

            if (double.IsNaN(p1.X))
            {
                return(null);                   //这里是出口
            }
            var p2 = Interaction.GetPoint("房间坐标2");

            if (double.IsNaN(p2.X))
            {
                return(null);                   //这里是出口
            }
            string room = GetText(p1, p2);

            if (string.IsNullOrEmpty(room))
            {
                room = Interaction.GetString("输入房间名称");
                if (string.IsNullOrEmpty(room))
                {
                    room = "房间_" + roomCount;
                }
            }

            PointInfo pi1      = GetPointInfo(p1);
            PointInfo pi2      = GetPointInfo(p2);
            TopoInfo  topoInfo = GetTopoInfo(room, AreaTypes.机房, pi1, pi2);

            Interaction.WriteLine(string.Format("{0} {1} {2}", pi1, pi2, room));
            Interaction.WriteLine("");

            //string xml = XmlSerializeHelper.GetXmlText(topoInfo);
            //Gui.TextReport("房间:" + txt, xml, 700, 500);

            return(topoInfo);
        }
Esempio n. 15
0
        public static void PolylineInfo() // mod by WY 20130202
        {
            ObjectId id = Interaction.GetEntity("\nSpecify a polyline", typeof(Polyline));

            if (id == ObjectId.Null)
            {
                return;
            }
            Polyline poly = id.QOpenForRead <Polyline>();

            for (int i = 0; i <= poly.EndParam; i++)
            {
                Interaction.WriteLine("[Point {0}] coord: {1}; bulge: {2}", i, poly.GetPointAtParameter(i), poly.GetBulgeAt(i));
            }
            List <ObjectId> txtIds = new List <ObjectId>();
            double          height = poly.GeometricExtents.MaxPoint.DistanceTo(poly.GeometricExtents.MinPoint) / 50.0;

            for (int i = 0; i < poly.NumberOfVertices; i++)
            {
                txtIds.Add(Draw.MText(i.ToString(), height, poly.GetPointAtParameter(i), 0, true));
            }
            Interaction.GetString("\nPress ENTER to exit");
            txtIds.QForEach(x => x.Erase());
        }
Esempio n. 16
0
        public static void LoadPoints()
        {
            string txt    = Gui.InputBox("输入坐标");
            double size   = Interaction.GetValue("点大小", 2);
            double height = Interaction.GetValue("文字高度", 2);
            string key    = Interaction.GetString("搜索", "");

            string[] lines = txt.Split('\n');
            for (int i = 0; i < lines.Length; i++)
            {
                string line = lines[i].Trim();
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }
                string[] parts = line.Split(',');
                string   name  = parts[0];
                double   x     = parts[2].ToDouble();
                double   y     = parts[3].ToDouble();
                double   z     = parts[4].ToDouble();

                if (string.IsNullOrEmpty(key) || name == key)
                {
                    Point3d point = new Point3d(x, y, z);
                    Draw.Point(point);
                    if (size > 0)
                    {
                        Draw.Circle(point, size);
                    }
                    if (height > 0)
                    {
                        Draw.Text(name, height, point);
                    }
                }
            }
        }
Esempio n. 17
0
        private static TopoInfo GetRoomEx()
        {
            roomCount++;

            int              pCout = 0;
            List <Point3d>   ps    = new List <Point3d>();
            List <PointInfo> pis   = new List <PointInfo>();
            double           pMinX = double.MaxValue;
            double           pMinY = double.MaxValue;
            double           pMaxX = double.MinValue;
            double           pMaxY = double.MinValue;

            int     ibegin    = 0;
            Point3d lineBegin = new Point3d();

            while (true)
            {
                pCout++;
                var p1 = Interaction.GetPoint("房间坐标" + pCout);
                if (double.IsNaN(p1.X))
                {
                    if (pis.Count >= 2)
                    {
                        break; //出口
                    }
                    else
                    {
                        continue;
                    }
                }
                ps.Add(p1);
                PointInfo pi1 = GetPointInfo(p1);

                if (ibegin == 0)
                {
                    lineBegin = p1;
                    ibegin    = 1;
                }
                else
                {
                    var leftLine = Draw.Line(lineBegin, p1);
                    lineBegin = p1;
                    // leftLine.SetLayer("aaa");

                    leftLine.QOpenForWrite <Entity>(line => line.ColorIndex = 3);
                    var arrow = Modify.Group(new[] { leftLine });
                }

                pis.Add(pi1);

                if (p1.X < pMinX)
                {
                    pMinX = p1.X;
                }
                if (p1.Y < pMinY)
                {
                    pMinY = p1.Y;
                }

                if (p1.Y > pMaxY)
                {
                    pMaxY = p1.Y;
                }
                if (p1.X > pMaxX)
                {
                    pMaxX = p1.X;
                }
            }

            Point3d pMin = Point3d.Origin;
            Point3d pMax = Point3d.Origin;

            if (pis.Count == 2)
            {
                pMin = ps[0];
                pMax = ps[1];
            }
            else
            {
                pMin = new Point3d(pMinX, pMinY, 0);
                pMax = new Point3d(pMaxX, pMaxY, 0);
            }

            string room = GetText(pMin, pMax);

            if (string.IsNullOrEmpty(room))
            {
                room = Interaction.GetString("输入房间名称");
                if (string.IsNullOrEmpty(room))
                {
                    room = "房间_" + roomCount;
                }
            }

            TopoInfo topoInfo = GetTopoInfo(room, AreaTypes.机房, pis);

            Interaction.WriteLine(string.Format("{0} {1} {2}", pis.First(), pis.Last(), room));
            Interaction.WriteLine("");

            //string xml = XmlSerializeHelper.GetXmlText(topoInfo);
            //Gui.TextReport("房间:" + txt, xml, 700, 500);

            return(topoInfo);
        }