Exemple #1
0
        protected override FileTypeList AddFileTypes(FileReadOptions options)
        {
            var result = new FileTypeList();

            result.AddFileType("Esri ASCII raster format (*.asc)", "asc", true);
            return(result);
        }
Exemple #2
0
        protected override FileTypeList AddFileTypes(FileReadOptions options)
        {
            var result = new FileTypeList();

            result.AddFileType("IBRA-Model (*.ibra, *.iga)", "ibra", "iga", true);
            return(result);
        }
Exemple #3
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var selectDwgDialog = new OpenFileDialog
            {
                Filters =
                {
                    new FileFilter("AutoCAD Drawings", new string[] { "dwg" })
                }
            };

            if (selectDwgDialog.ShowDialog(RhinoEtoApp.MainWindow) == DialogResult.Ok)
            {
                var options = new FileReadOptions
                {
                    ImportMode = true
                };
                if (!RhinoDoc.ReadFile(selectDwgDialog.FileName, options))
                {
                    return(Result.Failure);
                }

                ZoomNow.ZoomRhinoDoc();
                AllLayerOn();
            }

            Layer[] building = GetMultiLayerDialog("选取建筑外轮廓所在图层");
            if (building == null)
            {
                return(Result.Failure);
            }

            return(Result.Success);
        }
Exemple #4
0
        ///<summary>Defines file extensions that this import plug-in is designed to read.</summary>
        /// <param name="options">Options that specify how to read files.</param>
        /// <returns>A list of file types that can be imported.</returns>
        protected override FileTypeList AddFileTypes(FileReadOptions options)
        {
            var result = new FileTypeList();

            result.AddFileType("Salamander: Robot File (*.rtd)", "rtd");
            result.AddFileType("Salamander File (*.s3b)", "s3b");
            result.AddFileType("Salamander: GSA Text File (*.gwa)", "gwa");
            return(result);
        }
Exemple #5
0
        public TextFileReader(TextFileHandle fileHandle, FileReadOptions readType, TextCodepage codePage, long skipHeaderLines, long skipFooterLines)
        {
            System.Diagnostics.Debug.Assert(fileHandle != null);
            this.fileHandle = fileHandle;

            this.readType        = readType;
            this.codePage        = codePage;
            this.skipFooterLines = skipFooterLines;
            this.skipHeaderLines = skipHeaderLines;
        }
Exemple #6
0
        /// <summary>
        /// Is called when a user requests to import a ."rtd file.
        /// It is actually up to this method to read the file itself.
        /// </summary>
        /// <param name="filename">The complete path to the new file.</param>
        /// <param name="index">The index of the file type as it had been specified by the AddFileTypes method.</param>
        /// <param name="doc">The document to be written.</param>
        /// <param name="options">Options that specify how to write file.</param>
        /// <returns>A value that defines success or a specific failure.</returns>
        protected override bool ReadFile(string filename, int index, RhinoDoc doc, FileReadOptions options)
        {
            Host.EnsureInitialisation(true);
            var mdoc = Core.Instance.OpenDocument(filename);

            if (mdoc != null)
            {
                Core.Instance.ActiveDocument = mdoc;
            }
            return(mdoc != null);
        }
Exemple #7
0
        private FunctionResult Execute(string fileName, FileReadOptions readType, TextFileReaderFields fields, int skipHeaderLines = 0, int skipFooterLines = 0, TextCodepage codepage = TextCodepage.Default)
        {
            FunctionExecutor tester = (new FunctionTester <TextFileRead.TextFileRead>()).Compile(
                new PropertyValue(TextFileReadShared.CodepagePropertyName, codepage),
                new PropertyValue(TextFileReadShared.ReadTypePropertyName, readType),
                new PropertyValue(TextFileReadShared.FieldsPropertyName, fields),
                new PropertyValue(TextFileReadShared.SkipHeaderLinesPropertyName, skipHeaderLines),
                new PropertyValue(TextFileReadShared.SkipFooterLinesPropertyName, skipFooterLines));
            var result = tester.Execute(new ParameterValue(FileShared.FilePathPropertyName, fileName));

            Assert.IsFalse(FileHelpers.IsFileLocked(fileName));
            return(result);
        }
 /// <summary>
 /// Called whenever a Rhino document is being loaded and plug-in user data was
 /// encountered written by a plug-in with this plug-in's GUID.
 /// </summary>
 public void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
 {
     archive.Read3dmChunkVersion(out var major, out var minor);
     if (MAJOR == major && MINOR == minor)
     {
         // Always read user data even though you might not use it...
         var strings = archive.ReadStringArray();
         if (null != strings && !options.ImportMode && !options.ImportReferenceMode)
         {
             m_strings.AddRange(strings);
         }
     }
 }
