How to determine shape locations on page?

B

Bradford

I need to determine if any shapes lay outside the bounds of the drawing page before executing pageObj.ResizeToFitContents() so that I only resize when the drawing is larger than the page.

What is the best way to go about this using VB and Visio 2002 Enterprise Architect
 
M

Markus Breugst

Each shape has a PinX, PinY, Width and Height cell, and each page has a
PageWidth and PageHeight cell. The coordinate origin (0, 0) is at the left
bottom corner of a page. The (0, 0) point of a shape is usually its middle
(i. e. Width/2, Height/2).

With this information, you can iterate through all shapes and check if any
of them lies outside the page borders.

Hope this helps.

Best regards,
Markus

Bradford said:
I need to determine if any shapes lay outside the bounds of the drawing
page before executing pageObj.ResizeToFitContents() so that I only resize
when the drawing is larger than the page.
 
M

Mark Nelson [MS]

Use the ResultIU method on the Cell object. This is also the default method
on this object, so some VB programmers will omit the method name.
 
C

Chris Roth

The pin methods suggested won't work if a shape is, for instance, on the
border of the page. The pin might be greater than zero, but the shape might
be "half in the blue."

You might also draw a temporary rectangle that matches the page's size and
location.

Then try the spatial relation methods, such as shape.SpatialRelation to see
which shapes are outside of the page.

General method:

1. Draw a rectangle that matches the page
2. Select all shapes and save a reference to this selection ("Sel")
3. Remove the rectangle from Sel
4. Get a selection object of shapes inside of the rectangle: SelContained =
Rect.SpatialRelation( visSpatialContainedIn, ..., ...)
5. Remove ( Sel.Select(shp, visDeselect) ) each shape in SelContained from
Sel
6. All the remaining shapes in Sel are not on the page at all.

--
Hope this helps,

Chris Roth
Visio MVP



Bradford said:
I need to determine if any shapes lay outside the bounds of the drawing
page before executing pageObj.ResizeToFitContents() so that I only resize
when the drawing is larger than the page.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top