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:
import Rhino
# 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:
rh_file.Objects.AddBrep(part, attributes)
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.