containing shape detection

S

staaan

Hello,

how can you detect the shape that contains the current one?
I´m using Visual C# .Net and the following problem appeared recently:

I have a model that contains shapes on which other shapes are placed.
These shapes are not grouped or connected using a oneD connector.
If I move one shape the other (included) shapes move with it.
So how can I detect the Parent shape for a given one?

I just tried out fields like ContainingShape, ContainingMaster,
ContainingPage, Connects (because I read that glued shapes are
associated through connectors), ... but nothing works!


Another Question is if there is a method which is able to determine
whether one shape is part of another using the shapes corrdinates.


Please help!
Thanks!
 
J

John Goldsmith \(Visio MVP\)

Hello Staaan,

It depends on how the shapes relate to each other. You say that they aren't
connected using 1D connectors, but are they glued shape to shape using
static glue or is it that one shape's PinX/Y is reliant on another using a
formula (eg PinX =Sheet.1!PinX+20 mm)?

If they are glued, then you could read which shapes your target shape is
glued to, or which shapes are glued to it (remember that glue always has a
direction). In this situation the Connects property of your target shape
will return a collection of Connect objects that connect to other shapes and
the target shape's FromConnects property will return a collection of Connect
objects that other shapes are connected to. Once you have your collection
of Connect objects you can iterate through them and their respective
FromSheet and ToSheet properties to get hold of the other shapes.

Take a look at this link for further reading:

http://msdn.microsoft.com/en-us/library/aa201774(office.10).aspx

If it's just a formula relationship then you could read the Dependents
property of your target shape's PinX and PinY cells. This will return an
array of cells that are dependent on that cell/s and you can get hold of the
shape object via Cell.Shape. Look up the Dependents property of the Cell
object in help.

Regarding your last question, do you mean overlap? If that's the case you
might want to have a look at the SpatialNeighbors property and or HitTest
method of the Shape object.

Also, if you're after some C# code then have a look at the SDK over here:

http://www.microsoft.com/downloads/...B8-5EF7-4E6E-A582-C8D6B5EE4E33&displaylang=en

Hope that helps.

Best regards

John


John Goldsmith (Visio MVP)
www.visualSignals.typepad.co.uk
www.visualSignals.co.uk
 
S

staaan

Hello John,

I´m pretty new in Visio development, but I finally found the way the
shapes were connected. The connection was realised using formulas in the
shapesheets.

Regarding to my second question, I now have the choice between different
approaches:
First, I can use the HitTest-Property for testing several points of the
inner shape and determine wheter it is fully included or not.
Second, I can use the TransformXYTo-Method for transforming the
coordinates of the inner shape to those of the outer shape and test
wheter the shape is included.

Both works really fine. (I didn´t test the SpatialNeighbors-Method yet)

But there is also another problem:
Upper description works on simple shapes but I have to determine the
containment f.e. on shapes of the stencil "cross-functional vertical
flowchart" (I don´t know how it´s called in english, sorry). There the
coordinates of the vertical band often are not included in the
coordinates of the underlying vertical holder though the vertical band
lies exactly in the holder.
-> both are connectet through formulas
There the containment-relation can´t be detected (even by using a small
tolerance)

Do you have any ideas?
 

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