The documentation says it is present in the Rhino.FileIO namespace of the RhinoCommon.dll for NET Framework. However it appears that the DracoCompression class is not yet included in the Rhino3dm.dll even though it is available in the Javascript implementation here.
Are there plans to include this class?
Is there a workaround in the meantime?
do you know if there currently is there a workaround for this? I mean is there currently any way of decompressing a rhino draco mesh in a C# project that it run outside of rhino? I’m writing a plugin for revit where I’d need the functionality but i cannot find it in rhino.inside revit either.
Draco should be something we support in rhino3dm net, since we already support it in rhino3dm.js. I will look at why we are not packaging draco with rhino3dm net.
thank you both. The example you provided was really useful @dale, big thanks for taking the time to post it here. The problem with that solution for me is that I need it to work on machines that doesn’t nessesarily have rhino installed, but I still think it’s really neat and I’m sure there are other cases where it is a good solution.
@fraguada that would be amazing! I have another solution in my head as well that is a bit more complicated. Do you think this is something that will be implemented in say the next 6-12 months or is it further away than that? Just so I know if I should do my workaround instead.
It might something we can do within 6 months. I’ll investigate after we get a rhino3dm version based on 8.0 out.
Will update as I find out what we need to do to support it in .net.
I really appreciate it. I’m writing a revit add-in where I want to take a draco compressed rhino mesh stored in a database and convert it to a revit mass model. Do you have any other suggestions on how to decompress the mesh? I know there is the draco decompression library but it is written i cpp and I’m not sure if that works with compressed rhino meshes. Is it better to wait or do you have any suggestions on workarounds here? Could also be an idea to write the endpoint in js and return the decompressed mesh but it’s not as neat as doing it client-side.
Hi @erikforsberg95 , in case its of any value to you, this was our workaround for converting rhino Brep[ ] arrays from Compute to a single mesh that could be sent to our desktop clients as a byte array. It seems to be reasonably performant:
public static byte[] BrepsToMeshJsonBytes(Brep[] breps)
{
var result = new Mesh();
foreach (Brep brep in breps)
{
var meshes = MeshCompute.CreateFromBrep(brep, MeshingParameters.FastRenderMesh);
foreach (var mesh in meshes)
{
result.Append(mesh);
}
}
result.Compact();
var json = result.ToJSON(new SerializationOptions() { RhinoVersion = 7, WriteUserData = false });
return Encoding.ASCII.GetBytes(json);
}
Would also be keen to know of a better workaround as well.
Feeling like I’m just keeping to push this thread but I still have a few questions so I’m continuing here. I’ve managed to re-write the endpoint that returns the mesh so the format is an encoded rhino mesh instead of a draco string. I can easily create a Rhino.Geometry.Mesh from this by calling
var rhinoMesh = JsonConvert.DeserializeObject<Rhino.Geometry.Mesh>(serializedMeshString);
with rhino3dmIO in my project. However this is just kicking the can because to use RhinoInside.Revit to get access to the MeshEncoder.ToMesh() method, I’ll still need to have RhinoCommon in my project, right?
So now my question is, is there a way of converting a Rhino.Geometry.Mesh to a revit geometry locally (not using compute) without having rhino installed on the machine? Would it be a crazy idea to rewrite just the parts of RhinoInside.Revit that I need using rhino3dm instead of RhinoCommon for example? Or is there an intermediate format like .obj that I could use to convert in two steps?
In theory, if you have the Revit API, you should be able to get away with just using rhino3dm for converting Rhino meshes to Revit. With rhino3dm you get access to all of the mesh data you would get inside RhinoCommon. Maybe @kike can chime in here.
I also discovered this so I figured there should be a sneaky way of solving this, just like in you example @kike. Haven’t had time to test it yet but I read the code and it makes sense and probably works just fine for my case. You probably saved me a couple of hours banging my head so a big thank you for that!
I’ll update the thread with potential issues (if any) I find with your implementation for future reference.
@Erik - we had similar need (to convert client-side) and it wasn’t difficult - i’m off work this week but mon/tues will dig out and share what we did.
– EDIT –
just re-read your post. Well what we had was slightly diff:
For our web viewer (Threejs) our process was:
Server side \ Client side Rhino.Compute >> Rhino.Mesh >> OBJ (c#) >> Threejs mesh.
For our Civil3D geometry (native Solid3D classes rather than meshes) we did indeed rely on a 3rd party C++ routine and our process was as follows:
Server side \ Client side Rhino.Compute >> Export .SAT (Compute plugin, c#) >> Solid3D (3rd party C++ dll)
I don’t know the api/sdk for Revit but if it has options for importing or working with meshes and you don’t need smooth, NURBS solids then the OBJ option might be highly performant for you?
If you do require smooth native Revit classes then i think you might need something akin to our second process that we used for AutoCAD Civil3D.
thanks for that! Yes, I think the .obj option is a good way for us to move forward. I’ll test the simplified rhino → revit code first since that does not require us to add any new endpoints for us serverside, but if I have problems with that then .obj export is my next option.