When exporting a 3dm file from rhinocommon (ghpython); and loading that with ThreeJS 3dm loader. the brep objects don’t have a “mesh” attribute.
If I open this file in Rhino and save again. They would have the mesh for preview in threeJS.
My guess is that the objects don’t have a “Preview” mesh by default. Is there a way to add that to the attributes?
here is my code:
# create new rhino file
rh_file = Rhino.FileIO.File3dm()
# add layers
part_layer_index = rh_file.AllLayers.AddLayer("part", part_color)
# add objects to layer
attributes = Rhino.DocObjects.ObjectAttributes()
# add breps
attributes.LayerIndex = part_layer_index
for part in parts:
If you are creating objects programmatically, they won’t have render meshes by default. You need to call https://developer.rhino3d.com/api/rhinocommon/rhino.docobjects.rhinoobject/createmeshes to generate these before you export. Notice this is on a
BrepObject, so you need to add the
Brep to the doc first then get the
BrepObject and run
CreateMeshes on it.
yes! thank you. sorry i did not see that.
alternatively, for loading to ThreeJS, I could convert the brep object to a mesh and then save the file with mesh objects.
mesh_part = Rhino.Geometry.Mesh.CreateFromBrep(part, meshingParameters)
rh_file.Objects.AddMesh(mesh_part , attributes)
Yes, as long as you put meshes in the file, you can visualize them with three.js