Results 1 to 3 of 3

Thread: Checking if something is nothing??

  1. #1
    Member
    Join Date
    2003-01
    Location
    Currently Brisbane, Australia
    Posts
    40
    Login to Give a bone
    0

    Default Checking if something is nothing??

    G'day All,
    Am having a crack at this VBA thing and have gone alright today. Iam trying to create a polyline
    where the user can select as many points as they want and when they finish they type T to finish.

    But I have two problems:
    1. The way I have done it is to have a varible for the first point, the second point, and a variable to take all the other points picked by the user (varTendonPoint). But on my first go into my loop it wont have a value for use to draw a line from last point. I tried testing it to nothing but that doesnt seem to work...Is there a more elegant way?
    2. If I type T at the command line it doesnt terminate the polyline it just says invalid option....I thought that if I typed T it would produce an error and I could get out....hmmm lost with using this error stuff in VBA any pointers. It seems pretty clunky.
    Cheers for any help,
    Scott

    Code:
     
    On error resume next
    ThisDrawing.Utility.InitializeUserInput 128, "T t"
    	Do Until Err.Number <> 0
    		'If this is the first point after the second point then use the second point to draw the previous line from
    		If varTendonPoint = Nothing Then
    			varTendonPoint = ThisDrawing.Utility.GetPoint(varSecondTendonPoint, "Specify next tendon point or [<T>erminate tendon]:")
    		'Otherwise use the last point that was picked to draw the previous line from
    		Else
    			varTendonPoint = ThisDrawing.Utility.GetPoint(varTendonPoint, "Specify next tendon point or [<T>erminate tendon]:")
    		End If
    		
    		ReDim Preserve dblTendonPoints(UBound(dblTendonPoints) + 2)
    		dblTendonPoints(UBound(dblTendonPoints) - 1) = varTendonPoint(0): dblTendonPoints(UBound(dblTendonPoints)) = varTendonPoint(1)
    	Loop

  2. #2
    I could stop if I wanted to
    Join Date
    2002-02
    Location
    Kansas
    Posts
    487
    Login to Give a bone
    0

    Default Re: Checking if something is nothing??

    ThisDrawing.Utility.InitializeUserInput need to be call before each call to ThisDrawing.Utility.GetPoint it only good for on call to getpoint
    and you can use a Collection to save you points in

    you should use IsEmpty function

    if IsEmpty(varTendonPoint ) then

    NOT

    If varTendonPoint = Nothing Then

    here the code I would use

    Code:
    Dim x, y
    Dim c As New Collection
    'C IS A COLLECTION OF POINTS
    On Error Resume Next
    Do While True
    x = x + 1
    ThisDrawing.Utility.InitializeUserInput 128, "T t"
    If x = 1 Then
    y = ThisDrawing.Utility.GetPoint(, "Point  " & CStr(x))
    Else
    y = ThisDrawing.Utility.GetPoint(c(c.Count), "Point  " & CStr(x))
    End If
    If Err Then Exit Do
    c.Add y
    Loop
    this code will next on any error of the in put data need to and code to check for keyword in put

  3. #3
    All AUGI, all the time
    Join Date
    2015-12
    Location
    Central Oregon
    Posts
    591
    Login to Give a bone
    0

    Default Re: Checking if something is nothing??

    Here's a sample I posted for someone a while back that does basically what you want...except it is for 3dpoly's. Modify as needed for LW poly's.... mainly the Dim'ed object and LW plines only use x & y. By using this method it allows you to the pline as you draw, a la the pline command.
    Code:
    Sub testpoly()
    Dim vpick As Variant
    Dim dCoords() As Double
    Dim I As Long
    Dim oPoly As Acad3DPolyline
    
    On Error Resume Next
    vpick = ThisDrawing.Utility.GetPoint(, vbCr & "First point: ")
    If Err = 0 Then
        ReDim dCoords(2)
        dCoords(I) = vpick(0): dCoords(I + 1) = vpick(1): dCoords(I + 2) = 
    vpick(2)
        Do Until Err.Number <> 0
            I = I + 3
            vpick = ThisDrawing.Utility.GetPoint(vpick, vbCr & "..next point: ")
            ReDim Preserve dCoords(UBound(dCoords) + 3)
            dCoords(I) = vpick(0): dCoords(I + 1) = vpick(1): dCoords(I + 2) = 
    vpick(2)
            If oPoly Is Nothing Then
                Set oPoly = ThisDrawing.ModelSpace.Add3DPoly(dCoords)
            Else
                oPoly.Coordinates = dCoords
            End If
        Loop
    End If
    End Sub

Similar Threads

  1. Checking
    By Bill Hyland in forum New Forum Users (Non technical)
    Replies: 3
    Last Post: 2006-04-11, 05:00 PM
  2. checking out an .ipt
    By kjolly in forum Inventor - General
    Replies: 2
    Last Post: 2005-09-21, 10:29 PM
  3. Checking in
    By eclipse1995gsx in forum New Forum Users (Non technical)
    Replies: 12
    Last Post: 2005-06-16, 06:39 PM
  4. Checking it out
    By rsmith.84160 in forum New Forum Users (Non technical)
    Replies: 0
    Last Post: 2005-03-14, 04:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •