Hello,
I’m having issues while using the Mesh.Reduce(...) on any mesh (also a simple sphere).
The RhinoCommon version I am using is 7.20.22193.9001.
As an example, this is a python script reproducing the issue:
import sys
import rhinoscriptsyntax as rs
from Rhino import RhinoApp
from Rhino.Geometry import Mesh, ReduceMeshParameters
from exceptions import Exception
if __name__ == '__main__':
# Select a mesh before running this script.
obj = rs.SelectedObjects()[0]
mesh = rs.coercemesh(obj)
if mesh:
params = ReduceMeshParameters()
params.DesiredPolygonCount = 2000
params.Accuracy = 5
try:
# The following line ALWAYS throws a null reference exception
# inside RhinoCommon.
success = mesh.Reduce(params, threaded=True)
print("Reduced" if success else "Not reduced")
except Exception as e:
print("EXCEPTION: " + str(e))
else:
print("Mesh is null")
The method keeps crashing even if the DesiredPolygonCount and Accuracy values are lowered, or threaded argument is toggled.
Am I missing something?
Thank you
Hmm, I do see EXCEPTION: Object reference not set to an instance of an object when using the method passing ReduceMeshParameters.
On the other hand, something like this works:
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
mesh_id = rs.GetObject("Select mesh",32,preselect=True)
if mesh_id:
mesh = rs.coercemesh(mesh_id)
targ_count=2000
accuracy=5
success = mesh.Reduce(targ_count,True,accuracy,False,True)
if success:
sc.doc.Objects.Replace(mesh_id,mesh)
sc.doc.Views.Redraw()
else:
print "Unable to reduce mesh"
Thank you @Helvetosaur , that was fast!
I tried the Reduce(int, bool, int, bool, bool) version of the method, and it works for me as well.
Evidently the issue only affects the Reduce(ReduceMeshParameters, bool) version.
Cheers
@dale - maybe need to look at this?
Any update on this? I’m having the same error. And in my case I don’t want to set a specific polygon count so the Reduce(int, bool, int, bool, bool) wouldn’t work.
I’m trying to implement a prompt update that includes a percentage, but I’m not having any success.
progress: IProgress[float]
piac
(Giulio Piacentino)
August 6, 2026, 1:53pm
7
I reported RH-97579 for @DavidEranen to have a look.
This issue should be fixed already in Rhino 8 SR 27. Let me know if someone still has problems in Rhino 8 or later.
I made some additional fixes to Rhino 8 that will make things a bit more robust when calling Mesh.Reduce().
brian
(Brian Gillespie)
August 11, 2026, 11:08pm
9