Example #1
0
        /// <summary>
        /// 读取中心线坐标
        /// </summary>
        /// <param name="quWindow"></param>
        public static void Opencsv(TWindow quWindow)
        {
            OpenFileDialog ofd = new OpenFileDialog {
                Title  = "请选择坐标文件",
                Filter = "(*.csv)|*.csv|(*.txt)|*.txt",
            };

            if (ofd.ShowDialog() == true)
            {
                string filePath = ofd.FileName;
                try {
                    StreamReader stream = new StreamReader(filePath);
                    while (stream.Peek() != -1)
                    {
                        string   line = stream.ReadLine();
                        string[] ss   = line.Split(',');
                        XYZ      pt   = new XYZ(SToD(ss[2]) * 1000 / 304.8, SToD(ss[3]) * 1000 / 304.8, SToD(ss[4]) * 1000 / 304.8);
                        ptlist.Add(pt);
                    }
                    quWindow.LabelNum.Content = ptlist.Count.ToString();
                }
                catch (Exception exception) {
                    TaskDialog.Show("Error", exception.Message);
                }
            }
        }
Example #2
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument uiDoc = commandData.Application.ActiveUIDocument;
            Document   doc   = uiDoc.Document;

            _uiDoc = uiDoc;
            _doc   = doc;
            List <Element> list     = GetGuanPian(doc);
            TWindow        quWindow = new TWindow()
            {
                WindowStartupLocation = WindowStartupLocation.CenterScreen, MaxHeight = 320, MaxWidth = 500
            };

            quWindow.ComboBoxCuoFeng.SelectedIndex = 0;
            list.ForEach(m => quWindow.GuanPian.Items.Add(m.Name));
            quWindow.GuanPian.SelectedIndex = list.Count - 1;
            quWindow.ShowDialog();
            return(Result.Succeeded);
        }
Example #3
0
        /// <summary>
        /// 生成管片
        /// </summary>
        /// <param name="quWindow"></param>
        public static void CreateTunnel(TWindow quWindow)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            double r        = SToD(quWindow.TextBoxR.Text) * 1000 / 304.8;
            double h        = SToD(quWindow.TextBoxH.Text) * 1000 / 304.8;
            double w        = SToD(quWindow.TextBoxW.Text) * 1000 / 304.8;
            int    n        = (int)SToD(quWindow.TextBoxLSGS.Text);
            string cuoFeng  = quWindow.ComboBoxCuoFeng.SelectedItem.ToString();
            double BZK1     = SToD(quWindow.BZK1.Text).DegreeToR();
            double LJKN1    = SToD(quWindow.LJKN1.Text).DegreeToR();
            double LJKW1    = SToD(quWindow.LJKW1.Text).DegreeToR();
            double BZK2     = SToD(quWindow.BZK2.Text).DegreeToR();
            double LJKN2    = SToD(quWindow.LJKN2.Text).DegreeToR();
            double LJKW2    = SToD(quWindow.LJKW2.Text).DegreeToR();
            string GuanPian = quWindow.GuanPian.SelectedItem.ToString();

            if (r * h * w * n * BZK1 * BZK2 * LJKN1 * LJKN2 * LJKW1 * LJKW2 == 0)
            {
                TaskDialog.Show("Error", "参数输入有误,请重新输入!");
                quWindow.Activate();
            }
            else if (ptlist == null)
            {
                TaskDialog.Show("Error", "未选择线路坐标表或坐标表有误,请重新选择!");
                quWindow.Activate();
            }
            else
            {
                XYZ[] ptXyzs1       = GetDivPoint(r, BZK1, LJKW1, 0);
                XYZ[] ptXyzs2       = GetDivPoint(r - h, BZK1, LJKN1, 0);
                XYZ[] ptXyzs3       = GetDivPoint(r, BZK2, LJKW2, 0);
                XYZ[] ptXyzs4       = GetDivPoint(r - h, BZK2, LJKN2, 0);
                int   numOfGuanPian = n;

                for (int i = 0; i < numOfGuanPian - 1; i++)
                {
                    Line      line        = Line.CreateBound(ptlist[i], ptlist[i + 1]);
                    Transform transform1  = line.ComputeDerivatives(0, false);
                    Transform transform11 = Transform.CreateTranslation(ptlist[i]);
                    var       a           = transform11.BasisZ;
                    Transform transform2  = line.ComputeDerivatives(1, false);
                    Transform transform22 = Transform.CreateTranslation(ptlist[i + 1]);
                    XYZ[]     ptXyzs11    = TranPts(transform11, ptXyzs1);
                    XYZ[]     ptXyzs22    = TranPts(transform11, ptXyzs2);
                    XYZ[]     ptXyzs33    = TranPts(transform22, ptXyzs3);
                    XYZ[]     ptXyzs44    = TranPts(transform22, ptXyzs4);

                    for (int j = 0; j < 6; j++)
                    {
                        XYZ[] pt1 = new XYZ[12];
                        for (int k = 0; k < 3; k++)
                        {
                            pt1[k] = ptXyzs11[k + j * 3];
                        }

                        for (int l = 0; l < 3; l++)
                        {
                            pt1[l + 3] = ptXyzs22[l + j * 3];
                        }

                        for (int m = 0; m < 3; m++)
                        {
                            pt1[m + 6] = ptXyzs33[m + j * 3];
                        }

                        for (int nn = 0; nn < 3; nn++)
                        {
                            pt1[nn + 9] = ptXyzs44[nn + j * 3];
                        }
                        SimpelTunnel.CreateAdaptiveComponentFamily(pt1, GuanPian);
                    }
                }

                quWindow.Close();

                sw.Stop();
                var time = sw.Elapsed;
                TaskDialog.Show("OK", $"共耗时{time.TotalSeconds:f0}秒,生成{numOfGuanPian*6-6}个管片!");
            }
        }