Description
ShapeBBox(SubShape, Param) will return, for the specified sub-shape, the bounding box (x1,y1,x2,y2) internal coordinate (so starting from 0,0) specified by "Param" (0=x1, 1=y1, 2=x2, 3=y2).
Syntax
object.ShapeBBox (iSubShapeIdx, iParamIdx) |
object
Required. Object name, returned by Dim elem as ElementProp = Page.SelElement()
iSubShapeIdx
Required. Ordinal number of the subshape, from 0 to NumShapes - 1
iParamIdx
Required. Ordinal number of the co-ordinate, from 0 to 3 (0=x1, 1=x2, 2=x2, 3=y2)
Examples
Dim elem as ElementProp = Page.SelElement()
for i=0 to elem.NumShapes-1
msgbox "X1:" & elem.ShapeBBox(i,0) & " Y1:" & elem.ShapeBBox(i,1) & " X2:" & elem.ShapeBBox(i,2) & " Y2:" & elem.ShapeBBox(i,3)
next
Finding out if an object is cut on top with text wrap
If an object is not cut on top, then its Y co-ordinate, returned by ShapeBBox(iSubShapeIdx,1) is equal to 0. Otherwise, the object is cut on top, and its new Y co-ordinate is Fred.GetSelectionY + ShapeBBox(iSubShapeIdx,1).
The following function finds the apparent y-pos of the multiple selected body frames, wrapped on top (e.g. by a headline frame). If the frames are not wrapped, it returns the real y-pos. If the frames have not the same real y-pos, e.g. one frame starts a bit below another, the script returns the maximum apparent y-pos, or the maximum real y-pos.
Public Overridable Function GetRaY() As Integer
'v1 on 02/Oct/2013 (BS): returns the apparent y-pos of frames wrapped by other objects, e.g. body frames wrapped on top by a headline frame
'this is to be used for all manipulations of body frames that are wrapped on top
Dim y, y1, ymax As Integer
ymax = 0
Dim elem As ElementProp = Page.SelElement()
Dim nElem = elem.NumShapes - 1
For t As Integer = 0 To nElem
y1 = elem.ShapeBBox(CShort(t), 1)
If y1 > 0 Then ' object wraps around something
y = elem.Y + y1 ' adjust y-pos
Else
y = elem.Y
End If
If y > ymax Then ymax = y
Next
Return ymax
End Function
See also