C# Visio形状-获取X、Y位置

C# Visio形状-获取X、Y位置,c#,visio,C#,Visio,我已使用以下代码以编程方式将形状插入Visio: ActiveWindow.Page.Drop(VisioApp.Documents["ORGCH_M.VSS"].Masters.ItemU["Executive"], 5.433071, 7.559055); 插入形状后,如何通过编程检索其X、Y坐标 谢谢 要获取新形状的坐标,请首先获取新形状的引用。将重新运行此引用。然后在该形状对象中查找其形状和单元格。这将为您提供以Visio默认单位(即英寸)表示的坐标。以下是VBA中的一个示例: Dim

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

ActiveWindow.Page.Drop(VisioApp.Documents["ORGCH_M.VSS"].Masters.ItemU["Executive"], 5.433071, 7.559055);
插入形状后,如何通过编程检索其X、Y坐标


谢谢

要获取新形状的坐标,请首先获取新形状的引用。将重新运行此引用。然后在该形状对象中查找其形状和单元格。这将为您提供以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")
我注意到您正在使用公制图形,即在文件名中。你可能更喜欢在不同的单位工作。以下是使用毫米的相同示例:

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)