Joining Meshes became super slow in recent V6 builds : (

Hi @Pascal,

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)

thank you,

–Jarek

Join_Mesh_Test_100K.zip (9.8 MB)

@tim, can you look at this?

Yep, a minute in 6.16… a second or so in V5.

I added https://mcneel.myjetbrains.com/youtrack/issue/RH-53066, currently for Tim. Checking on 6.15…

-Pascal

1 Like

This happened as a result of the fix for https://mcneel.myjetbrains.com/youtrack/issue/RH-52761. I can check for ngons prior to the join and call the old code if there aren’t any.

Tim

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?

PS. Hope V6 still can get this fixed : )

–jarek

@Jarek - do you recall what Rhino 6 SR was “fast?” We don’t believe the fix made by @tim is the cause of the slowness.

Also, what is the purpose of the massive disjoint mesh?

– Dale

Slow in 6.10…
Slow in 6.4…

@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.

-Pascal

hi @dale,

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?

thanks,

–jarek

@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()

– Dale

Nice, thanks. Why can’t the join command be as fast :slight_smile: Or have some options like “I_don’t_care_about_Ngons_Only_Speed” ?

I tried RhinoScript:

    	Dim m : m = Rhino.GetObjects()
    	Call Rhino.JoinMeshes(m, True)

but it is as slow as the command. Unfortunately we have bunch of in house tools relying on the RhinoScript version : /

–j

@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.

– Dale

That would be great…

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 !

–jarek

2 Likes

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).

–jarek

This issue (Rhino.JoinMeshes is slow RH-53070) is fixed in the latest Service Release Candidate

1 Like

Hey @dale

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.

Can you help me with this?

Thanks in advance!

I have this - don’t know if it’s any faster…
JoinMeshesByLayer.py (612 Bytes)

Thanks man, looks faster but I get an error after a while:

Message: 00000000-0000-0000-0000-000000000000 does not exist in ObjectTable

So I guess I should somehow purge or skip the missing ids from the object table.

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.

Does this work any better?
JoinMeshesByLayerT1.py (766 Bytes)

Same error, really weird.
Do you have any other idea, so the error points to this line:

rs.ObjectLayer(joined,layer)

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…

1 Like