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
Actually I may have needlessly complicated things by suggesting IsOnShape as there's the wonderful SelectShapesAtPoint function. I'm including an example in the name of showing different approaches:
Sub AreShapesClose() Dim S As Shape Dim Gap As Double Gap = ActiveDocument.ToUnits(20, cdrMillimeter) 'Set the gap around around our circular shape - in mm in this case For Each S In ActiveLayer.Shapes 'Iterate through all the shapes in our active layer If ActivePage.SelectShapesAtPoint(S.CenterX, S.CenterY, True, S.SizeWidth / 2 + Gap).Shapes.Count > 1 Then 'If it has selected more shapes than the current shape in a circle around it then those other shapes are within 'our radius - let's mark them ActiveSelection.Shapes.All.ApplyUniformFill CreateCMYKColor(0, 100, 100, 0) End If Next S End Sub
Using this will mark all the shapes that are within the given distance (Gap) of another shape
I did not test it, but I think all of these scripts would already include duplicate objects, which are just a special case of overlapping. But if the script only marks one of the pair of objects there is a 50/50 chance of it marking the object behind, which means it would not be seen. A quick fix for that would be to mark one of the objects in red and the other in blue, so that whichever is in front, one of them will always be seen.
Good point. If it's directly overlapping, you'd never see it. I guess you could also. move the object to the top and then color it as well....or make the object on top red. I think that would be better.