return a AcadLWPolyline in a function

Discussion in 'AutoCAD' started by villaco, Aug 8, 2003.

  1. villaco

    villaco Guest

    Hello everybody
    I'm trying to make a function which return value will be an autocad object,
    I wrote this:

    Function line(xi As Double, yi As Double, xf As Double, yf As Double) As AcadLWPolyline
        Dim dblpoints(1 To 4) As Double
        Dim lwlinea As AcadLWPolyline
        dblpoints(1) = xi
        dblpoints(2) = yi
        dblpoints(3) = xf
        dblpoints(4) = yf
        Set lwlinea = ThisDrawing.ModelSpace.AddLightWeightPolyline(dblpuntos)
        set line = lwlinea
    End Function

    but i get an error message, maybe this is not the right way?
    thanx
    Villaco
     
    villaco, Aug 8, 2003
    #1
  2. Villaco,
    The only error in your function was in the following line.
    ...AddLightWeightPolyline(dblpuntos)
    needs to be
    ...AddLightWeightPolyline(dblpoints)


    This subroutine calls your procedure to make a polyline at the origin

    Sub make_line()
    Dim newLine As AcadLWPolyline
    Set newLine = line(0, 0, 2, 3)
    End Sub


    Good luck,
    James
     
    James Belshan, Aug 8, 2003
    #2
  3. villaco

    villaco Guest

    Thanx James and Ed
    I will follow Ed suggestions!
    My problem was the way I call the function,

    Dim Objlinea As AcadLWPolyline
    Objlinea = line(rslineasp!xi, rslineasp!yi, rslineasp!xf, rslineasp!yf)<----this was my mistake

    James guide me
    Set Objlinea = linea(rslineasp!xi, rslineasp!yi, rslineasp!xf, rslineasp!yf)

    Thank u, this function really makes my work easy.

    Villaco
     
    villaco, Aug 9, 2003
    #3
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.