Join Mesh by Touching a certain color

How can I make a mesh join another mesh if its touching a certain color?

basic principle: If black mesh is touching red mesh, join.

You might start with a simple command macro. For example:

_Hide _Enter
_SelColor _RGB 0 0 0

You would have to check for intersections and then check for color.
What are you trying to achieve?

Im trying to make the meshes that touch the red mesh to join with the red mesh, but stay separate from the rest.

Example below.

Ok, this should be simple… but meshmeshintersection does not register two meshes that are touching as intersecting.

This script works if the meshes pass through each other only:

import rhinoscriptsyntax as rs

objects=rs.GetObjects("Select objects for touch calculation")

#divide objects into two lists

objectsRed = []
objectsNotRed = []

for obj in objects:
    if rs.IsMesh(obj):
        if rs.ObjectLayer(obj) == redLayer:
print len(objectsRed)
print len(objectsNotRed)

#check if there are any objects in the lists
if len(objectsRed)>0:
    if len(objectsNotRed)>0:
        for objRed in objectsRed:
            for objNotRed in objectsNotRed:
                 intersect= rs.MeshMeshIntersection(objRed,objNotRed)
                 print intersect
                 if intersect:
            if len(rs.SelectedObjects())>1:
                rs.ObjectLayer(joined[0], redLayer)

I didn’t annotate it or clean it up since it didn’t work properly.
In this case I think the right approach would now be to duplicate the mesh outlines and then check for intersections between those. The approach in the above script can be used for that as well, you just need to rewrite it with the proper commands of course :wink:

Good luck!