Hi,
Your code works if rectangle is near on the right of the circle. But position of Both are random. it's possible that rectangle is far to the bottom left of circle.
If you want to understand my project, I have a map and place locations on this symbolise by circle. Each location got a label symbolize by the rectangle. Both are placed by user in a other application and I place it in the word. I can place Both of them but i want to bound location and label by line. So consider locations and labels are random positions.
Regards