lisp polyline

suky

Usenet Archive
Joined
Jan 23, 2004
Messages
5
Reaction score
0
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 said:
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.

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)
)
)
 
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
 
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
suky said:
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.

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)
)
)
 
;; 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
 
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.
 
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
 
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
 
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

ECCAD said:
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.
 

Latest threads

Back
Top