Overlapping Objects 
Author Message
 Overlapping Objects

Does anyone have a code snippet that, given two objects, will tell if one is
overlapping the other?

Thanks,
Rob Hutchison



Mon, 19 Jan 2004 20:03:59 GMT  
 Overlapping Objects
Try the HitTest example at www.magma.ca/~lancucki/Visio_VBA_Information.htm

John...    Visio MVP

Need stencils or ideas? http://www.magma.ca/~lancucki/Visio3rdparty.htm
Need VBA examples?   http://www.magma.ca/~lancucki/Visio_VBA_Information.htm


Quote:
> Does anyone have a code snippet that, given two objects, will tell if one
is
> overlapping the other?

> Thanks,
> Rob Hutchison



Tue, 20 Jan 2004 03:41:18 GMT  
 Overlapping Objects



Quote:
> Try the HitTest example at

www.magma.ca/~lancucki/Visio_VBA_Information.htm
Wouldnt Shape.BoundingBox be more elegant and faster? Or doesnt BoundingBox
work?

Stefan

Quote:
> John...    Visio MVP

> Need stencils or ideas? http://www.magma.ca/~lancucki/Visio3rdparty.htm
> Need VBA examples?

http://www.magma.ca/~lancucki/Visio_VBA_Information.htm


Tue, 20 Jan 2004 15:19:31 GMT  
 Overlapping Objects
Actually, I worked on it last night, using BoundingBox...

Here is what I got; seems to work correctly.
-----------------------------------------------------------------
Private Function IsOverlapping(Shape1 As IVShape, Shape2 As IVShape) As
Boolean

    Dim Left1 As Double
    Dim Left2 As Double
    Dim Bottom1 As Double
    Dim Bottom2 As Double
    Dim Right1 As Double
    Dim Right2 As Double
    Dim Top1 As Double
    Dim Top2 As Double

    Shape1.BoundingBox flags + visBBoxExtents, Left1, Bottom1, Right1, Top1
    Shape2.BoundingBox flags + visBBoxExtents, Left2, Bottom2, Right2, Top2

    If ((Left2 >= Left1 And Left2 <= Right1) Or _
        (Right2 >= Left1 And Right2 <= Right1)) And _
        ((Top2 >= Bottom1 And Top2 <= Top1) Or _
        (Bottom2 >= Bottom1 And Bottom2 <= Top1)) Then
        IsOverlapping = True
    Else
        IsOverlapping = False
    End If

End Function
--------------------------------------------------------------------------


Quote:



> > Try the HitTest example at
> www.magma.ca/~lancucki/Visio_VBA_Information.htm

> Wouldnt Shape.BoundingBox be more elegant and faster? Or doesnt
BoundingBox
> work?

> Stefan

> > John...    Visio MVP

> > Need stencils or ideas? http://www.magma.ca/~lancucki/Visio3rdparty.htm
> > Need VBA examples?
> http://www.magma.ca/~lancucki/Visio_VBA_Information.htm



Tue, 20 Jan 2004 19:58:20 GMT  
 Overlapping Objects
Robert:

From V2000 and later, you probably are best served in this area by the
Shape.SpatialXxx
properties, which can tell you about overlapping and find neighbors
directly.
These are based on geometry rather than bounding box. (Note that
bounding box
only coincides with the visible geometry for rectangle shapes.)

If you absolutely have to use bounding box, then the method described
elsewhere
in this thread looks pretty reasonable.

Graham

Quote:

> Does anyone have a code snippet that, given two objects, will tell if one is
> overlapping the other?

> Thanks,
> Rob Hutchison

--
--------------------------------------------
Graham Wideman
MS MVP for Visio
Books:
Visio 2000 Developer's Survival Guide
Visio 2002 Developer's Survival Pack (with Tools)
... and resources for programmable diagramming at:
http://www.diagramantics.com
--------------------------------------------
Unoffical Visio FAQ:
http://www.diagramantics.com/diagenvs/visio/faq/index.htm

(Remove the obvious to email me)
---------------------------------------------


Wed, 21 Jan 2004 05:25:20 GMT  
 Overlapping Objects
Use the Shape.SpatialNeighbor function.
Quote:
>-----Original Message-----
>Does anyone have a code snippet that, given two objects,
will tell if one is
>overlapping the other?

>Thanks,
>Rob Hutchison

>.



Mon, 26 Jan 2004 00:26:10 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. determining if time values from two records overlap

2. overlapping properties

3. Overlapping appointments in PF Calendar

4. overlapping appointment-items

5. Highlighting overlapping task bars.

6. Overlapping Shapes

7. Shapes overlapping!

8. Preventing overlapping shapes

9. Footer overlapping

10. Text in grouped, overlapping text boxes does not print

11. combo overlap

12. listview command bar overlap problem

 

 
Powered by phpBB® Forum Software