Visio VBA 函数查看形状前面/后面是否有形状

发布于 2024-07-05 17:35:44 字数 143 浏览 5 评论 0原文

Visio VBA 有没有办法查看 Visio 中形状前面或后面是否有形状?

我想我可以写一些东西来检查页面中每个形状的边界框,看看它是否与我的形状占据相同的空间。 我宁愿使用内置的东西,因为随着绘图的形状越来越多,检查每个形状可能需要很长时间。

Is there a way in Visio VBA to see if there is a shape in front of or behind a shape in Visio?

I imagine I could write something that checks the bounding box of each shape in a page to see if it occupies the same space as my shape.
I'd rather use something built-in since checking each shape could take a long time as a drawing gets more and more shapes.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

予囚 2024-07-12 17:35:44

Shape.SpatialRelation 属性将告诉您两个形状是否接触。 Shape.Index 属性将告诉您哪个在 z 顺序中位于前面或后面。

这是一个简单的示例:

Public Sub DoShapesIntersect(ByRef shape1 As Visio.Shape, ByRef shape2 As Visio.Shape)

    '// do they touch?
    If (shape1.SpatialRelation(shape2, 0, 0) <> 0) Then

        '// they touch, which one is in front?
        If (shape1.Index > shape2.Index) Then
            Debug.Print shape1.Name + " is in front of " + shape2.Name
        Else
            Debug.Print shape1.Name + " is behind " + shape2.Name
        End If
    Else
        Debug.Print "shape1 and shape2 do not touch"
    End If

End Sub

请在此处阅读更多信息:

MSDN 上的 Shape.SpatialRelation 属性

The Shape.SpatialRelation property will tell you if two shapes touch. The Shape.Index property will tell you which is in front or behind in the z-order.

Here is a simple example:

Public Sub DoShapesIntersect(ByRef shape1 As Visio.Shape, ByRef shape2 As Visio.Shape)

    '// do they touch?
    If (shape1.SpatialRelation(shape2, 0, 0) <> 0) Then

        '// they touch, which one is in front?
        If (shape1.Index > shape2.Index) Then
            Debug.Print shape1.Name + " is in front of " + shape2.Name
        Else
            Debug.Print shape1.Name + " is behind " + shape2.Name
        End If
    Else
        Debug.Print "shape1 and shape2 do not touch"
    End If

End Sub

Read more here:

Shape.SpatialRelation Property on MSDN

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文