Exemple #9
0
        protected override bool ReadFile(string filename, int index, RhinoDoc document, FileReadOptions options)
        {
            try
            {
                var model = default(Model);

                using (var reader = new StreamReader(filename))
                {
                    model = Model.Load(reader);
                }

                model.LoadItems(document);
            }
            catch (Exception ex) when(!System.Diagnostics.Debugger.IsAttached)
            {
                Dialogs.ShowMessage(ex.Message, "Import Error", ShowMessageButton.OK, ShowMessageIcon.Error);

                return(false);
            }

            return(true);
        }
 /// <summary>
 /// Called whenever a Rhino document is being loaded and plug-in user data was
 /// encountered written by a plug-in with this plug-in's GUID.
 /// </summary>
 protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
 {
     archive.Read3dmChunkVersion(out var major, out var minor);
     if (MAJOR == major && MINOR == minor)
     {
         SampleCsStringTable string_table = SampleCsStringTable.Instance;
         string_table.ReadDocument(doc, archive, options);
     }
 }
        protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
        {
            archive.Read3dmChunkVersion(out var major, out var minor);
            if (major == 1 && minor == 0)
            {
                var t = new ModelEntityTable();
                t.ReadDocument(archive);

                if (!options.ImportMode && !options.ImportReferenceMode)
                {
                    if (t.Count > 0)
                    {
                        this.ModelEntityTable = t;
                    }
                }
            }
        }
Exemple #12
0
 protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
 {
     GableRoofCommand.DefaultHeight = archive.ReadDouble();
 }
Exemple #13
0
        protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
        {
            int major, minor;

            archive.Read3dmChunkVersion(out major, out minor);
            byte[] data = archive.ReadByteArray();
            if (!archive.ReadErrorOccured && data != null)
            {
                Host.EnsureInitialisation(true);
                ModelDocument mDoc = Document.FromBinary <ModelDocument>(data);
                Core.Instance.ActiveDocument = mDoc;
            }
            base.ReadDocument(doc, archive, options);
        }
Exemple #14
0
        protected override bool ReadFile(string filename, int index, RhinoDoc doc, FileReadOptions options)
        {
            string line;

            // Read the file and display it line by line.
            StreamReader file   = new StreamReader(filename);
            var          obj    = new ASCObject();
            var          points = new List <Point3d>();
            var          y      = 0;

            while ((line = file.ReadLine()) != null)
            {
                string[] components = Regex.Split(line, @"\s+");
                if (components.Length == 2)
                {
                    var val = components[1];
                    switch (components[0])
                    {
                    case "ncols": obj.ncols = int.Parse(val); break;

                    case "nrows": obj.nrows = int.Parse(val); break;

                    case "xllcorner": obj.xllcorner = int.Parse(val); break;

                    case "yllcorner": obj.yllcorner = int.Parse(val); break;

                    case "cellsize": obj.cellsize = float.Parse(val); break;

                    case "NODATA_value": obj.NODATA_value = float.Parse(val); break;
                    }
                }
                else
                {
                    var x = 0;
                    foreach (var item in components)
                    {
                        float _x = obj.xllcorner + obj.cellsize * x;
                        float _y = obj.yllcorner - obj.cellsize * y + obj.cellsize * obj.nrows;
                        float _z = float.Parse(item);
                        points.Add(new Point3d(_x, _y, _z));
                        x += 1;
                    }
                    y++;
                }
            }

            var importAsPointCloud = true;
            var importAsMesh       = true;

            if (!Settings.TryGetBool(ASCImportOptionPageLayout.KEY_POINTCLOUD, out importAsPointCloud))
            {
                importAsPointCloud = false;
            }

            if (!Settings.TryGetBool(ASCImportOptionPageLayout.KEY_MESH, out importAsMesh))
            {
                importAsPointCloud = true;
            }

            if (importAsPointCloud)
            {
                var pc = new PointCloud(points);
                doc.Objects.AddPointCloud(pc);
            }

            if (importAsMesh)
            {
                int  faceCount = 0;
                Mesh mesh      = new Mesh();
                mesh.Vertices.AddVertices(points);

                for (int i = 0; i < obj.nrows * (obj.ncols - 1); i++)
                {
                    if (faceCount < (obj.nrows - 1))
                    {
                        var A    = i;
                        var B    = i + 1;
                        var C    = (i + obj.nrows) + 1;
                        var D    = (i + obj.nrows);
                        var face = new MeshFace(A, B, C, D);
                        mesh.Faces.AddFace(face);
                        faceCount += 1;
                    }
                    else
                    {
                        faceCount = 0;
                    }
                }
                mesh.FaceNormals.ComputeFaceNormals();
                mesh.Compact();
                doc.Objects.AddMesh(mesh);
            }

            doc.Views.Redraw();
            file.Close();
            return(true);
        }
