collect points in vba and store them in a variable

collect points in vba and store them in a variable

Anonymous
Not applicable
404 Views
3 Replies
Message 1 of 4

collect points in vba and store them in a variable

Anonymous
Not applicable
Hi,
In VBA i want to collect points in a variable of the type double with the getpoint function but i don't know how many. It depends on the user.
How do i declare the variable since i don't know how big it grows.
The points should then be passed to the add3dpoly method to create a polypline.
0 Likes
405 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Hi,

Two approaches are:

1 Use the "redim preserve" to update the dimensions of the array each time
you wish to add a point.
2 Initially add the data to a collection, then use the count of the
collection to redim the array.

AFAIK the 2nd is more suited to large quantities of data, whereas the first
should be adequate for hand picking of points.
--

Regards,


Laurie Comerford
www.cadapps.com.au

wrote in message news:5066402@discussion.autodesk.com...
Hi,
In VBA i want to collect points in a variable of the type double with the
getpoint function but i don't know how many. It depends on the user.
How do i declare the variable since i don't know how big it grows.
The points should then be passed to the add3dpoly method to create a
polypline.
0 Likes
Message 3 of 4

Anonymous
Not applicable
Thanks for the responce, but do you have an example of the 2nd?
I'm just moving from lisp to VBA and not too familar with this.
0 Likes
Message 4 of 4

Anonymous
Not applicable
This is one way to do what you want. It creates the pline as you go so you
can see it......

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

wrote in message news:5066684@discussion.autodesk.com...
Thanks for the responce, but do you have an example of the 2nd?
I'm just moving from lisp to VBA and not too familar with this.
0 Likes