Get absolute shape coordinates (shape is part of a group)

Started by ivan, August 18, 2010, 11:08:30 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ivan

there's a connection line. it has end and begin points. I need to find a shape of specific type (can be determined by name - like "shape_A.256" etc)) nearest to these points.
What i did: loop through all of page's shapes - filter the one's i need. then loop through all these shapes to find nearest to the connector begin point. simple math like
distance = ((x.Cells("pinX") - sh.Cells("beginX")) ^ 2 + (x.Cells("pinY") - sh.Cells("beginY")) ^ 2) ^ 0.5 where x is "shape_A" shape
the problem is that this shape "shape_A" can be part of a group. thus in it "pinX", "pinY" are relative coordinates. relative to group.shape coordinates. How can i get absolute coordinates ? it's like x.Cells("pinY") + x_group.Cells("pinY")  but how can i get if a shape is part of a group and get that parent shape ? how can i get absolute coordinates on the page ?



wapperdude

#1
Assume that sheet.1 represents the shape nested within a group, then, from the page perspective, the center of the shape can be determined as
     X-coordinate:  PNTX(LOCTOPAR(PNT(Sheet.1!PinX,Sheet.1!PinY),Sheet.3!Width,Width))
     Y-coordinate:  PNTY(LOCTOPAR(PNT(Sheet.1!PinX,Sheet.1!PinY),Sheet.3!Width,Width))

where sheet.3 is the group shape containing the sheet.1 shape.

HTH
Wapperdude
Visio 2019 Pro

Jumpy

And if in VBA
Shape.Parent
is ThePage, than it is not part of a group.
Otherwise it is.

ivan

thanks. it's solved for me this way
still tricky for me why there's no standart function to retrieve absolute position....