Join the vertices of two different meshes?

I have two different meshes and i want to join all vertices at the intersection line. Is this possible?


mesh join.3dm (401.2 KB) Mesh join.gh (33.3 KB)

1 Like

The two surfaces don’t share a common edge so the meshes won’t either. If they did, you could join the two surfaces into a single Brep before converting it to a mesh.

I notice the geometry is 282070.073 millimeters across.
If you use appropriate units (here meters is probably best), you can join the surfaces into a single Brep before converting to a mesh like Joseph says, and then the mesh will be connected.

I rebuilt the smaller surface using part of the adjacent edge of the larger surface, replacing the end control points of two edges. I dropped the mesh Settings because it was distorting the mesh so it didn’t match the surface(s) accurately.


Mesh_join_2020Aug31a.gh (39.3 KB)

This works really good but since i have many surfaces i have to add surfaces one by one.

is there some specific tolerance for which it would be possible to join the surfaces? In this case I have to use millimetres but i can scale down and then scale up in the end.

In Rhino you can use the JoinEdge command to join surfaces which can’t be combined simply with the Join command, and it will tell you the tolerance that needs to be used.
However, I don’t believe there’s any equivalent to JoinEdge in Grasshopper.

You can change the tolerance in the Rhino settings (Tools>Options>Units>Model>Absolute tolerance) though, and then Brep Join will work in Grasshopper. For your model 0.2 seems to be enough.

I’m curious though - what kind of project is this that has objects 100s of meters across that need to be modelled in mm?

To automate this in gh, you can try the MeshVertexList.Align method which I think does a similar (or the same) thing as JoinEdge as Daniel mentions: https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Collections_MeshVertexList_Align.htm

Just out of interest, I tried to implement it on your mesh using a quick script. I also used a couple of Daniel’s K2 components to refine one of the meshes, and it seems to work ok with a slider for tolerance. The vertices of the lower mesh are then aligned to the upper mesh**. If you wish, you can choose the particular vertices you want to align using this method, but setting an appropriate tolerance works fine in this instance and only a few lines of code.

Anyway, maybe overkill but fun to investigate:

MeshAlignScript.gh (530.0 KB)
(includes a weaverbird component to weld and join coincident vertices after shifting).

John.

(** doing it the other way around might negate the corner chamfering at the top right of this image)

Actually, the other way round is much cleaner:

MeshAlignScript2.gh (529.5 KB)

5 Likes

This is absolutely perfect.
I have only one problem …If i have to connect one mesh in two sides then i have to do it like this:


The problem is that “t” of the second component affects also the first one … in this case the side with t=450 becomes t=1293

In general, is it possible to connect to the closest node within a distance “t”. It is strange that it takes the furthest distance:
image

Another possible approach with meshes is to use the script I posted here for inserting vertices into an existing mesh, and add all of the touching boundary points of each mesh to the other:
stitch_edges.gh (754.6 KB)


This can produce some very thin triangles where the points are almost but not quite coincident, so you might want to also run AlignVertices with a tolerance on the result.

2 Likes

Hi @drilonshabani,

It’s basically the extension I described that you need to choose the particular vertices to align each time, otherwise it will use all of them and mess up your first bit of good work! This is tricky as you need a boolean pattern for each mesh you put into the Align method - but it then does it’s thing. You can’t really force one mesh to stay put and the other adapt it seems (this is also my first time using this part of the api, learning something here!), but you can choose the points used for each run of the C# component.

I’ve adapted this now to take a boolean pattern of vertex indices to be used. Now the next tricky thing though: which points to select? Well, you can find the points on each mesh that are next to each other within a max distance. Initial filtering to the boundary vertices of the two adjacent meshes drastically cuts the calculation time. I wrapped something into a cluster that does this; then you can just run the C# mesh align thing twice, each time with different vertices.

The example attached includes three simple meshes adjoined similar to your problem. Hope you can adapt this workflow, it might be that using Daniel’s script first might help for your particular case as he rightly mentions.

MeshAlignScript3.gh (37.1 KB)

Best of luck with it,

John.

2 Likes