Extracting difference in height at interface of two solids

Hello,
I am trying to develop a script for the following problem.

This is a small example model which I created to explain the task. The blue solids can be assumed to be the nodes of grid shell structure and the green solids are beams. As shown in case 1, the beam face is within the bounds of the node face. But in the other cases the beam face is either above or below the bounds. I have hundreds of such nodes in a model and no two nodes have the same inclination. I want to write a script which can extract the distance by which the beam is outside the node bounds using a separate coordinate system for each node in the model (something like a Gumball in Rhinoceros). It would be great if someone can share an approach on how to implement this in Grasshopper.
Regards,
Markus

What’s the difference between case 2 and case 3?

No principle difference. Just that the beam in case 2 is more outside the upper (horizontal) node bound when compared to case 3.

But now that I gave it a thought, it could be a case where the beam is outside the side (vertical) node bounds.

And for that matter what’s the difference between (2,3) and (4), just the upside/down difference as compared to the world Z-axis?

The upside or downside difference using the local coordinate system of each node and not the world z-axis.

I guess you have a plane that represent this? Because the shapes look fully symmetric along the up-down axis.

Yes a plane would do. The third coordinate is not required for symmetric cases.