got a suggestion from wolfgang
1 .you should not be able to move the block inside the jaws if jaws the jars are too close together.
2. I select either internal or external measurement with a check box and would hide the internal object if external is selected and hide the external if internal is selected.

my reflection:
need time to think how to do it :)
having some difficulty thinking about the interaction modeling

if (    ox>=(x2+x-w/2)&&(oy>oymin-h/2)&&(w>x)) { // >= is important not == does not work well // recently added w>x still cannot get the interaction of suggestion1
 x = ox -x2 +w/2; // to make object and jaw right move together when touched