Lines

Discussion in 'AutoCAD' started by Nick Haury, Feb 11, 2004.

  1. Nick Haury

    Nick Haury Guest

    I am still learning, so bear with me folks! I want to be able to ask these
    two questions ("Pick starting point", and "Pick ending point"), then get the
    points and draw a line from pt1 to pts. In lisp it's easy to do a setq and
    define the pt1 & pt2 and use the get point function, but what would the
    syntax be in VBA to assign variables, be able to pick the first point and
    store it, then pick, or enter a distance relative from the first point, the
    second point and then draw the line? I know that this must be really simple
    to you all, but what the hey, I'm a newbe!
     
    Nick Haury, Feb 11, 2004
    #1
  2. Nick Haury

    Joe Sutphin Guest

    Hi Nick,

    Welcome to VBA, here is your answer.

    Joe
    --
    Public Sub DrawALine()
    Dim StartPoint As Variant
    Dim EndPoint As Variant

    On Error Resume Next

    With ThisDrawing
    StartPoint = .Utility.GetPoint(, "Select line start point")
    EndPoint = .Utility.GetPoint(StartPoint, "Select end point")

    If InStr(1, .GetVariable("LASTPROMPT"), "*Cancel*") Then Exit Sub

    If .ActiveSpace = acModelSpace Then
    .ModelSpace.AddLine StartPoint, EndPoint

    Else
    .PaperSpace.AddLine StartPoint, EndPoint
    End If
    End With
    End Sub
     
    Joe Sutphin, Feb 11, 2004
    #2
  3. Nick Haury

    Nick Haury Guest

    Thanks Joe,
    That seems a lot like lisp, huh, cool!
    Nick
     
    Nick Haury, Feb 11, 2004
    #3
  4. Nick Haury

    Tom Craft Guest

    Joe,
    Just ran into an interesting situation this morning concerning the getpoint
    function. My getpoint function is followed by a getinteger function. I assumed
    that if the user jumped ahead of the prompts and input an integer at the
    getpoint function, an error would be raised. Seems to not be so. It appears
    that (haven't had time to really verify) the coordinates returned are the
    cursor coordinates at the time of the integer input.
    If they answer the getpoint with just an {enter}, there is an error raised.

    Tom Craft
     
    Tom Craft, Feb 11, 2004
    #4
  5. Nick Haury

    Tom Craft Guest

    Joe,
    Just ran into an interesting situation this morning concerning the getpoint
    function. My getpoint function is followed by a getinteger function. I assumed
    that if the user jumped ahead of the prompts and input an integer at the
    getpoint function, an error would be raised. Seems to not be so. It appears
    that (haven't had time to really verify) the coordinates returned are the
    cursor coordinates at the time of the integer input.
    If they answer the getpoint with just an {enter}, there is an error raised.

    Tom Craft
     
    Tom Craft, Feb 11, 2004
    #5
  6. It's called direct distance entry.



    Copyright (c)2004 Tony Tanzillo
    Unauthorized reproduction expressly prohibited.
     
    Tony Tanzillo, Feb 11, 2004
    #6
  7. Nick Haury

    Joe Sutphin Guest

    Hi Tom,

    Here is modified routine that does not allow return or spacebar entry.

    Joe
    --
    Public Sub DrawALine()
    Dim StartPoint As Variant
    Dim EndPoint As Variant

    On Error Resume Next

    With ThisDrawing
    'don't allow return or spacebar input
    .Utility.InitializeUserInput 1
    StartPoint = .Utility.GetPoint(, "Select line start point")
    EndPoint = .Utility.GetPoint(StartPoint, "Select end point")

    If InStr(1, .GetVariable("LASTPROMPT"), "*Cancel*") Then Exit Sub

    If .ActiveSpace = acModelSpace Then
    .ModelSpace.AddLine StartPoint, EndPoint

    Else
    .PaperSpace.AddLine StartPoint, EndPoint
    End If
    End With
    End Sub
     
    Joe Sutphin, Feb 12, 2004
    #7
  8. Nick Haury

    rforjzis Guest

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.