Miter shapes/joints for intersecting solids/polysurfaces?

Hi all,

I’m a relative newbie with scripting (and Rhino too), not sure if I’m asking a too simple or complicated question (sorry)… But I’m stuck and haven’t found anything helpful.

I’m creating a sort of “wall generator” script which uses rs.AddBox to create the wall, then rs.ExplosePolysurface, then assigns different materials for the 6 surfaces (exterior, interior, etc). Then the six surfaces are grouped together as a “Wall-[number]”.

I want the script to be able to check all the walls that have been created and if they are intersecting to create miter “joints” (the shape, not an actual joined surface) at the overlapping corners.

Is there some commands or procedure I could use? I’ve explored 2-3 ideas but they are incredibly ugly and messy. For example, I could go through an array of “Walls”, use rs.EnableObjectGrips, go through the array of surfaces, then the array of points, then compare every point against every other of every other surface/wall and then move the grip point accordingly… There must be less ugly and complicated ways than this, aren’t they?

Thanks in advance!