Example #1
0
        static public void DynamicDrawTrapezoidalTunnel(DBTunnel inTunnel = null)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;
            Editor   ed  = doc.Editor;

            //输入起点坐标
            PromptPointOptions opts = new PromptPointOptions("\nEnter Tunnel Start Point:");
            PromptPointResult  res  = ed.GetPoint(opts);

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

            Point3d firstPoint = res.Value;

            //create Tunnel
            SquareTunnelJig jig       = new SquareTunnelJig(firstPoint);
            SquareTunnel    tmpTunnel = (SquareTunnel)jig.GetEntity();

            for (int i = 0; ; i++)
            {
                jig.setPromptCounter(i);
                PromptResult drag = ed.Drag(jig);
                if (drag.Status == PromptStatus.Cancel || drag.Status == PromptStatus.None)//画完了
                {
                    Utils.TransactionControl(() =>
                    {
                        List <Point3d> points = tmpTunnel.BasePoints;
                        points.RemoveAt(points.Count - 1);
                        if (points.Count < 2)
                        {
                            return;
                        }
                        SquareTunnel tunnel = new SquareTunnel();
                        tunnel.TunnelType   = DBTunnel.Tunnel_type_t;
                        tunnel.Width_b      = 12;
                        tunnel.Width_t      = 8;
                        tunnel.BasePoints   = points;
                        tunnel.Name         = "巷道";
                        try
                        {
                            tunnel.Location = Project.Instance.getCurrentSurface(doc).Path;
                        }
                        catch (System.Exception) { }
                        Utils.AppendEntity(tunnel);
                        appendNode(tunnel);
                        appendTag(tunnel);

                        tunnel.Dispose();
                        tmpTunnel.Dispose();
                    });
                    break;
                }
                else if (drag.Status == PromptStatus.OK)
                {
                }
            }
        }
Example #2
0
        /**********************************************/

        //通过参数的方式生成方形巷道
        static public List <DBTunnel> StaticDrawSquareTunnel(List <DBTunnel> inList)
        {
            if (inList == null)
            {
                return(null);
            }

            List <DBTunnel> outList = new List <DBTunnel>();

            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;

            foreach (var v in inList)
            {
                if (v.HandleValue > 0)
                {
                    outList.Add(v);
                    continue;
                }
                Utils.TransactionControl(() =>
                {
                    List <Point3d> points = new List <Point3d>();
                    foreach (var point in v.BasePoints)
                    {
                        points.Add(new Point3d(
                                       point.X,
                                       point.Y,
                                       point.Z
                                       ));
                    }
                    SquareTunnel tunnel = new SquareTunnel();
                    tunnel.TunnelType   = DBTunnel.Tunnel_type_s;
                    tunnel.BasePoints   = points;
                    tunnel.SetClose(v.IsClosed);
                    tunnel.Name = (v.Name == null || v.Name == "")?"巷道":v.Name;
                    try
                    {
                        tunnel.Location = (v.Location != null && v.Location != "") ?
                                          v.Location : Project.Instance.getCurrentSurface(doc).Path;
                    }
                    catch (System.Exception) { }

                    Utils.AppendEntity(tunnel);
                    appendNode(tunnel);
                    appendTag(tunnel);

                    DBTunnel dbTunnel = new DBTunnel();
                    dbTunnel.SetProperty(tunnel);
                    tunnel.Dispose();
                    outList.Add(dbTunnel);
                });
            }
            return(outList);
        }