none
How To Determine If a Shape is Outside a Given Broundry and remove it?

    Question

  • I am using VBA Code and looping through all of the shapes in my drawing to remove all shapes outside a given boundry.

    I am wondering is their a better method of removing all shapes outside a given boundry.  My boundry is given by the two opposite corner position and for each shape I check if its falls inside the boundry or outside.

    I takes a while to loop through all the shapes.

    Anyone with a better solution for me ?

    Thank You,

    G

    lundi 4 février 2013 21:50

Réponses

  • Hi,

    If you provide the boundry first, then add shapes to it, then maybe we can use a container boundary.

    Referring to the "Boundary Shapes" part in the following link:

    http://msdn.microsoft.com/en-us/library/ff959245.aspx

    If you want some code to do it, then maybe you'd better to post in the Microsoft Office for Developers:

    http://social.msdn.microsoft.com/Forums/en/category/officedev



    Jaynet Zhang
    TechNet Community Support

    mercredi 6 février 2013 08:01
    Modérateur
  • Hi G7,

    There are several ways to go about this.

    You can approximate using the Width, Height, PinX, PinY (and LocPinX, LocPinY) of all shapes involved to determine the location on the page of the left, right, top, bottom of every shape you analyze.

    An example:

    '// Calculate page-coordinate left and right for a shape:
    
    Dim dLeft as Double, dRight as Double
    
    dLeft = shp.CellsU("PinX").ResultIU - shp.CellsU("LocPinX").ResultIU
    
    dRight = dLeft + shp.CellsU("Width").ResultIU 

    This can be used for both "source" and "target" shapes. Ie: the one that defines the boundary and the ones you one to test.

    If your shapes aren't particularly rectangular, you can use the shp.BoundingBox(flags, l, b, r, t) method to get the left, bottom, right, top of a shape, according to particular flags and tolerances.

    You can also use shp.SpatialRelation( othershape, tolerance, flags) to compare two shapes. The results are tell you whether the shape is inside, touching or outside of the other shape. The results are constants that you can find in the VisSpatialRelationCodes enumeration. This is probably the most computationally intense, but if you have fewer than 50 or 100 shapes to test, it should be fine.



    Chris Roth Visio Guy (http://www.visguy.com)

    Get the book! Using Microsoft Visio 2010

    Please check Mark as Answered if I've answered your question and solved your problem. If you found my post helpful, please click Vote as Helpful.

    mercredi 6 février 2013 12:21

Toutes les réponses

  • Hi,

    If you provide the boundry first, then add shapes to it, then maybe we can use a container boundary.

    Referring to the "Boundary Shapes" part in the following link:

    http://msdn.microsoft.com/en-us/library/ff959245.aspx

    If you want some code to do it, then maybe you'd better to post in the Microsoft Office for Developers:

    http://social.msdn.microsoft.com/Forums/en/category/officedev



    Jaynet Zhang
    TechNet Community Support

    mercredi 6 février 2013 08:01
    Modérateur
  • Hi G7,

    There are several ways to go about this.

    You can approximate using the Width, Height, PinX, PinY (and LocPinX, LocPinY) of all shapes involved to determine the location on the page of the left, right, top, bottom of every shape you analyze.

    An example:

    '// Calculate page-coordinate left and right for a shape:
    
    Dim dLeft as Double, dRight as Double
    
    dLeft = shp.CellsU("PinX").ResultIU - shp.CellsU("LocPinX").ResultIU
    
    dRight = dLeft + shp.CellsU("Width").ResultIU 

    This can be used for both "source" and "target" shapes. Ie: the one that defines the boundary and the ones you one to test.

    If your shapes aren't particularly rectangular, you can use the shp.BoundingBox(flags, l, b, r, t) method to get the left, bottom, right, top of a shape, according to particular flags and tolerances.

    You can also use shp.SpatialRelation( othershape, tolerance, flags) to compare two shapes. The results are tell you whether the shape is inside, touching or outside of the other shape. The results are constants that you can find in the VisSpatialRelationCodes enumeration. This is probably the most computationally intense, but if you have fewer than 50 or 100 shapes to test, it should be fine.



    Chris Roth Visio Guy (http://www.visguy.com)

    Get the book! Using Microsoft Visio 2010

    Please check Mark as Answered if I've answered your question and solved your problem. If you found my post helpful, please click Vote as Helpful.

    mercredi 6 février 2013 12:21