I'm looking for a macro that can detect distance between objects. Is there one that can do that? I want to be able to give a value and then have the script search and find any objects that are closer to each other than the value specified. Thanks
Joseph
I think this will do it then ...
Dim ss As Shapes minimum_gap = 0.05 'value in inches, change as required Set ss = ActiveLayer.Shapes For i = 1 To ss.Count 'do every shape found If ss(i).Type = cdrEllipseShape Then For j = i + 1 To ss.Count 'compare it with every shape we haven't yet done If ss(j).Type = cdrEllipseShape Then distance_x = ss(j).CenterX - ss(i).CenterX distance_y = ss(j).CenterY - ss(i).CenterY distance = Sqr((distance_x * distance_x) + (distance_y * distance_y)) End If radius_i = ss(i).CenterX - ss(i).LeftX + ss(i).Outline.Width / 2 radius_j = ss(j).CenterX - ss(j).LeftX + ss(j).Outline.Width / 2 gap = distance - radius_i - radius_j If gap < minimum_gap Then ss(j).Fill.UniformColor.CMYKAssign 0, 100, 100, 0 End If Next j End If Next i
As currently written, it assumes all circles are on the active layer, so you can have other objects in the document without them being considered. It also presumes all the objects are circles
Cool, I'll give it a try. So the concept here is to set the distance within the code and "select" the objects I want to check, correct?