Visio中的形状 - 获得X,Y位置 [英] Visio shape - get X,Y position
问题描述
我已经成功地使用下面的代码编程中插入形状到Visio:
I've managed to programatically insert a shape into Visio using the code below:
ActiveWindow.Page.Drop(VisioApp.Documents["ORGCH_M.VSS"].Masters.ItemU["Executive"], 5.433071, 7.559055);
我将如何编程检索它的X,形状已经被插入后Y坐标?
How would i programatically retrieve it's X,Y coordinates after the shape has been inserted?
谢谢!
推荐答案
要获得新形状的坐标首先得到一个参考到新的形状。 Page.Drop 将retun这个参考。然后看看在形状对象为其品克斯和松香细胞。这会给你的坐标在Visio中的默认单位即英寸。下面是在VBA的例子:
To get the coordinates of the new shape first get a reference to the new shape. Page.Drop will retun this reference. Then look in that shape object for its PinX and PinY cells. This will give you the coordinates in Visio's default units i.e. inches. Here is an example in 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中的文件名)。你可能更喜欢在不同的单位上班。下面是使用毫米相同的例子:
I notice you are working in a metric drawing (i.e. _M in the filename). You may prefer to work in a different unit. Here is the same example using millimeters:
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)
这篇关于Visio中的形状 - 获得X,Y位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!