Beispiel #1
0
        public void iFds()
        {
            Utils.Init();
#if ARX_APP
            OpenFileDialog theDialog = new OpenFileDialog();
            theDialog.Title            = "Open FDS file";
            theDialog.Filter           = "FDS files (*.fds)|*.fds|All files (*.*)|*.*";
            theDialog.RestoreDirectory = true;
#elif BRX_APP
            Bricscad.Windows.OpenFileDialog theDialog = new Bricscad.Windows.OpenFileDialog("Open FDS file", "", "*.fds", "Dialog name", Bricscad.Windows.OpenFileDialog.OpenFileDialogFlags.DefaultIsFolder);
#endif

            if (theDialog.ShowDialog() == DialogResult.OK)
            {
#if ARX_APP
                string filename = theDialog.FileName;
#elif BRX_APP
                string filename = theDialog.Filename;
#endif
                string[] filelines = File.ReadAllLines(filename);
                double[] xb        = new double[6];
                string   surf      = "";

                foreach (string line in filelines)
                {
                    if (line.Contains("&OBST"))
                    {
                        //&OBST ID = 'OBST1', XB = 6.8,7., 7,64, 1.8,5.234, SURF_ID = 'gypsum_board' /
                        xb   = regXb(line);
                        surf = "";
                        surf = regSurfId(line);

                        Random rnd   = new Random();
                        int    color = rnd.Next(1, 255);

                        // Check if layer exists
                        if (surf != null)
                        {
                            Layers.CreateLayer(surf, Color.FromColorIndex(ColorMethod.ByAci, Convert.ToInt16(color)));
                        }
                        else
                        {
                            surf = "!FDS_OBST[inert](0)";
                            Layers.CreateLayer(surf, Color.FromColorIndex(ColorMethod.ByAci, Convert.ToInt16(color)));
                        }

                        if (xb != null)
                        {
                            Utils.CreateBox(xb[0], xb[1], xb[2], xb[3], xb[4], xb[5], surf);
                        }
                    }
                    else if (line.Contains("&MESH"))
                    {
                        xb   = regXb(line);
                        surf = "!FDS_MESH";
                        Utils.CreateBox(xb[0], xb[1], xb[2], xb[3], xb[4], xb[5], surf);
                    }
                    //ed.WriteMessage(filelines[i]);
                }
            }

            //Utils.CreateBox(0, 4, 0, 0.2, 0, 3, "!FDS_OBST[inert](0)");
            //Utils.CreateBox(-0.2, 0, 0, 4, 0, 3, "!FDS_OBST[inert](0)");
            //Utils.CreateBox(-1, 5, -2, 8, 0, 3.6, "!FDS_MESH");
            //Utils.CreateExtrudedSurface(new Point3d(2, 2, 2), new Point3d(2, 2.4, 2.2), "!FDS_VENT[vent]");
            //Utils.CreateExtrudedSurface(new Point3d(4, -2.4, 0), new Point3d(4, 8.4, 3.0), "!FDS_SLCF[slice]");

            //Utils.ZoomInit();
        }
Beispiel #2
0
        public void iFds()
        {
            CultureInfo culture = new CultureInfo("en-US");

            Utils.Init();
#if ARX_APP
            OpenFileDialog theDialog = new OpenFileDialog();
            theDialog.Title            = "Open FDS file";
            theDialog.Filter           = "FDS files (*.fds)|*.fds|All files (*.*)|*.*";
            theDialog.RestoreDirectory = true;
#elif BRX_APP
            Bricscad.Windows.OpenFileDialog theDialog = new Bricscad.Windows.OpenFileDialog("Open FDS file", "", "*.fds", "Dialog name", Bricscad.Windows.OpenFileDialog.OpenFileDialogFlags.DefaultIsFolder);
#endif

            if (theDialog.ShowDialog() == DialogResult.OK)
            {
#if ARX_APP
                string filename = theDialog.FileName;
#elif BRX_APP
                string filename = theDialog.Filename;
#endif
                string[] filelines = File.ReadAllLines(filename);

                double x1, x2, y1, y2, z1, z2;
                string surf = "";

                foreach (string line in filelines)
                {
                    if (line.Contains("&OBST"))
                    {
                        //&OBST ID = 'OBST1', XB = 6.8,7., 7,64, 1.8,5.234, SURF_ID = 'gypsum_board' /
                        surf = "";

                        Regex regExXb = new Regex(@"XB\s*=\s*(\-*\d*\.{0,1}\d*)\s*,\s*(\-*\d*\.{0,1}\d*)\s*,\s*(\-*\d*\.{0,1}\d*)\s*,\s*(\-*\d*\.{0,1}\d*)\s*,\s*(\-*\d*\.{0,1}\d*)\s*,\s*(\-*\d*\.{0,1}\d*)", RegexOptions.IgnoreCase);
                        Match xb      = regExXb.Match(line);

                        if (xb.Success)
                        {
                            System.Text.RegularExpressions.Group x1G = xb.Groups[1];
                            System.Text.RegularExpressions.Group x2G = xb.Groups[2];
                            System.Text.RegularExpressions.Group y1G = xb.Groups[3];
                            System.Text.RegularExpressions.Group y2G = xb.Groups[4];
                            System.Text.RegularExpressions.Group z1G = xb.Groups[5];
                            System.Text.RegularExpressions.Group z2G = xb.Groups[6];
                            x1 = Convert.ToDouble(x1G.Value, culture);
                            x2 = Convert.ToDouble(x2G.Value, culture);
                            y1 = Convert.ToDouble(y1G.Value, culture);
                            y2 = Convert.ToDouble(y2G.Value, culture);
                            z1 = Convert.ToDouble(z1G.Value, culture);
                            z2 = Convert.ToDouble(z2G.Value, culture);

                            ed.WriteMessage(x1.ToString() + "\n");
                            ed.WriteMessage(x2.ToString() + "\n");
                            ed.WriteMessage(y1.ToString() + "\n");
                            ed.WriteMessage(y2.ToString() + "\n");
                            ed.WriteMessage(z1.ToString() + "\n");
                            ed.WriteMessage(z2.ToString() + "\n");

                            Regex regExSurfId = new Regex(@"SURF_ID\s*=\s*'(.*)'", RegexOptions.IgnoreCase);
                            Match surfId      = regExSurfId.Match(line);
                            surf = surfId.Success ? "!FDS_OBST[" + surfId.Groups[1].Value + "](0)" : "!FDS_OBST[inert](0)";

                            Layers.CreateLayer(surf);

                            if (x1 != x2 && y1 != y2 && z1 != z2)
                            {
                                Utils.CreateBox(x1, x2, y1, y2, z1, z2, surf);
                            }
                        }
                    }
                    //ed.WriteMessage(filelines[i]);
                }
            }

            //Utils.CreateBox(0, 4, 0, 0.2, 0, 3, "!FDS_OBST[inert](0)");
            //Utils.CreateBox(-0.2, 0, 0, 4, 0, 3, "!FDS_OBST[inert](0)");
            //Utils.CreateBox(-1, 5, -2, 8, 0, 3.6, "!FDS_MESH");
            //Utils.CreateExtrudedSurface(new Point3d(2, 2, 2), new Point3d(2, 2.4, 2.2), "!FDS_VENT[vent]");
            //Utils.CreateExtrudedSurface(new Point3d(4, -2.4, 0), new Point3d(4, 8.4, 3.0), "!FDS_SLCF[slice]");

            //Utils.ZoomInit();
        }