protected override FileTypeList AddFileTypes(FileWriteOptions options) { var result = new FileTypeList(); result.AddFileType("IBRA-Model (*.ibra)", "ibra", true); return(result); }
/// <summary> /// Generate standard obj file write options /// </summary> /// <returns>A FileObjWriteOptions object containing the settings for the export.</returns> private static FileObjWriteOptions CreateObjWriteOptions() { //Create general export settings FileWriteOptions writeOptions = new FileWriteOptions { WriteSelectedObjectsOnly = true, WriteGeometryOnly = true }; //Create obj export settings for everything other than rooms FileObjWriteOptions objWriteOptions = new FileObjWriteOptions(writeOptions) { CreateNgons = false, ExportMaterialDefinitions = true, ExportNormals = true, ExportTcs = true, ExportVcs = true, SignificantDigits = 4, ExportGroupNameLayerNames = FileObjWriteOptions.ObjGroupNames.NoGroups, UseRelativeIndexing = false, MeshParameters = MeshingParameters.FastRenderMesh, MapZtoY = true, UnderbarMaterialNames = true }; return(objWriteOptions); }
/// <summary> /// Called whenever a Rhino is about to save a .3dm file. If you want to save // plug-in document data when a model is saved in a version 5 .3dm file, then // you must override this function to return true and you must override WriteDocument(). /// </summary> public bool ShouldCallWriteDocument(FileWriteOptions options) { return( Count > 0 && false == options.WriteGeometryOnly && false == options.WriteSelectedObjectsOnly ); }
protected override FileTypeList AddFileTypes(FileWriteOptions options) { FileTypeList typeList = new FileTypeList(); typeList.AddFileType("glTF Binary File", ".glb"); typeList.AddFileType("glTF Text File", ".gltf"); return(typeList); }
protected override bool ShouldCallWriteDocument(FileWriteOptions options) { if (TimePanel.Instance.Restarted && TimePanel.Instance.TrackbarValue == 0) { return(true); } else { Dialogs.ShowMessage("You can't save JShapes when you are running an animation so it will be save the starting positions.", "Warning during saving", ShowMessageButton.OK, ShowMessageIcon.Warning); return(true); } }
/// <summary> /// /// </summary> /// <param name="file">3dm file to write to disk.</param> /// <param name="path">Path of the file to write.</param> /// <returns></returns> public static bool Write3dm(RhinoDoc doc, FileWriteOptions options, string path) { var file3dm = new File3dm(); var objectEnumeratorSettings = new ObjectEnumeratorSettings { HiddenObjects = true, IncludeLights = true }; foreach (var rhinoObject in doc.Objects.GetObjectList(objectEnumeratorSettings)) { if ((options.WriteSelectedObjectsOnly && rhinoObject.IsSelected(true) == 1) || (!options.WriteSelectedObjectsOnly) || (rhinoObject.IsSelected(true) == 2)) { file3dm.AllMaterials.Add(doc.Materials[rhinoObject.Attributes.MaterialIndex]); var matId = file3dm.AllMaterials.Count - 1; var att = rhinoObject.Attributes; att.MaterialIndex = matId; switch (rhinoObject.ObjectType) { case ObjectType.Mesh: file3dm.Objects.AddMesh(rhinoObject.Geometry as Rhino.Geometry.Mesh, att); break; case ObjectType.Brep: case ObjectType.Extrusion: case ObjectType.Surface: case ObjectType.SubD: var meshes = rhinoObject.GetMeshes(Rhino.Geometry.MeshType.Default); var mesh = new Rhino.Geometry.Mesh(); foreach (var m in meshes) { mesh.Append(m); } file3dm.Objects.AddMesh(mesh, att); break; } } } return(file3dm.Write(path, 0)); }
protected override void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, FileWriteOptions options) { archive.Write3dmChunkVersion(1, 0); this.ModelEntityTable.WriteDocument(archive); }
protected override void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, FileWriteOptions options) { ArchivableDictionary dict = new ArchivableDictionary(); int i = 1; dict.Set("BeamCount", Beams.Count); dict.Set("CountableUserData", CountableUserData.getCounter()); foreach (Beam beam in Beams) { if (beam.GetType() == typeof(Column)) { Column col = beam as Column; dict.Set("BeamType" + i, "Column"); dict.Set("ky" + i, col.Ky); dict.Set("kz" + i, col.Kz); dict.Set("ColLength" + i, col.Length); dict.Set("CliConcreteStrenghtClass" + i, beam.CrossSec.ConcreteMaterial.StrengthClass ?? null); dict.Set("ColumnCalculationSettings1" + i, col.ColumnCalcSettings.ColumnCalMethod[ColumnCalculationMethod.NominalCurvature1]); dict.Set("ColumnCalculationSettings2" + i, col.ColumnCalcSettings.ColumnCalMethod[ColumnCalculationMethod.NominalCurvature2]); dict.Set("ColumnCalculationSettings3" + i, col.ColumnCalcSettings.ColumnCalMethod[ColumnCalculationMethod.NominalStiffness1]); dict.Set("ColumnCalculationSettings4" + i, col.ColumnCalcSettings.ColumnCalMethod[ColumnCalculationMethod.NominalStiffness2]); } else { dict.Set("BeamType" + i, "Other"); } dict.Set("Rh" + i, beam.ClimateCond.RH); dict.Set("T0" + i, beam.ClimateCond.T0); dict.Set("T" + i, beam.ClimateCond.T); dict.Set("BeamName" + i, beam.Name); dict.Set("Gammac" + i, beam.Gammac); dict.Set("Gammas" + i, beam.Gammas); dict.Set("Gammar" + i, beam.Gammar); dict.Set("Acc" + i, beam.Acc); dict.Set("CrossSecName" + i, beam.CrossSec.Name); dict.Set("ConcreteStrenghtClass" + i, beam.CrossSec.ConcreteMaterial.StrengthClass ?? null); dict.Set("BeamId" + i, beam.CrossSec.Id); dict.Set("geomLarges" + i, beam.CrossSec.GeometryLargeIds); dict.Set("reinf" + i, beam.CrossSec.ReinforementIds); if (beam.CrossSec.GetType() == typeof(RectangleCrossSection)) { RectangleCrossSection crossSectionTemp = beam.CrossSec as RectangleCrossSection; dict.Set("CrossSectionType" + i, "Rect"); dict.Set("NoReinfH" + i, crossSectionTemp.NoReinfH); dict.Set("NoReinfW" + i, crossSectionTemp.NoReinfW); dict.Set("ConcreteCover" + i, crossSectionTemp.ConcreteCover); dict.Set("ConcreteWidth" + i, crossSectionTemp.ConcreteWidth); dict.Set("ConcreteHeight" + i, crossSectionTemp.ConcreteHeight); dict.Set("HasSteelShell" + i, crossSectionTemp.HasSteelShell); dict.Set("SteelThickness" + i, crossSectionTemp.SteelThickness); dict.Set("MainDiameter" + i, crossSectionTemp.MainD); dict.Set("StirrupDiameter" + i, crossSectionTemp.StirrupD); dict.Set("SteelMaterialName" + i, crossSectionTemp.SteelMaterial.StrengthClass ?? null); dict.Set("ReinforcementMaterialName" + i, crossSectionTemp.ReinfMaterial.StrengthClass ?? null); dict.Set("Rotation" + i, crossSectionTemp.Rotation); } else if (beam.CrossSec.GetType() == typeof(CrossSection)) { dict.Set("CrossSectionType" + i, "Basic"); } else if (beam.CrossSec.GetType() == typeof(CircleCrossSection)) { CircleCrossSection crossSectionTemp = beam.CrossSec as CircleCrossSection; dict.Set("CrossSectionType" + i, "Rect"); dict.Set("NoReinf" + i, crossSectionTemp.NoReinf); dict.Set("ConcreteCover" + i, crossSectionTemp.ConcreteCover); dict.Set("ConcreteDiameter" + i, crossSectionTemp.ConcreteDiameter); dict.Set("HasSteelShell" + i, crossSectionTemp.HasSteelShell); dict.Set("SteelThickness" + i, crossSectionTemp.SteelThickness); dict.Set("MainDiameter" + i, crossSectionTemp.MainD); dict.Set("StirrupDiameter" + i, crossSectionTemp.StirrupD); dict.Set("SteelMaterialName" + i, crossSectionTemp.SteelMaterial.StrengthClass ?? null); dict.Set("ReinforcementMaterialName" + i, crossSectionTemp.ReinfMaterial.StrengthClass ?? null); } int k = 1; dict.Set("NumberOfLoadCases" + i, beam.LoadCases.Count); foreach (LoadCase loadCase in beam.LoadCases) { if (loadCase.GetType() == typeof(ColLoadCase)) { ColLoadCase clc = (ColLoadCase)loadCase; dict.Set("LoadCaseType" + i + "s" + k, "ColLoadCase"); dict.Set("N_Ed" + i + "s" + k, clc.N_Ed); dict.Set("M_EzTop" + i + "s" + k, clc.M_EzTop); dict.Set("M_EzBottom" + i + "s" + k, clc.M_EzBottom); dict.Set("M_EyTop" + i + "s" + k, clc.M_EyTop); dict.Set("M_EyBottom" + i + "s" + k, clc.M_EyBottom); dict.Set("Ratio" + i + "s" + k, clc.Ratio); dict.Set("CCurve" + i + "s" + k, clc.Ccurve); } else if (loadCase.GetType() == typeof(SimpleLoadCase)) { SimpleLoadCase slc = (SimpleLoadCase)loadCase; dict.Set("LoadCaseType" + i + "s" + k, "SimpleLoadCase"); dict.Set("N_Ed" + i + "s" + k, slc.N_Ed); dict.Set("M_Edy" + i + "s" + k, slc.M_Edy); dict.Set("M_Edz" + i + "s" + k, slc.M_Edz); } dict.Set("LoadCaseName" + i + "s" + k, loadCase.Name); switch (loadCase.Ls) { case LimitState.Ultimate: dict.Set("LimitState" + i + "s" + k, 0); break; case LimitState.Service_CH: dict.Set("LimitState" + i + "s" + k, 1); break; case LimitState.Service_FR: dict.Set("LimitState" + i + "s" + k, 2); break; case LimitState.Service_QP: dict.Set("LimitState" + i + "s" + k, 3); break; default: break; } k++; } i++; } if (CurrentBeam != null) { dict.Set("currentBeamId", CurrentBeam.Id); } else { dict.Set("currentBeamId", -1); } archive.WriteDictionary(dict); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { /// input / output parameters List <Mesh> meshes = new List <Mesh>(); List <String> names = new List <String>(); string filepath = ""; string O = ""; ///import data if (!DA.GetDataList("Meshes", meshes)) { return; } if (!DA.GetDataList("Names", names)) { return; } if (!DA.GetData("File path", ref filepath)) { return; } //if (!DA.GetDataList("Guid", GH_guids)) return; /// PROCESS information /// 0. merge meshes if necessary /// 1. create obj write options // PROBLEM: mesh doesn't have any colors/names/guids ///define local parameters //var doc = Rhino.RhinoDoc.ActiveDoc; var R_meshes = meshes; var R_names = names; var joinedmesh = new Mesh(); var mesh = R_meshes[0]; mesh.GetObjectData(); MeshObject meshObject = new MeshObject(); meshObject.Name = R_names[i]; ///0. if (R_meshes.Count > 1) { for (int i = 0; i < R_meshes.Count; i++) { if (R_names != null) { R_meshes[i].SetUserString(Name, R_names[i]); } joinedmesh.Append(R_meshes[i]); } } else { joinedmesh = R_meshes[0]; if (R_names != null) { R_meshes[0].SetUserString(Name, R_names[0]); } } ///1. var file_options = new FileWriteOptions(); file_options.WriteUserData = true; var obj_options = new FileObjWriteOptions(file_options); obj_options.ExportNormals = true; obj_options.ExportMaterialDefinitions = true; obj_options.ExportTcs = true; obj_options.ExportObjectNames = FileObjWriteOptions.ObjObjectNames.ObjectAsObject; var wfr = FileObj.Write(filepath, new Mesh[] { joinedmesh }, obj_options); if (wfr.ToString() == "Success") { O = filepath; } else { O = "Failed"; } //ouput DA.SetDataList(0, O); }
/// <summary> /// Called when Rhino is saving a .3dm file to allow the plug-in to save document user data. /// </summary> protected override void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, FileWriteOptions options) { // Write the version of our document data archive.Write3dmChunkVersion(MAJOR, MINOR); // Write the string table StringDocumentDataTable.WriteDocument(archive); // Write the simple table SimpleDocumentDataTable.WriteDocument(archive); // Write the dictionary archive.WriteDictionary(Dictionary); }
/// <summary> /// Called whenever a Rhino is about to save a .3dm file. If you want to save // plug-in document data when a model is saved in a version 5 .3dm file, then // you must override this function to return true and you must override WriteDocument(). /// </summary> protected override bool ShouldCallWriteDocument(FileWriteOptions options) { return(!options.WriteGeometryOnly && !options.WriteSelectedObjectsOnly); }
protected override WriteFileResult WriteFile(string filename, int index, RhinoDoc doc, FileWriteOptions options) { bool binary = GlTFUtils.IsFileGltfBinary(filename); ExportOptionsDialog optionsDlg = new ExportOptionsDialog(); if (optionsDlg.ShowModal() != Eto.Forms.DialogResult.Ok) { return(WriteFileResult.Cancel); } glTFExportOptions exportOptions = glTFBinExporterPlugin.GetSavedOptions(); IEnumerable <Rhino.DocObjects.RhinoObject> objects = GetObjectsToExport(doc, options); if (!GlTFExporterCommand.DoExport(filename, exportOptions, binary, objects, doc.RenderSettings.LinearWorkflow)) { return(WriteFileResult.Failure); } return(WriteFileResult.Success); }
protected override bool ShouldCallWriteDocument(FileWriteOptions options) => true;
protected override bool ShouldCallWriteDocument(FileWriteOptions options) { return(true); }
protected override WriteFileResult WriteFile(string filename, int index, RhinoDoc doc, FileWriteOptions options) { bool binary = GlTFUtils.IsFileGltfBinary(filename); glTFExportOptions gltfOptions = new glTFExportOptions(); gltfOptions.UseBinary = binary; ExportOptionsDialog optionsDlg = new ExportOptionsDialog(gltfOptions); if (optionsDlg.ShowModal() == null) { return(WriteFileResult.Cancel); } IEnumerable <Rhino.DocObjects.RhinoObject> objects = GetObjectsToExport(doc, options); GlTFExporterCommand.DoExport(filename, gltfOptions, objects, doc.RenderSettings.LinearWorkflow); return(WriteFileResult.Success); }
/// <summary> /// Called when Rhino is saving a .3dm file to allow the plug-in to save document user data. /// </summary> public void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, FileWriteOptions options) { archive.Write3dmChunkVersion(MAJOR, MINOR); archive.WriteStringArray(m_strings); }
protected override void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, FileWriteOptions options) { archive.WriteDouble(GableRoofCommand.DefaultHeight); }
/// <summary> /// Called when Rhino is saving a .3dm file to allow the plug-in to save document user data. /// </summary> protected override void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, FileWriteOptions options) { SampleCsStringTable string_table = SampleCsStringTable.Instance; string_table.WriteDocument(doc, archive, options); }
protected override WriteFileResult WriteFile(string filename, int index, RhinoDoc doc, FileWriteOptions options) { try { var filter = new ObjectEnumeratorSettings(); if (options.WriteSelectedObjectsOnly) { filter.SelectedObjectsFilter = options.WriteSelectedObjectsOnly; } var objs = doc.Objects.FindByFilter(filter); var model = new Model(); model.Add(objs); using (var writer = new StreamWriter(filename)) model.Save(writer); return(WriteFileResult.Success); } catch (Exception ex) when(!System.Diagnostics.Debugger.IsAttached) { Dialogs.ShowMessage(ex.Message, "Error", ShowMessageButton.OK, ShowMessageIcon.Error); return(WriteFileResult.Failure); } }
private IEnumerable <Rhino.DocObjects.RhinoObject> GetObjectsToExport(RhinoDoc doc, FileWriteOptions options) { if (options.WriteSelectedObjectsOnly) { return(doc.Objects.GetSelectedObjects(false, false)); } else { return(doc.Objects); } }
/// <summary> /// Called when Rhino is saving a .3dm file to allow the plug-in to save document user data. /// </summary> protected override void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, FileWriteOptions options) { archive.Write3dmChunkVersion(MAJOR, MINOR); SampleCsStringTable string_table = SampleCsStringTable.Instance; string_table.WriteDocument(doc, archive, options); }
protected override void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, FileWriteOptions options) { if (Core.Instance?.ActiveDocument != null && !options.WriteSelectedObjectsOnly) { byte[] data = Core.Instance.ActiveDocument.ToBinary(); if (data != null) { archive.Write3dmChunkVersion(0, 1); archive.WriteByteArray(data); if (archive.WriteErrorOccured) { Core.PrintLine("ERROR: Writing Salamander model to Rhino .3dm failed!"); } else { Core.PrintLine("Salamander model data written to .3dm."); } } } base.WriteDocument(doc, archive, options); }
/// <summary> /// Called whenever a Rhino is about to save a .3dm file. If you want to save // plug-in document data when a model is saved in a version 5 .3dm file, then // you must override this function to return true and you must override WriteDocument(). /// </summary> protected override bool ShouldCallWriteDocument(FileWriteOptions options) { SampleCsStringTable string_table = SampleCsStringTable.Instance; return(string_table.ShouldCallWriteDocument(options)); }
protected override void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, FileWriteOptions options) { var dict = new Rhino.Collections.ArchivableDictionary(1, "RigiBodyData"); //If user save during animation, save the shapes at the time when start was pressed if (!TimePanel.Instance.Restarted || TimePanel.Instance.TrackbarValue != 0) { List <RigidBody> copyToAdd = new List <RigidBody>();; for (int i = 0; i < RigidBodyManager.World.RigidBodies.Count; i++) { copyToAdd.Add(RigidBodyManager.DuplicateRigidBody(RigidBodyManager.FramesRigidBodies[0][i], RigidBodyManager.FramesRigidBodies[0][i].IsStatic)); } dict.Set("rigidBodies", RigidBodyManager.ObjectToByteArray(copyToAdd)); } else { dict.Set("rigidBodies", RigidBodyManager.ObjectToByteArray(RigidBodyManager.RigidBodies)); } dict.Set("guidList", RigidBodyManager.ObjectToByteArray(RigidBodyManager.GuidList)); dict.Set("geometryList", RigidBodyManager.ObjectToByteArray(RigidBodyManager.GeometryList)); dict.Set("MaxFrameBoxValue", (int)TimePanel.Instance.MaxFrameBoxValue); dict.Set("worldCount", RigidBodyManager.World.RigidBodies.Count); archive.WriteDictionary(dict); }
/// <summary> /// Called when Rhino is saving a .3dm file to allow the plug-in to save document user data. /// </summary> protected override void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, FileWriteOptions options) { archive.Write3dmChunkVersion(MAJOR, MINOR); archive.WriteDictionary(m_dictionary); }