Matt__W 发表于 2009-2-3 16:19:38

使用正交获得2个点

您好,有没有办法使用ThisDrawing.Utility。GetPoint强制用户选择两个形成水平或垂直矢量的点 就像你画一条线的时候正交
谢谢
&nbsp
 

Matt__W 发表于 2009-2-3 16:38:13

是和否。这都是我脑子里想不出来的,所以它不是'这不是真的,但应该让人明白这个想法
sub test()
dim dblPtOne(0 to 2) as double
dim dblPtTwo(0 to 2) as double
dim dblX as double
dim dblY as double
dblptone = thisdrawing.utility.getpoint(,"First point")
dblpttwo = thisdrawing.utility.getpoint(,"Second point")
dblx = dblptone(0) - dblpttwo(0)
if dblx < 0 then
dblx = dblx*-1
end if
dbly = dblptone(1) - dblpttwo(1)
if dbly < 0 then
dbly = dblx*-1
end if
if dblx < dbly then
dblpttwo(0) = dblptone(0)
else
dblpttwo(1) = dblptone(1)
end if
end sub

Swift 发表于 2009-2-3 16:45:02

快速搜索发现(见下文)&gt&燃气轮机;此处(&lt)&lt&nbsp&nbsp;它使用GRDRAW创建橡皮筋效果&nbsp;你所要做的就是在运行这个和*presto*之前打开正交模式&nbsp;可以水平或垂直选择点
Sub grdraw_test()
    Dim pt1, pt2
    Dim VL As Object
    Dim VLF As Object
    Dim VLO As Object
    Dim drawList As String
   
    Set VL = GetInterfaceObject("VL.Application.16") 'or .16 for 2004+
    Set VLF = VL.ActiveDocument.Functions
   
    On Error GoTo Resume_here 'this is just a quick way of handling an "enter to end the point selection process. A more robust handler shoud be used
   
    pt1 = ThisDrawing.Utility.GetPoint(, vbCr & "Start point: ")
    pt2 = ThisDrawing.Utility.GetPoint(pt1, vbCr & "Next point: ")
    drawList = "(grdraw " & pt_list(pt1) & " " & pt_list(pt2) & " 7)"
    Set VLO = VLF.Item("read").funcall(drawList)
    VLF.Item("eval").funcall VLO
    pt1 = pt2
   
Resume_here:
    'do stuff for leader
    Set VLO = VLF.Item("read").funcall("(redraw)")
    VLF.Item("eval").funcall VLO
End Sub
Private Function pt_list(pt) As String
    Dim newStr As String
    newStr = "'(" & pt(0) & " " & pt(1) & ")"
    pt_list = newStr
End Function

Bryco 发表于 2009-2-3 16:46:00

酷炫

Bryco 发表于 2009-2-3 16:46:58


嫉妒的小婊子

Swift 发表于 2009-2-3 16:47:13

除了鲍勃&#039;s代码,可以设置#039;正交#039;在例行程序中也打开,然后在退出时重置状态。

Bryco 发表于 2009-2-3 18:46:58

设置实用程序的位32。初始化输入:
ThisDrawing.Utility.InitializeUserInput 32
p2=ThisDrawing.Utility.GetPoint (p1,"Second point:")
~&039;J#039~

Matt__W 发表于 2009-2-4 18:26:48

太棒了
谢谢大家

Matt__W 发表于 2009-2-5 18:58:34

我错过什么了吗?我看到的做任何工作(除了错误陷阱)的代码只有两行&nbsp;pt1=ThisDrawing.Utility。GetPoint(,vbCr“起点:”)
&nbsp;pt2=ThisDrawing.Utility。GetPoint(pt1,vbCr“下一点:”)
我看不到口齿不清在这里做什么;

Swift 发表于 2009-2-5 21:18:08

哦,天哪,如果克里看到了。
页: [1]
查看完整版本: 使用正交获得2个点