I am looking at creating arrays of thousands of identical objects, my idea is to force the render mesh on the first object before arraying it so the render mesh is copied along with the object (otherwise afterwards it has to mesh them all).
Currently I just show the first object in a shaded Rhino viewport which creates the render mesh for the object, then I cut the redraw and do my array. But it would be nice to avoid this and if it happens that the active viewport has a wireframe display mode, the first mesh won’t be created anyway.
I’m not actually finding that this works - it still says "“Creating meshes” when the script terminates and I can’t see a time difference with my attempt at creating the initial box with meshes programmatically with CreateMeshes before arraying or just letting Rhino shade the whole batch after.
Hi Mitch, it’s hard to say without example. Is the object you array already in the doc when you use CreateMeshes on it ? If this is the case, which mesh parameters to you pass to it ?
Yes - CreateMeshes wants a Rhino object - so one that has already been added to the document - I don’t know if one can or how to add meshes to a brep object that has not been added to the document yet.
I used the Default meshing parameters, and I assume it is the Render mesh type that is needed. However, now that I think about it - if I have an object that has been meshed with the default mesh parameters and the document has custom mesh settings, does that mean that Rhino will re-mesh it again at script’s end because the parameters are different?
I can try looking into that tomorrow, too late here now.
OK, below seems to work if the object has been added to the doc, i add the meshing to the rhino object and then commit the changes before i redraw. If you run below in wireframe mode then switch to shaded it will not show “Create meshes…”:
actually i used Mesh.CreateFromBrep as my geometry was not part of the document. Then i assigned the meshes to each brep face using BrepFace.SetMesh before i displayed it in the conduit…
_
c.
OK, thanks, the difference was I had not gotten the document’s mesh settings; I also didn’t have the CommitChanges line. I’m not sure if CommitChanges() is completely necessary? If I comment it out, the “Creating Meshes…” message still does not appear on the command line.
Anyway, thanks for the help!
Edit - funny thing is that if I go back the original method - showing the first box so that it meshes, cutting the redraw and then doing my array, it’s actually faster. To do 8000 boxes, it only took 2.55 seconds to do it that way, while it took 3.65 seconds creating the mesh via RhinoCommon (without showing the first box) and then arraying it. Weird.