Author Topic: Please check your brain at the door  (Read 2195 times)

0 Members and 1 Guest are viewing this topic.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Please check your brain at the door
« on: April 12, 2007, 04:11:52 PM »
Im having a huge brain fart today.  We had a fatality at work today, and I cant seem to make my brain think about code.  If Im using Utility.GetPoint, how do I use a While or DoWhile to continue picking points til nil?

Code: [Select]
Private Sub cmdLayoutLines_Click()
      Me.Hide
      Dim intBusSpacing As Integer, strLayer As AcadLayer, objLine As AcadLine
      Set strLayer = ThisDrawing.Layers.Add("3d-Layout-Lines")
      strLayer.color = 173
      ThisDrawing.ActiveLayer = strLayer
      With ThisDrawing.Utility
            Dim pt1 As Variant, pt2 As Variant
            pt1 = .GetPoint(, "Pick Starting Point: ")
            pt2 = .GetPoint(pt1, "Pick Next Point: ")
            ThisDrawing.ModelSpace.AddLine pt1, pt2
            While pt2 <> Empty
                  pt1 = pt2
                  pt2 = .GetPoint(pt1, "Pick Next Point: ")
                  ThisDrawing.ModelSpace.AddLine pt1, pt2
            Wend
      End With
      Me.Show
End Sub
this is not working
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Please check your brain at the door
« Reply #1 on: April 12, 2007, 04:13:38 PM »
For some strange reason, after the first line is drawn, Intellisense tells me pt2=Empty, thus the check
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Please check your brain at the door
« Reply #2 on: April 12, 2007, 04:18:44 PM »
ok, Im making progress
Code: [Select]
Private Sub cmdLayoutLines_Click()
      Me.Hide
      Dim intBusSpacing As Integer, strLayer As AcadLayer, objLine As AcadLine
      Set strLayer = ThisDrawing.Layers.Add("3d-Layout-Lines")
      strLayer.color = 173
      ThisDrawing.ActiveLayer = strLayer
      With ThisDrawing.Utility
            Dim pt1 As Variant, pt2 As Variant
            pt1 = .GetPoint(, "Pick Starting Point: ")
            pt2 = .GetPoint(pt1, "Pick Next Point: ")
            ThisDrawing.ModelSpace.AddLine pt1, pt2
            While Not pt2(0)
                  pt1 = pt2
                  pt2 = .GetPoint(pt1, "Pick Next Point: ")
                  ThisDrawing.ModelSpace.AddLine pt1, pt2
            Wend
      End With
      Me.Show
End Sub
Now it keeps picking points, but crashes on Enter key
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Guest

  • Guest
Re: Please check your brain at the door
« Reply #3 on: April 12, 2007, 04:23:16 PM »
Im having a huge brain fart today.  We had a fatality at work today, and I cant seem to make my brain think about code.  If Im using Utility.GetPoint, how do I use a While or DoWhile to continue picking points til nil?

Whoa! Whoa! Whoa!  Back up.... a FATALITY??!?   :-o  Wha....??

Here's what I came up with..
Code: [Select]
Private Sub cmdLayoutLines_Click()
    Me.Hide
    Dim intBusSpacing As Integer, strLayer As AcadLayer, objLine As AcadLine
    Set strLayer = ThisDrawing.Layers.Add("3d-Layout-Lines")
    strLayer.color = 173
    ThisDrawing.ActiveLayer = strLayer
   
    On Error Resume Next
    Do
        With ThisDrawing.Utility
            Dim pt1 As Variant, pt2 As Variant
            pt1 = .GetPoint(, "Pick Starting Point: ")
            pt2 = .GetPoint(pt1, "Pick Next Point: ")
            ThisDrawing.ModelSpace.AddLine pt1, pt2
            While Not pt2(0)
                pt1 = pt2
                If Err.Number <> 0 Then
                    Exit Do
                Else
                    pt2 = .GetPoint(pt1, "Pick Next Point: ")
                    ThisDrawing.ModelSpace.AddLine pt1, pt2
                End If
            Wend
        End With
    Loop
    Me.Show
End Sub

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Please check your brain at the door
« Reply #4 on: April 12, 2007, 04:40:07 PM »
thanks Matt, I'll give that a spin
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Please check your brain at the door
« Reply #5 on: April 12, 2007, 11:20:42 PM »
This is a way without On error resume next.
(I use Randall's autoerrorhandler function so it's quick.


Code - Visual Basic: [Select]
  1. Sub Lines()
  2.     Dim Pt1, Pt2
  3.     Dim Util As AcadUtility
  4.     On Error GoTo Err_Control
  5.     Set Util = ThisDrawing.Utility
  6.    
  7.     With Util
  8.         Pt1 = .GetPoint(, "Pick Starting Point: ")
  9.         Do
  10.             Pt2 = .GetPoint(Pt1, "Pick Next Point: ")
  11.             ThisDrawing.ModelSpace.AddLine Pt1, Pt2
  12.             Pt1 = Pt2
  13.         Loop
  14.     End With
  15.  
  16. Exit_Here:
  17.     Exit Sub
  18. Err_Control:
  19.     Select Case Err.Number
  20.         Case -2147352567, -2145320928
  21.         'Method 'GetPoint' of object 'IAcadUtility2' failed
  22.        'User input is a keyword
  23.            Err.Clear
  24.             Resume Exit_Here
  25.         Case Else
  26.             MsgBox Err.Description
  27.             Err.Clear
  28.             Resume Exit_Here
  29.     End Select
  30. End Sub

kdub->formatting code=vb
« Last Edit: September 21, 2012, 08:41:56 PM by Kerry »

Fatty

  • Guest
Re: Please check your brain at the door
« Reply #6 on: April 15, 2007, 11:10:33 AM »
Bryco,

Ya da man!
I've got an enjoy with your code
Regards,

Oleg  :-)