@jasond240 Actually I gave this problem a lot of thought and made some progress with a solution.
The essence of the challenge is to determine the angle of box2 (cyan box) as box1 rotates. The end of box2 should follow a circular path. The problem is that there is an inflection point where the continued rotation of box1 in a CW direction yields a solution where box2 can go in a CW or CCW direction.
To help me explore how to compute the angle of box2 I created a point A (PtA) that should be located at one of the two intersections of two circles. One of the circles is located at the pivot of box2 (yellow circle) and the and the other is centered at your point D (pink circle). I used a numerical approach (trial and error) to determine the appropriate intersection. In the code below, Po is an initial guess for the intersection point. It lies on the yellow circle. Pn on the pink circle at the intersection of a line from Po to the center of the pink circle. It is closer to one of the two true intersections of the two circles than Po. Pm is on the yellow circle and is at an intersection of a line from Pm to the center of the yellow circle. The calculation of Pm and Pn is in a while loop which continues recalculating Pm and Pn until the distance between Pm and Pn is less than 0.01 (an arbitrary error value). I placed a limit of 10 iterations on the loop to protect against the case when the two circles do not intersect. The process converges very quickly to a solution. The initial guess for Po determines which of the two circle intersection points will be calculated. My code needs some work to better choose the initial guess.
Slowly rotate box1 or box2 in the attached file (I have not tied the rotation of box2 to PtA) and you will see PtA move with the intersection point of the two circles. WARNING! The code will crash Max if the two circles do not intersect. My plan was to use PtA to determine the angle of rotation for box2. But at what point should the arm hyper-extend? My code jumps PtA to the other solution when box2 pivot is on the line from the pivot of box 1 to the center of the pink circle. This needs to be addressed.
Play around with my file and you may gain some more insight into the problem and a potential solution.

Script for PtA.
alpha = rotation of box1, beta = rotation of box2, P1 = pivot of box1. 8 = radius of yellow circle, cirRad = radius of pink circle.
beta = alpha + betaLoc
P1= box1+[dum1.x*cos(alpha),dum1.x*sin(alpha),0]
Po = [8.0*cos(beta),8*sin(beta),0] + P1
cont = 1
Pn = cirPos + cirRad/length(Po-cirPos)*(Po - cirPos)
while cont > 0 do
(
Po = Pn
Pm = P1 + 8/length(Pn-P1)*(Pn-P1)
Pn = cirPos + cirRad/length(Pm-cirPos)*(Pm - cirPos)
if cont > 10 then cont = 0
if length(Pm-Pn) < 0.01 then cont = 0
) -- end while
Pm
Script for PtA.
lee.minardi