Check if a shape is within another shape

Started by Serg, July 09, 2015, 02:50:24 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Serg

Hi all,

I'm stuck and bashing my head against a wall for a few weeks. Here is my issue. My WPF app reads from a Visio and based on that creates an object of facility which has a containment and tanks within the containment. The problem is I can't say if tanks are within a containment or not cause theoretically they can be outside of containment. Also it can be a few containments in one facility so I need to know what containment tanks belong. Sorry if it still not clear. Let me know if I need to clarify something. I also attached my Visio file.

Thank you in advance!

wapperdude

Let me see if I have this correct.  You want to determine if the physical location of the tank is within the containment, which would be different that determining if the tank is a sub-member of the containment, or do you need both?

For example, you have a warehouse, and within this warehouse of movable containment areas, could be a lockable chain link region for storing, say, tanks of helium.  You want to know if (a) the containment region is within the warehouse, and (b) if the helium tanks are within the containment region.  That is, when the drawing was made, was everything placed within the correct boundaries?  Second related question:  are the drawing locations determined by the actual, physical location?  That is, is the drawing supposed to tell you if the actual physical entity has been incorrectly located?

Wapperdude
Visio 2019 Pro

Serg

Thanks for the reply wapperdude!

Yes, I want to determine if the physical location of the tank shape is within the containment. Next step I guess would be to assign the containment name to shape data property of the tank shape so it can be read from WPF app. A containment is always within a facility but tanks are either within the containment or facility.
Yes, the drawing was made within a correct boundaries and determined by the actual, physical location.
No, there is no need to tell if the actual physical entity has been incorrectly located.

I need to be able to determine in my WPF(c#) app if a tank shape belongs to a containment or facility and since the application loops through a shape cells I need a cell corresponding with containment name and if it's null I'd assume it is outside of containment area.

Here is my logic:
1. User drops a tank shape on the drawing
2. Visio determines what is the location of the tank shape.
3. If the tank shape is within a containment shape then assign the tank shape data property with containment name value.

Please let me know if it still not clear. Thank you!

wapperdude

I think that's clear.  I only have V2007, I'll defer an answer to users with V2013 as there may be more sophisticated methods available with the newer version.

Visio 2019 Pro

Serg


Yacine

Hi Serg,
I played with the idea of containers and linked 2 containers to the geometry of the "L" containment.
In the tank shape I added a cell =CONTAINERCOUNT(), which I used to color the shape.
I leave it up to you add an "ungroup" command to the on drop event in the shapesheet.
I enclose the example.
Yacine

Serg

Thank you for your reply Yacine!

Yes, now I can tell if a tank shape is within a containment area however it can be a few containments for example containment A and containment B. That's why I need to know if it's possible that the tank shape (if within a containment) would read the containment name and assign in to some cell. If I can do this means my WPF app will be able to distinguish where the tank shape belongs(outside of containments or Containment A or Containment B etc).

Yacine

Yacine

Serg

I don't know if someone needs it but I found a way to check if shape is located within another shape. I simply used a shape location coordinates and also its width and length.

Nikolay

If you just want to know (programmatically) if one shape is contained within another, Visio has a built-in method to help you: shape.SpacialRelation
This also work for non-rectangular shapes.