Polyline Command: Reinventing the wheel or something else?

Discussion in 'AutoCAD' started by reneram, Apr 8, 2004.

  1. reneram

    reneram Guest

    I need to replicate the _pline command of AutoCAD in my program; I need the user to create the polyline at run time (I'll hide my form, have the user create the polyline, and then show my form again for further operations).
    I tried using ThisDrawing.SendCommand(..), but it assumes that I have all the information of the poly. Best thing could be pausing the program, having the user draw his polyline, and then from the code retrieving the LAST entitie created, but I don't know if it's possible; on the other side I can't quit the program because I'm storing data in my variables that I'll be using with the newly created polyline.
    Any suggestions
    Thanks
    René
     
    reneram, Apr 8, 2004
    #1
  2. reneram

    HJohn Guest

    Why not create the polyline before you execute your program? The user, then would have only to selet it.
     
    HJohn, Apr 8, 2004
    #2
  3. reneram

    reneram Guest

    Because I'm working on an interactive interface, and the user is suppose to create the polylines during execution as the boundery of an area that will have external data referenced.
    No only, I'm just letting the user create the polyline as a border, but all the other setting are predefined by the variables at run time depending on previous option selections that the user has made, ie: layer, color, hatchpattern, linetype, and so on with the external data.
     
    reneram, Apr 9, 2004
    #3
  4. reneram

    Jackrabbit Guest

    Can you prompt the user to enter a series of points using the GetPoint function? You could save the points and use them to create a polyline object programmatically.

    This would be relatively easy to do if the areas selected are always rectangular. You would only need to prompt for the lower left and upper right points of the rectangle.
     
    Jackrabbit, Apr 9, 2004
    #4
  5. reneram

    Tom Craft Guest

    Try something like this.

    Tom

    Public Sub process_draw_poly()
    Dim pntarry(3) As Double
    dim cnt As Integer
    Dim pnt1 As Variant, pnt2 As Variant
    Dim dpnt(1) As Double
    dim selpoly As AcadLWPolyline

    On Error GoTo errhndlr
    pnt1 = thisdrawing.utility.getpoint( , "First point|")
    pnt2 = thisdrawing.utility.getpoint(pnt1 , "Second point|")
    'no error, must have start of pline
    pntarry(0) = pnt1(0): pntarry(1) = pnt1(1)
    pntarry(2) = pnt2(0): pntarry(3) = pnt2(1)
    If THISDRAWING.ActiveSpace = acModelSpace Then
    Set selpoly = THISDRAWING.ModelSpace.AddLightWeightPolyline(pntarry)
    Else
    Set selpoly = THISDRAWING.PaperSpace.AddLightWeightPolyline(pntarry)
    End If
    cnt = 1
    Do
    pnt1(0) = pnt2(0): pnt1(1) = pnt2(1)
    pnt2 = thisdrawing.utility.getpoint( pnt1, "Next point|")
    dpnt(0) = pnt2(0): dpnt(1) = pnt2(1)
    cnt = cnt + 1
    selpoly.AddVertex cnt, dpnt
    Loop
    errhndlr:
    End Sub
     
    Tom Craft, Apr 9, 2004
    #5
  6. reneram

    reneram Guest

    I've been going even further than this, what I have to do is a real replica of the pline command or call it from vba with all the options it has (rubber-band, arc, width, close, ...) called from the command line.
    Once the user has created the polyline I can work with it.
     
    reneram, Apr 19, 2004
    #6
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.