Exemple #15
0
 private FunctionResult Execute(string fileName, FileReadOptions readType = FileReadOptions.Complete)
 {
     return(Execute(fileName, readType, new TextFileReaderFields()));
 }
Exemple #16
0
        /// <summary>
        /// Called whenever a Rhino document is being loaded and plug-in user data was
        /// encountered written by a plug-in with this plug-in's GUID.
        /// </summary>
        protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
        {
            archive.Read3dmChunkVersion(out var major, out var minor);
            if (MAJOR == major && MINOR == minor)
            {
                // Always read user data even though you might not use it.

                var string_table = new SampleCsStringDocumentData();
                string_table.ReadDocument(archive);

                var simple_table = new SampleCsSimpleDocumentDataTable();
                simple_table.ReadDocument(archive);

                var dictionary = archive.ReadDictionary();

                if (!options.ImportMode && !options.ImportReferenceMode)
                {
                    if (string_table.Count > 0)
                    {
                        StringDocumentDataTable.AddRange(string_table.ToArray());
                    }

                    if (simple_table.Count > 0)
                    {
                        SimpleDocumentDataTable.AddRange(simple_table.ToArray());
                    }

                    if (null != dictionary && dictionary.Count > 0)
                    {
                        Dictionary = dictionary;
                    }
                }
            }
        }
