Results 1 to 4 of 4

Thread: Draw Polyline needing x,y,&z coordinates from collection

  1. #1
    Member
    Join Date
    2015-11
    Posts
    3
    Login to Give a bone
    0

    Default Draw Polyline needing x,y,&z coordinates from collection

    Background:

    I receive a .dxf with points. These points are arrayed in x,y,& z coordinates. I have extracted the coordinates into collections and I am trying to draw a polyline using those coordinates as vertices. It is important that the z coordinate be included. All points differ in their x,y,z coordinates.

    The collection is a collection of arrays (0 to 2).

    This was my attempt to call vertices straight from the collection:

    Code:
    ThisDrawing.ActiveLayer = newLayer
    Set pLineA = ThisDrawing.ModelSpace.Add3DPoly(pointCollA.Item(1), pointCollA.Item(2), pointCollA.Item(3), _
                                                    pointCollA.Item(4), pointCollA.Item(5), pointCollA.Item(6), _
                                                    pointCollA.Item(7), pointCollA.Item(8), pointCollA.Item(9), _
                                                    pointCollA.Item(10), pointCollA.Item(11), pointCollA.Item(12), _
                                                    pointCollA.Item(13), pointCollA.Item(14), pointCollA.Item(15), _
                                                    pointCollA.Item(16), pointCollA.Item(17), pointCollA.Item(18), _
                                                    pointCollA.Item(19), pointCollA.Item(20), pointCollA.Item(21), _
                                                    pointCollA.Item(22), pointCollA.Item(23), pointCollA.Item(24), _
                                                    pointCollA.Item(25))
    
    ThisDrawing.ActiveLayer = newLayer1
    Set pLineB = ThisDrawing.ModelSpace.Add3DPoly(pointCollB.Item(1), pointCollB.Item(2), pointCollB.Item(3), _
                                                    pointCollB.Item(4), pointCollB.Item(5), pointCollB.Item(6), _
                                                    pointCollB.Item(7), pointCollB.Item(8), pointCollB.Item(9), _
                                                    pointCollB.Item(10), pointCollB.Item(11), pointCollB.Item(12), _
                                                    pointCollB.Item(13), pointCollB.Item(14), pointCollB.Item(15), _
                                                    pointCollB.Item(16), pointCollB.Item(17), pointCollB.Item(18), _
                                                    pointCollB.Item(19), pointCollB.Item(20), pointCollB.Item(21), _
                                                    pointCollB.Item(22), pointCollB.Item(23), pointCollB.Item(24), _
                                                    pointCollB.Item(25))
    Result is: Compile error: Wrong number of arguments or invalid property assignment.

    Thank you for help!

  2. #2
    Member
    Join Date
    2015-11
    Posts
    3
    Login to Give a bone
    0

    Default Re: Draw Polyline needing x,y,&z coordinates from collection

    BTW ive tried this with AddPolyline & AddLightWeightPolyline too.

  3. #3
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,397
    Login to Give a bone
    0

    Default Re: Draw Polyline needing x,y,&z coordinates from collection

    You pass it an array object, not a list of points. Here's the sample from the help file.
    Code:
    Sub Example_Add3DPoly()
        
        Dim polyObj As Acad3DPolyline
        Dim points(0 To 8) As Double
        
        ' Create the array of points
        points(0) = 0: points(1) = 0: points(2) = 0
        points(3) = 10: points(4) = 10: points(5) = 10
        points(6) = 30: points(7) = 20: points(8) = 30
        
        ' Create a 3DPolyline in model space
        Set polyObj = ThisDrawing.ModelSpace.Add3DPoly(points)
        ZoomAll
        
    End Sub
    C:> ED WORKING....

  4. #4
    Member
    Join Date
    2015-11
    Posts
    3
    Login to Give a bone
    0

    Default Re: Draw Polyline needing x,y,&z coordinates from collection

    Yep. Thank you. What I wasn't realizing was that i needed to initialize it with the first two points and then append it for the rest of the vertices.

    Here was my end result.

    Code:
    Dim points(0 To 5) As Double
    Dim points1(0 To 2) As Double
    Dim pLineA As Acad3DPolyline
    Dim pLineB As Acad3DPolyline
    
    index = 0
    ThisDrawing.ActiveLayer = newLayer
        For Each coords In railOne
            If index < count Then
                If index < 1 Then
                    handle = railOne(index)
                    Set object = ThisDrawing.HandleToObject(handle)
                        points(0) = object.Coordinates(0)
                        points(1) = object.Coordinates(1)
                        points(2) = object.Coordinates(2)
    
                    index = index + 1
                    handle = railOne(index)
                    Set object = ThisDrawing.HandleToObject(handle)
                        points(3) = object.Coordinates(0)
                        points(4) = object.Coordinates(1)
                        points(5) = object.Coordinates(2)
                        Set pLineA = ThisDrawing.ModelSpace.Add3DPoly(points)
                        index = index + 1
                Else
                    handle = railOne(index)
                    Set object = ThisDrawing.HandleToObject(handle)
                        points1(0) = object.Coordinates(0)
                        points1(1) = object.Coordinates(1)
                        points1(2) = object.Coordinates(2)
                    pLineA.AppendVertex points1
                    index = index + 1
                End If
            Else
            End If
        Next coords
    Thank you for the help!!!!

Similar Threads

  1. Select polyline and get coordinates
    By avinash patil in forum Dot Net API
    Replies: 5
    Last Post: 2012-11-04, 08:24 PM
  2. Polyline Coordinates finding
    By avinash patil in forum VBA/COM Interop
    Replies: 1
    Last Post: 2012-08-30, 11:29 AM
  3. 3D Polyline coordinates
    By lmitsou in forum AutoLISP
    Replies: 5
    Last Post: 2008-07-17, 08:49 PM
  4. Replies: 8
    Last Post: 2007-06-07, 07:53 PM
  5. Can I draw lines using coordinates eg 44˚34.00'N 125˚26.0'W
    By strenge in forum AutoCAD Map 3D - General
    Replies: 21
    Last Post: 2007-01-14, 08:22 AM

Posting Permissions

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