I am not sure that the second one smooths with the same settings. After a first trial i got similar times as @Holo but once i’ve entered the values manually using _Smooth, there was only a small difference between runtimes. Still the Rhino command seems to be twice as fast.
Thanks for testing, I don’t fully understand what you mean, because -smooth should remember it’s settings. That’s why I made a mesh box first and sat the values there, and then ran it with out setting the settings again on the real mesh. Did you find something else than that, that made it run only twice as fast?
I noticed that. On my first run i got values like these:
Then when i did start the _Smooth command after running your example, i saw that the Steps value was still set at 30. Once i changed it to 1000 and smoothed your part (without running the script part which changes the option values) i got the results:
so it got only faster using the _Smooth command but not the Python part.
Hi Demifish, thanks for the info, fun to see the Centroidal version.
But this is about why the command version is faster than the scripted version running Rhino Common. I have a tool that I would like to smooth a mesh x times as fast as possible, that’s all
Hi Clement, I use the -_Smooth version first to set the variables, but a bug got in there I think.
Please try this on the file:
import rhinoscriptsyntax as rs
import scriptcontext as sc
SmoothNr = 1000
mesh_id = rs.GetObject("mesh to smooth",rs.filter.mesh,preselect=True)
mesh = rs.coercemesh(mesh_id)
coordinateSystem = Rhino.Geometry.SmoothingCoordinateSystem(2)
plane = Rhino.Geometry.Plane.WorldXY
for i in range(SmoothNr):
mesh.Smooth(1,True,True,True,True, coordinateSystem, plane)
### Setting up smooth with out taking time
rs.Command("_MeshBox 0 1 1 1 Enter SelLast")
rs.UnselectObject(newMesh) ### the newMesh is selected by the SelLast command, so I unselect it first
rs.Command("_-Smooth SmoothFactor=1 CoordinateSystem=World X=Yes Y=Yes Z=Yes FixBoundaries=Yes Steps="+str(SmoothNr)+" Enter",False)
rs.Command("_Delete",False) ### Deleting the smoothed dummy mesh
### Running the Rhino command to compare times
### Now select the smoothed mesh and see that there are two similar meshes, one from each test
I see that if the SmoothNr is low then the script is faster, but if it is high like 1000 then the Rhino command is faster. And I want it faaaaast ((without using the command and messing up users settings))
Anyway, a quick peek at the code teaches me that using the Smooth() method on the mesh creates and deletes 1000 times a mesh, which is going to be much slower than the _-Smooth command since it doesn’t do that.