Пример #1
0
        //坐标数据表GridList生成巷道
        public void DrawStatic()
        {
            List <DBTunnel> inList = new List <DBTunnel>();

            for (int i = 1; i <= hand.Count; i++)
            {
                bool     isAddpoint = false;
                DBTunnel dbtunnel   = new DBTunnel();
                dbtunnel.BasePoints = new List <DBVertice>();
                foreach (var item in tunnels)
                {
                    if (item.HandleValue == -i)
                    {
                        dbtunnel.BasePoints.Add(new DBVertice(item.X, item.Y, item.Z));
                        isAddpoint = true;
                    }
                }
                if (isAddpoint)
                {
                    inList.Add(dbtunnel);
                }
                else
                {
                    continue;
                }
            }
            DrawTunnel.StaticDrawSquareTunnel(inList);

            List <Tunnel> deleteTunnel = new List <Tunnel>();

            foreach (var tunnel in tunnels)
            {
                if (tunnel.HandleValue < 0)
                {
                    deleteTunnel.Add(tunnel);
                }
            }
            foreach (var tunnel in deleteTunnel)
            {
                tunnels.Remove(tunnel);
            }
        }
Пример #2
0
        static public void transformToTunnel()
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;
            Editor   ed  = doc.Editor;
            PromptSelectionResult res = ed.SelectAll();

            if (res.Status == PromptStatus.Error)
            {
                return;
            }

            Autodesk.AutoCAD.EditorInput.SelectionSet SS = res.Value;

            var tmpidarray = SS.GetObjectIds();
            var idArray    = SS.GetObjectIds();

            Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = db.TransactionManager;
            List <DBTunnel> inList = new List <DBTunnel>();

            Utils.TransactionControl(() =>
            {
                foreach (ObjectId id in tmpidarray)
                {
                    Entity entity = (Entity)tm.GetObject(id, OpenMode.ForWrite, true);

                    if (!(entity is Line) && !(entity is Autodesk.AutoCAD.DatabaseServices.Polyline))
                    {
                        continue;
                    }

                    if (entity is Line)
                    {
                        Line line           = entity as Line;
                        DBTunnel dbTunnel   = new DBTunnel();
                        dbTunnel.BasePoints = new List <DBVertice>
                        {
                            new DBVertice(line.StartPoint), new DBVertice(line.EndPoint)
                        };
                        inList.Add(dbTunnel);
                        line.Erase();
                    }
                    else if (entity is Autodesk.AutoCAD.DatabaseServices.Polyline)
                    {
                        Autodesk.AutoCAD.DatabaseServices.Polyline polyline =
                            entity as Autodesk.AutoCAD.DatabaseServices.Polyline;

                        DBTunnel dbTunnel   = new DBTunnel();
                        dbTunnel.BasePoints = new List <DBVertice>();

                        for (int i = 0; i < polyline.NumberOfVertices; i++)
                        {
                            dbTunnel.BasePoints.Add(new DBVertice(polyline.GetPoint3dAt(i)));
                        }

                        if (polyline.Closed == true)
                        {
                            dbTunnel.IsClosed = true;
                        }

                        inList.Add(dbTunnel);
                        polyline.Erase();
                    }
                }
            });
            var resList = DrawTunnel.StaticDrawSquareTunnel(inList);
        }