【问题标题】:Visio shape - get X,Y positionVisio 形状 - 获取 X、Y 位置
【发布时间】:2010-09-20 23:38:09
【问题描述】:

我已设法使用以下代码以编程方式将形状插入 Visio:

ActiveWindow.Page.Drop(VisioApp.Documents["ORGCH_M.VSS"].Masters.ItemU["Executive"], 5.433071, 7.559055);

插入形状后如何以编程方式检索它的 X、Y 坐标?

谢谢!

【问题讨论】:

    标签: c# visio


    【解决方案1】:

    要获得新形状的坐标,首先要获得对新形状的引用。 Page.Drop 将重新调整此引用。然后在该形状对象中查找其PinX 和PinY 单元格。这将为您提供 Visio 的默认单位(即英寸)的坐标。这是 VBA 中的一个示例:

    Dim newShape As Visio.Shape
    Dim x As Double
    Dim y As Double
    
    Set newShape = ActiveWindow.Page.Drop(Visio.Application.Documents("ORGCH_M.VSS")
                        .Masters.ItemU("Executive"), 5.433071, 7.559055)
    
    x = newShape.Cells("PinX")
    y = newShape.Cells("PinY")
    

    我注意到您正在使用公制图纸(即文件名中的 _M)。您可能更喜欢在不同的单位工作。这是使用毫米的相同示例:

    Dim newShape As Visio.Shape
    Dim xIn As Double
    Dim yIn As Double
    Dim xOut As Double
    Dim yOut As Double
    
    xIn = Visio.Application.ConvertResult(100, visMillimeters, visInches)
    yIn = Visio.Application.ConvertResult(120, visMillimeters, visInches)
    
    Set newShape = ActiveWindow.Page.Drop(Visio.Application.Documents("ORGCH_M.VSS")
                        .Masters.ItemU("Executive"), xIn, yIn)
    
    xOut = newShape.Cells("PinX").Result(visMillimeters)
    yOut = newShape.Cells("PinY").Result(visMillimeters)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-15
      • 1970-01-01
      • 2022-08-02
      • 2023-01-25
      • 1970-01-01
      • 2019-02-02
      • 1970-01-01
      • 2019-02-19
      相关资源
      最近更新 更多