Author Topic: Get 2 points using ortho  (Read 3611 times)

0 Members and 1 Guest are viewing this topic.

gabep

  • Guest
Get 2 points using ortho
« on: February 03, 2009, 04:19:38 PM »
Hello,

Is there a way to use ThisDrawing.Utility.GetPoint to force a user to pick 2 points that form a horizontal or a vertical vector ?  Like ortho does when you draw a line?

Thanks!
   
   

Bob Wahr

  • Guest
Re: Get 2 points using ortho
« Reply #1 on: February 03, 2009, 04:38:13 PM »
Yes and no.

This is all off the top of my head so it isn't real but should get the idea across.

Code: [Select]
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

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Get 2 points using ortho
« Reply #2 on: February 03, 2009, 04:45:02 PM »
A quick search revealed this (see below) found >>here<<.   It uses GRDRAW to create a rubber band effect.  All you would have to do is turn on ORTHOMODE prior to running this and *presto*!  You can select points horizontally or vertically.

Code: [Select]
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
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

Bob Wahr

  • Guest
Re: Get 2 points using ortho
« Reply #3 on: February 03, 2009, 04:46:00 PM »
Cool

effingshowoff

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Get 2 points using ortho
« Reply #4 on: February 03, 2009, 04:46:58 PM »
Cool

effingshowoff

Jealous little bitch!

 :roll: :wink:
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

Swift

  • Swamp Rat
  • Posts: 596
Re: Get 2 points using ortho
« Reply #5 on: February 03, 2009, 04:47:13 PM »
In addition to Bob's code, you could set 'ortho' on during the routine too and then reset the state on exit.

fixo

  • Guest
Re: Get 2 points using ortho
« Reply #6 on: February 03, 2009, 06:46:58 PM »
Hello,

Is there a way to use ThisDrawing.Utility.GetPoint to force a user to pick 2 points that form a horizontal or a vertical vector ?  Like ortho does when you draw a line?

Thanks!
   
set bit 32 for Utility.InitializeUserInput :
Code: [Select]
ThisDrawing.Utility.InitializeUserInput 32
p2=ThisDrawing.Utility.GetPoint (p1,"Second point:")

~'J'~

gabep

  • Guest
Re: Get 2 points using ortho
« Reply #7 on: February 04, 2009, 06:26:48 PM »
Great stuff!

Thanks guys!

:)

rogue

  • Guest
Re: Get 2 points using ortho
« Reply #8 on: February 05, 2009, 06:58:34 PM »
am I missing something? the only two lines of code I see doing any work (save for the error trap) are

   pt1 = ThisDrawing.Utility.GetPoint(, vbCr & "Start point: ")
   pt2 = ThisDrawing.Utility.GetPoint(pt1, vbCr & "Next point: ")

I dont see the lisp doing anything here ....  ???

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Get 2 points using ortho
« Reply #9 on: February 05, 2009, 09:18:08 PM »
Oh boy, if Kerry sees this. :evil: