lisp polyline

Discussion in 'AutoCAD' started by suky, Jan 24, 2004.

  1. suky

    suky Guest

    I would like to enter the coordinates of six points end draw a closed
    polyline between the points.
    I would also like to do it for many polylines with different coordinates.
    Does anyone have a such lisp routine?
    T.i.a.
     
    suky, Jan 24, 2004
    #1
  2. suky

    R.K. McSwain Guest

    Like this??

    (defun mypoly (lst)
    (command "._pline")
    (foreach item lst (command item))
    (command "_c")
    )

    ....where "lst" is a list of coordinates.
    Example:
    (setq lst (list
    (list 0 -3)
    (list 1 1)
    (list 2 2)
    (list 2 5)
    (list 5 1)
    (list 6 -8)
    )
    )
     
    R.K. McSwain, Jan 24, 2004
    #2
  3. suky

    suky Guest

    How can i use it?
    I mean, i need to activate command and then
    to be asked to input the coordinats of each point apart
    and polyline to be drawn.I have more than 500 objects i need to draw.
    TIA
     
    suky, Jan 24, 2004
    #3
  4. suky

    suky Guest

    How can i use it?
    I mean, i need to activate command and then
    to be asked to input the coordinats of each point apart
    and polyline to be drawn.I have more than 500 objects i need to draw.
    TIA

    "R.K. McSwain" <> schreef in bericht
    Like this??

    (defun mypoly (lst)
    (command "._pline")
    (foreach item lst (command item))
    (command "_c")
    )

    ....where "lst" is a list of coordinates.
    Example:
    (setq lst (list
    (list 0 -3)
    (list 1 1)
    (list 2 2)
    (list 2 5)
    (list 5 1)
    (list 6 -8)
    )
    )
     
    suky, Jan 24, 2004
    #4
  5. suky

    ECCAD Guest

    ;; Make Polyline from points:
    ;;
    (defun mypoly (lst)
    (command "._pline")
    (foreach item lst (command item))
    (command "_c")
    ); end function
    ;;
    ;; Input your points:
    ;;
    (defun C:GP ()
    (setq P1x (getreal "\nPoint 1: X "))
    (setq P1y (getreal "\nPoint 1: Y "))
    (setq P2x (getreal "\nPoint 2: X "))
    (setq P2y (getreal "\nPoint 2: Y "))
    (setq P3x (getreal "\nPoint 3: X "))
    (setq P3y (getreal "\nPoint 3: Y "))
    (setq P4x (getreal "\nPoint 4: X "))
    (setq P4y (getreal "\nPoint 4: Y "))
    (setq P5x (getreal "\nPoint 5: X "))
    (setq P5y (getreal "\nPoint 5: Y "))
    (setq P6x (getreal "\nPoint 6: X "))
    (setq P6y (getreal "\nPoint 6: Y "))
    (setq P1 (list P1x P1y 0.0))
    (setq P2 (list P2x P2y 0.0))
    (setq P3 (list P3x P3y 0.0))
    (setq P4 (list P4x P4y 0.0))
    (setq P5 (list P5x P5y 0.0))
    (setq P6 (list P6x P6y 0.0))
    (setq p_lst (list P1 P2 P3 P4 P5 P6)); make a list of points..
    (mypoly p_lst); and apply
    (setq p_lst nil P1 nil P2 nil P3 nil P4 nil P5 nil P6 nil)
    (setq p1x nil p1y nil p2x nil p2y nil p3x nil p3y nil p4x nil p4y nil p5x nil p5y nil p6x nil p6y nil)
    (princ)
    ); end function C:GP ' get points'
    ;;

    Load and call up with GP at command prompt.
    Might be easier to place all the points in a 'text' file, then
    read-in and apply in groups of 6.

    Bob
     
    ECCAD, Jan 24, 2004
    #5
  6. suky

    suky Guest

    I loaded it up and inputed my coordinates but it doesn't draw a polyline.
    I get on the command prompt "unknown command _ c".
    Am i doing something wrong or the lisp needs to be completed?
    Thanks for your time in advance.
     
    suky, Jan 25, 2004
    #6
  7. suky

    Jeff Mishler Guest

    I just tried it in Acad2002 and it worked just fine.....

    What version of Acad? Are you making sure to input all of the X & Y prompts?

    Jeff
     
    Jeff Mishler, Jan 25, 2004
    #7
  8. suky

    ECCAD Guest

    Hmm,
    Works for me. Don't hit the Enter key for any X or Y values.
    Gathers (6) sets of X,Y points, draws a Pline point to point, then does a "_c" - Close option.
    Only thing I can think of IF your AutoCAD is not (ENGLISH) version, you will need to replace the "_c" with whatever character code is for your (Close) option.
    Bob
     
    ECCAD, Jan 26, 2004
    #8
  9. suky

    suky Guest

    That did the trick.Now it works great,thank you.
    If i want for example, to draw an arc between points 3 and 4, how can i
    define it?
    TIA

    will need to replace the "_c" with whatever character code is for your
    (Close) option.
     
    suky, Jan 26, 2004
    #9
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.