Hi all,
I’m encountering a problem while writing a Mesh from rhinodocument to file.
I’m using the following code to get objects from document:
int layerIndex = RhinoDoc.ActiveDoc.Layers.FindByFullPath($"_{side}::_{objectType}", -1);
List<RhinoObject> rhinoObjects = rhinoDoc.Objects.FindByLayer(rhinoDoc.Layers[layerIndex]).Where(r => r.Geometry is T).ToList();
return rhinoObjects;
Select 1 of the objects with:
if (rhinoObjects != null)
{
insoles[i].InsoleMesh = rhinoObjects[0].Geometry as Mesh;
}
And write with:
FileWriteOptions fileWriteOptions = new FileWriteOptions();
FileObjWriteOptions options = new FileObjWriteOptions(fileWriteOptions);
string filename = $"{insole.Side}.obj";
string filePath = Path.Combine(destinationPath, filename);
Mesh[] objTOWrite = new Mesh[1];
objTOWrite[0] = insole.InsoleMesh;
FileObj.Write(filePath, objTOWrite, options);
//check if file is ready
IOMethods.CheckIfFileIsInUse(filePath);
errorMessage = string.Empty;
At The FileObj.Write part I’m getting the following error:
Stacktrace: (Not sure if that is interesting)
Name | Value | Type | |
---|---|---|---|
StackTrace | " at Rhino.FileIO.FileObjWriter.SetMeshTextureCoordinates(RhinoDoc doc, Mesh mesh, ObjectAttributes attributes, Transform exportTransform, Boolean bSkipWcsOcs, Boolean bApplyTextureTransforms, Boolean bIgnoreDisabledChannels)\r\n at Rhino.FileIO.FileObjWriter.WriteMeshesToFile(Mesh meshes, ObjectAttributes attribs, FileObjWriteOptions options)\r\n at Rhino.FileIO.FileObjWriter.WriteFile(StreamWriter file, Mesh meshes, FileObjWriteOptions options)\r\n at Rhino.FileIO.FileObjWriter.WriteFile(String filename, Mesh meshes, FileObjWriteOptions options)\r\n at Rhino.FileIO.FileObj.Write(String filename, Mesh meshes, FileObjWriteOptions options)\r\n at PLTInsoleR8.PS2DFunctions.ExportAsObj(Insole insole, String destinationPath, String& errorMessage) in C:\Users\r.weenink\source\repos\PLTInsoleR8\PLTInsoleR8\PS2DFunctions\PS2DFunctions.cs:line 203" | string |
I’ve checked the Mesh and this is a valid mesh with vertices and faces etc.
The filepath is being created I’ve checked this as well.
This exact piece of code worked in Rhino 7.
Please help me out. I’m out of my depth.
Kind regards Reinder