Not sure what changed in Rhino recently, but joining meshes became super slow and seriously gets in the way of our workflow where this is something we have to do very often.
Joining 100K+ pieces together in V5 or earlier versions of V6 is really just a blink of an eye fast, and now in latest V6 Rhino freezes for a good minute.
Please see attached sample file to compare, if you have access to V5 or earlier V6 builds… Hope this can get fixed!
EDIT: working with Version 6 SR16
(6.16.19150.22171, 5/30/2019)
Thanks Tim- I believe here there is mostly no Ngons… But are you saying that if there are Ngons, the code will be very slow and there is no way around it?
@tim - in 6.4 the if the option in Join is set not to join disjoint meshes, it is extra slow, but not as slow as 6.16 in my test - it does finish. ~4 minutes plus, here.
I’d say SR13 and before for sure (well, it used to be slow again for a while due to poor handling of legacy materials, but @johnc made fixes for that…) So for a while it was good, but this slowness is quite recent, but not ‘just happened’. Sorry I can’t be more precise. It definitely worked in V6 well for a long time (since we switched to V6 last year).
Most of the work we do has to do with models that are orginally imported from other software (SKP, Revit) and Rhino is used to clean them up and built upon that/detail them further etc. These most often come imported as meshes, and very heavy scenes. Disorganized. Messy. Sometimes super slow since meshes don’t come joined. In order to be able to operate on these, we would use various combinations of join/splitdisjointmesh/extract mesh faces/ etc. Back and forth - since Rhino works super fast on big joined meshes. So we heavily rely on this being fast.
@pascal - I just saw your note - 6.10 might have been pre-JohnC fix. We switched to Rhino 6 around SR9 and helped to iron out a couple of issues, slow mesh joining was one of them, but it was due to some weird material buildup… I would say 6.11 to 6.13 was OK?
@Jarek - this quick and dirty script will join a bunch of meshes without all the bother of the Join command.
import scriptcontext
import Rhino
def FastJoinMesh():
# Pick some meshes
go = Rhino.Input.Custom.GetObject()
go.SetCommandPrompt("Select meshes to join")
go.GeometryFilter = Rhino.DocObjects.ObjectType.Mesh
go.GetMultiple(1, 0)
if go.CommandResult() != Rhino.Commands.Result.Success:
return
# Make a list of mesh geometry
meshes = []
for objref in go.Objects():
meshes.append(objref.Mesh())
# Join 'em up
new_mesh = Rhino.Geometry.Mesh()
new_mesh.Append(meshes)
# Add new mesh to doc
scriptcontext.doc.Objects.Add(new_mesh)
# Delete the selected meshes
for objref in go.Objects():
scriptcontext.doc.Objects.Delete(objref.ObjectId, False)
FastJoinMesh()
@Jarek - the Join command can probably be a faster for your case. Code was added to Join to deal with disjoint meshes (e.g. the JoinDisjointMeshes=No/Yes command line option). This is where the root of the slowness comes from. I think @tim has a few idea on how to speed this up a bit.
I can also make a quick tune up to RhinoScript too.
I did not see that… 90% of the time we would need it on YES (that’s how it is right now). The slowdown is noticeable only on 20,000+ meshes (I know this sounds crazy, but try importing architects files from SKP or Revit - one bush that comes as separate faces could be 100,000+…). Rhino deals exceptionally well with these heavy files to make them usable or workable, but we heavily rely on the mesh joining being fast. Looking forward to what @tim can cook up. Thank you for helping with making this better !
The _Join with meshes is back to being quite fast in the latest build. @Tim, thank you for the fix! (@Dale, this affects the RhinoScript JoinMesh which also works well now).
I’m having trouble with a script that helps me to simplify some sketchup files that we get from time to time in the office.
Hundreds of thousands of individual meshes that I want to join per layer.
I saw the script above which should be faster than the normal join command and I would like it to automatically join all the meshes for each layer.
this is the script snippet I am starting from:
def JoinByLayer() :
layer_list = rs.LayerIds()
rs.EnableRedraw(False)
for layer_id in layer_list:
rs.UnselectAllObjects()
rs.ObjectsByLayer(layer_id,True)
objs=rs.SelectedObjects()
if objs and len(objs)>1: rs.Command("_Join")
What I would like is a way to join a large number of single meshes in the fastest way possible, hypothetically even 1 million single meshes per layer.
Hmm, that shouldn’t happen. I don’t know if it’s trying to delete something that doesn’t exist anymore or if somehow the joined mesh became invalid and returned an unset GUID (00000000-0000-0000-0000-000000000000) I would have to have something to test with.
OK, that points to the mesh being returned by the rs.JoinMeshes() method as being invalid somehow… I have to go out now, but I can try to test with something later…