Author Topic: How to determine shape underneath another shape  (Read 389 times)

0 Members and 1 Guest are viewing this topic.

doone

  • Jr. Member
  • **
  • Posts: 12
How to determine shape underneath another shape
« on: May 25, 2018, 10:58:54 AM »
Hi Everyone,

I'm interested to know if it is possible to determine what, if any, shapes are underneath another specific shape on a page.  So, for example, let's say I place a line (sheet.1) on the page and then I place a circle (sheet.2) on top of the line.  Is there a formula that I can put in the shapesheet of the circle to get the name of the line underneath?

Something similar was asked in this post http://visguy.com/vgforum/index.php?topic=1119.msg4867#msg4867.  Paul suggested using SpatialSearch method, but that would be a vba solution.  I'm trying to avoid code and just use the shapesheet.

Kind Regards,
Lorna

vojo

  • Hero Member
  • *****
  • Posts: 1137
Re: How to determine shape underneath another shape
« Reply #1 on: May 25, 2018, 10:20:37 PM »
there is a docmd (google it) that allows you to take selected shape and move it to back or front.  No VBA
could use some action cells to do that

or can do manually

Another_Noone

  • Jr. Member
  • **
  • Posts: 50
Re: How to determine shape underneath another shape
« Reply #2 on: July 27, 2018, 06:44:28 AM »
Just sharing a weird idea: How about checking for x/y coordinates of the other shape...

This wont work for 2 random shapes, but for soecific shapes wich you previously created it might.
Another_Noone

Just some weirdo on the Interwebs.

vojo

  • Hero Member
  • *****
  • Posts: 1137
Re: How to determine shape underneath another shape
« Reply #3 on: July 27, 2018, 08:05:00 AM »
novice approach

- select the line (either .1 or .2)
- color it (say red)
- send to back
- deselect (select something else)
- select the line (still be black)
- color it (say blue)
- now you can tell visually who is on top

If you don't want to change colors then up shape sheet and look for .1 vs .2....rest of the steps same

Journey approach
- put each line on a different layer
- turn layers on and off for specific shapes

Yacine

  • Hero Member
  • *****
  • Posts: 2482
Re: How to determine shape underneath another shape
« Reply #4 on: July 28, 2018, 03:04:23 AM »
Actually the answer is: No, there's no shapesheet solution for finding overlapping shapes.
VBA is the way to go.

There could probably be a way where each shape registers its coordinates in a central place (eg the shapesheet of the page) and a clever formula would then check if two coordinates are close to each other. But this would require that each shape is prepared to send this information to the page. This is certainly not what you're looking for.
Yacine

vojo

  • Hero Member
  • *****
  • Posts: 1137
Re: How to determine shape underneath another shape
« Reply #5 on: July 28, 2018, 06:26:39 PM »
well...not quite true

you can do this

Action cell =   setf(getref(action.checked), if (action.checked,0,1))

user cell = if (action.checked, docmd(1046),)    Brings to front
or
user cell = if (action.checked, docmd(1048),)    sends it to the back

Basically, thru action cells, you can move the shape to front or send to back

Docmd has a lot of power....probably 200 commands in there.   My favorite is docmd(1312) which opens shape properties

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3279
  • Ideas Visio-lized into solutions
Re: How to determine shape underneath another shape
« Reply #6 on: July 28, 2018, 09:19:25 PM »
Both Yacine and Go no are arguably correct.

There is no shape sheet function that is equivalent to vba spatial neighborhood that will give you the identity of shapes beneath a given shape.  Even Vojo's approach won't do that.

But, using Vojo's technique, it is possible to change the z-order of shapes and thus reveal by user observation if a shape might have been hidden by another.  This approach requires setting up each shape to have the described actions.  That alone is a lot of work. 

I believe using code is truly the most efficient and satisfying approach.  But, if code is out of the question, then, Vojo's approach is an alternative to consider.

Wapperdude
Visio 2007 Std

vojo

  • Hero Member
  • *****
  • Posts: 1137
Re: How to determine shape underneath another shape
« Reply #7 on: July 29, 2018, 12:05:03 PM »
wapperdude....fair enough...I thought he wanted to see if underneath...not do something algorithmically

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3279
  • Ideas Visio-lized into solutions
Re: How to determine shape underneath another shape
« Reply #8 on: July 30, 2018, 09:15:16 AM »
@Vojo:  intent wasn't clear...besides, providing options is a good thing.

3rd possible option...assumes this is for newly dropped shapes, you can set Page properties to move existing shapes out of the way when new shape is dropped.  Doesn't help for existing over-played shapes, or even intentionally over-laying to hide a shape.

Wapperdude
Visio 2007 Std