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

标签 c# visio

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

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

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

谢谢!

最佳答案

要获取新形状的坐标,首先获取对新形状的引用。 Page.Drop将重新调整此引用。然后在该形状对象中查找其 PinXPinY细胞。这将为您提供 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)

关于c# - Visio 形状 - 获取 X、Y 位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3736712/

相关文章:

c# - 通过 knockout 显示 ajax 数据

c# - 如何以编程方式将 UAC 的 consent.exe 带到前台?

c# - Visio 中的形状连接器

python - 关于使用 Python 扩展对 Dia 进行编程有什么提示吗?

xml - 在 MS Visio 2010 中导入和导出 BPMN 2.0 XML

C#百分位排序算法

c# - 请求 .Form 返回 null

C# 堆栈溢出

visio - 将 .vsd 文件转换为 .vdx

visual-studio-2010 - 反正有从SQLite数据库生成数据库图的方法吗?