Exemple #17
0
        protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
        {
            Beams.Clear();
            CurrentBeam = null;

            if (unitfactors.ContainsKey(RhinoDoc.ActiveDoc.ModelUnitSystem))
            {
                Unitfactor = unitfactors[RhinoDoc.ActiveDoc.ModelUnitSystem];
            }
            else
            {
                MessageBox.Show("Cross section design tool does not support the chosen" +
                                "unit system. Unit system will be changed to millimeters.");
                RhinoDoc.ActiveDoc.ModelUnitSystem = UnitSystem.Millimeters;
                Unitfactor = unitfactors[RhinoDoc.ActiveDoc.ModelUnitSystem];
            }



            try
            {
                ArchivableDictionary dict = archive.ReadDictionary();

                int i     = 1;
                int count = 0;
                if (dict["BeamCount"] != null)
                {
                    count = (int)dict["BeamCount"];
                }

                dict.Set("CountUserData", CountableUserData.getCounter());
                while (i < count + 1)
                {
                    Beam   bTemp;
                    string beamName = (string)dict["BeamName" + i];

                    if ((string)dict["BeamType" + i] == "Column")
                    {
                        bTemp = new Column(beamName, dict.GetDouble("Gammas" + i),
                                           dict.GetDouble("Gammac" + i),
                                           dict.GetDouble("Gammar" + i),
                                           dict.GetDouble("Acc" + i))
                        {
                            Length = (double)dict["ColLength" + i],
                            Ky     = (double)dict["ky" + i],
                            Kz     = (double)dict["kz" + i],
                        };
                        ((Column)bTemp).ColumnCalcSettings.ColumnCalMethod[ColumnCalculationMethod.NominalCurvature1] =
                            dict.GetBool("ColumnCalculationSettings1" + i);
                        ((Column)bTemp).ColumnCalcSettings.ColumnCalMethod[ColumnCalculationMethod.NominalCurvature2] =
                            dict.GetBool("ColumnCalculationSettings2" + i);
                        ((Column)bTemp).ColumnCalcSettings.ColumnCalMethod[ColumnCalculationMethod.NominalStiffness1] =
                            dict.GetBool("ColumnCalculationSettings3" + i);
                        ((Column)bTemp).ColumnCalcSettings.ColumnCalMethod[ColumnCalculationMethod.NominalStiffness2] =
                            dict.GetBool("ColumnCalculationSettings4" + i);
                    }
                    else
                    {
                        bTemp = new Beam(beamName, dict.GetDouble("Gammas" + i),
                                         dict.GetDouble("Gammac" + i),
                                         dict.GetDouble("Gammar" + i),
                                         dict.GetDouble("Acc" + i))
                        {
                        };
                    }

                    bTemp.ClimateCond = new ClimateCondition(
                        (int)dict["Rh" + i],
                        (int)dict["T0" + i],
                        (int)dict["T" + i],
                        bTemp);

                    string       crossSecName = (string)dict["CrossSecName" + i];
                    CrossSection cTemp;
                    if ((string)dict["CrossSectionType" + i] == "Basic")
                    {
                        cTemp =
                            new CrossSection(crossSecName, bTemp)
                        {
                        };
                    }

                    else if (dict.GetString("CrossSectionType" + i) == "Rect")
                    {
                        cTemp =
                            new RectangleCrossSection(crossSecName, bTemp)
                        {
                            NoReinfH       = (int)dict["NoReinfH" + i],
                            NoReinfW       = (int)dict["NoReinfW" + i],
                            ConcreteCover  = (int)dict["ConcreteCover" + i],
                            ConcreteWidth  = dict.GetInteger("ConcreteWidth" + i),
                            ConcreteHeight = dict.GetInteger("ConcreteHeight" + i),
                            HasSteelShell  = dict.GetBool("HasSteelShell" + i),
                            SteelThickness = dict.GetDouble("SteelThickness" + i),
                            MainD          = dict.GetInteger("MainDiameter" + i),
                            StirrupD       = dict.GetInteger("StirrupDiameter" + i),
                            SteelMaterial  = new SteelMaterial(dict.GetString("SteelMaterialName" + i) ?? "S355", SteelType.StructuralSteel, bTemp),
                            ReinfMaterial  = new SteelMaterial(dict.GetString("ReinforcementMaterialName" + i ?? "B500B"), SteelType.Reinforcement, bTemp),
                            Rotation       = dict.GetInteger("Rotation" + i),
                        };
                    }
                    else
                    {
                        cTemp =
                            new CircleCrossSection(crossSecName, bTemp)
                        {
                            NoReinf          = (int)dict["NoReinf"],
                            ConcreteCover    = (int)dict["ConcreteCover" + i],
                            ConcreteDiameter = dict.GetInteger("ConcreteDiameter" + i),
                            HasSteelShell    = dict.GetBool("HasSteelShell" + i),
                            SteelThickness   = dict.GetDouble("SteelThickness" + i),
                            MainD            = dict.GetInteger("MainDiameter" + i),
                            StirrupD         = dict.GetInteger("StirrupDiameter" + i),
                            SteelMaterial    = new SteelMaterial(dict.GetString("SteelMaterialName" + i) ?? "S355", SteelType.StructuralSteel, bTemp),
                            ReinfMaterial    = new SteelMaterial(dict.GetString("ReinforcementMaterialName" + i) ?? "B500B", SteelType.Reinforcement, bTemp),
                        };
                    }


                    //Sets a link between reinforcements and the beam
                    List <int> reinforcements = ((int[])dict["reinf" + i]).ToList();

                    List <Reinforcement> temp = GetReinforcements(reinforcements);
                    temp.ForEach(o => o.Material.Bm = bTemp);



                    //Sets a link between geometry larges and the beam
                    List <int> geometryLarges = ((int[])dict["geomLarges" + i]).ToList();

                    List <GeometryLarge> gls = GetGeometryLarges(geometryLarges);
                    gls.ForEach(o => o.Material.Bm = bTemp);


                    cTemp.ConcreteMaterial = new ConcreteMaterial((string)dict["ConcreteStrenghtClass" + i], bTemp);
                    bTemp.CrossSec         = cTemp;
                    geometryLarges.ForEach(id => cTemp.GeometryLargeIds.Add(id));
                    reinforcements.ForEach(id => cTemp.ReinforementIds.Add(id));
                    bTemp.Id = dict.GetInteger("BeamId" + i);
                    Beams.Add(bTemp);



                    //Set loadCases
                    int lc_n = dict.GetInteger("NumberOfLoadCases" + i);
                    int k    = 1;
                    while (k <= lc_n)
                    {
                        string name           = dict.GetString("LoadCaseName" + i + "s" + k);
                        int    limitStatenumb = dict.GetInteger("LimitState" + i + "s" + k);

                        LimitState ls;
                        switch (limitStatenumb)
                        {
                        case 0:
                            ls = LimitState.Ultimate; break;

                        case 1:
                            ls = LimitState.Service_CH; break;

                        case 2:
                            ls = LimitState.Service_FR; break;

                        case 3:
                            ls = LimitState.Service_QP; break;

                        default:
                            ls = LimitState.Ultimate; break;
                        }
                        ;

                        if (dict.GetString("LoadCaseType" + i + "s" + k) == "ColLoadCase")
                        {
                            ColLoadCase clc = new ColLoadCase(
                                dict.GetDouble("N_Ed" + i + "s" + k),
                                dict.GetDouble("M_EzTop" + i + "s" + k),
                                dict.GetDouble("M_EzBottom" + i + "s" + k),
                                dict.GetDouble("M_EyTop" + i + "s" + k),
                                dict.GetDouble("M_EyBottom" + i + "s" + k),
                                (Column)bTemp,
                                dict.GetDouble("Ratio" + i + "s" + k),
                                name,
                                dict.GetDouble("CCurve" + i + "s" + k),
                                ls);
                        }
                        else if (dict.GetString("LoadCaseType" + i + "s" + k) == "SimpleLoadCase")
                        {
                            SimpleLoadCase slc = new SimpleLoadCase(
                                dict.GetDouble("N_Ed" + i + "s" + k),
                                dict.GetDouble("M_Edz" + i + "s" + k),
                                dict.GetDouble("M_Edy" + i + "s" + k),
                                bTemp,
                                name,
                                ls);
                            bTemp.LoadCases.Add(slc);
                        }
                        k++;
                    }


                    i++;
                }
                Countable.SetCounter(i - 2);
                if (Beams.Count != 0)
                {
                    int currentID = (int)dict["currentBeamId"];
                    if (currentID != -1)
                    {
                        CurrentBeam = Beams.FirstOrDefault(beam => beam.Id == currentID);
                    }
                }

                CountableUserData.setCounter((int)dict["CountableUserData"]);

                if (MainForm != null)
                {
                    MainForm.ChangeToStartView();
                }

                //If there is previous display results, clear them
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                base.ReadDocument(doc, archive, options);
            }
        }
Exemple #18
0
        /// <summary>
        /// Called whenever a Rhino document is being loaded and plug-in user data was
        /// encountered written by a plug-in with this plug-in's GUID.
        /// </summary>
        protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
        {
            SampleCsStringTable string_table = SampleCsStringTable.Instance;

            string_table.ReadDocument(doc, archive, options);
        }
 protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
 {
     RigidBodyManager.World = new World(new CollisionSystemSAP());
     Rhino.Collections.ArchivableDictionary dict = archive.ReadDictionary();
     RigidBodyManager.GuidList           = (List <Guid>)RigidBodyManager.ByteArrayToObject(dict["guidList"] as byte[]);
     RigidBodyManager.RigidBodies        = (List <RigidBody>)RigidBodyManager.ByteArrayToObject(dict["rigidBodies"] as byte[]);
     RigidBodyManager.GeometryList       = (List <Brep>)RigidBodyManager.ByteArrayToObject(dict["geometryList"] as byte[]);
     TimePanel.Instance.MaxFrameBoxValue = (int)dict["MaxFrameBoxValue"];
     //Reset
     TimePanel.Instance.ResetNotSavable();
     WorldCount = (int)dict["worldCount"];
 }
        /// <inheritdoc />
        /// <summary>
        /// Called whenever a Rhino document is being loaded and plug-in user data was
        /// encountered written by a plug-in with this plug-in's GUID.
        /// </summary>
        protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
        {
            archive.Read3dmChunkVersion(out var major, out var minor);
            if (MAJOR == major && MINOR == minor)
            {
                var dictionary = archive.ReadDictionary();
                if (null != dictionary && !options.ImportMode && !options.ImportReferenceMode)
                {
                    m_dictionary = dictionary.Clone();

                    // Note, if we read our user data from a document, then
                    // assume that we can to track commands...
                    CommandTrackingEnabled = true;
                }
            }
        }