RepCad Posted July 17, 2017 Share Posted July 17, 2017 Hello everybody,, how can i draw polyline by list of x,y coordinate ?? : list = ((x1 y1)(x2 y2)(x3 y3)(x4 y4) ......) example my coordinate : ((2420.96 1612.3) (2422.96 1612.25) (2423.96 1612.12) (2424.96 1612.24) (2425.96 1612.09) (2426.96 1612.14) (2427.96 1612.08) (2429.84 1612.08) (2430.06 1612.15) (2430.96 1612.12) (2431.96 1612.17) (2432.46 1612.17)) Thanks in advance, Quote Link to comment Share on other sites More sharing options...
ronjonp Posted July 17, 2017 Share Posted July 17, 2017 You can use the function HERE to do this. Quote Link to comment Share on other sites More sharing options...
benhubel Posted July 17, 2017 Share Posted July 17, 2017 Apparently I'm just a couple minutes too late. Still, I'll post what I wrote anyway. It's really simple and there may be bugs, but it seems to work with your data-set, at least. (defun c:writepoints ( / verts index) (setq verts '((2420.96 1612.3)(2422.96 1612.25)(2423.96 1612.12)(2424.96 1612.24)(2425.96 1612.09)(2426.96 1612.14)(2427.96 1612.08)(2429.84 1612.08)(2430.06 1612.15)(2430.96 1612.12)(2431.96 1612.17)(2432.46 1612.17))) (setq index 0) (repeat (1- (length verts)) (command "_.line" (append (nth index verts) '(0.0)) (append (nth (1+ index) verts) '(0.0)) "") (setq index (1+ index)) ) ) Quote Link to comment Share on other sites More sharing options...
Grrr Posted July 17, 2017 Share Posted July 17, 2017 (defun C:test ( / PointList ) (setq PointList '( (2420.96 1612.3) (2422.96 1612.25) (2423.96 1612.12) (2424.96 1612.24) (2425.96 1612.09) (2426.96 1612.14) (2427.96 1612.0) (2429.84 1612.0) (2430.06 1612.15) (2430.96 1612.12) (2431.96 1612.17) (2432.46 1612.17) ) ) (LWPoly PointList (if (progn (initget "Yes No") (member (getkword "\nClosed ? [Yes/No] <Yes>: ") '(nil "Yes"))) 1 0) ) (princ) ); defun (defun LWPoly (lst cls) ; LM's entmake functions (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length lst)) (cons 70 cls) ) (mapcar (function (lambda (p) (cons 10 p))) lst) ) ) ) Quote Link to comment Share on other sites More sharing options...
RepCad Posted July 17, 2017 Author Share Posted July 17, 2017 Apparently I'm just a couple minutes too late. Still, I'll post what I wrote anyway. It's really simple and there may be bugs, but it seems to work with your data-set, at least. (defun c:writepoints ( / verts index) (setq verts '((2420.96 1612.3)(2422.96 1612.25)(2423.96 1612.12)(2424.96 1612.24)(2425.96 1612.09)(2426.96 1612.14)(2427.96 1612.08)(2429.84 1612.08)(2430.06 1612.15)(2430.96 1612.12)(2431.96 1612.17)(2432.46 1612.17))) (setq index 0) (repeat (1- (length verts)) (command "_.line" (append (nth index verts) '(0.0)) (append (nth (1+ index) verts) '(0.0)) "") (setq index (1+ index)) ) ) Thanks benhubel, your code is work and it dont have any bugs. thanks alot for your help Quote Link to comment Share on other sites More sharing options...
RepCad Posted July 17, 2017 Author Share Posted July 17, 2017 (defun C:test ( / PointList ) (setq PointList '( (2420.96 1612.3) (2422.96 1612.25) (2423.96 1612.12) (2424.96 1612.24) (2425.96 1612.09) (2426.96 1612.14) (2427.96 1612.0) (2429.84 1612.0) (2430.06 1612.15) (2430.96 1612.12) (2431.96 1612.17) (2432.46 1612.17) ) ) (LWPoly PointList (if (progn (initget "Yes No") (member (getkword "\nClosed ? [Yes/No] <Yes>: ") '(nil "Yes"))) 1 0) ) (princ) ); defun (defun LWPoly (lst cls) ; LM's entmake functions (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length lst)) (cons 70 cls) ) (mapcar (function (lambda (p) (cons 10 p))) lst) ) ) ) Grrr, Thank you for your time, your code that's what I want, thanks alot. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 18, 2017 Share Posted July 18, 2017 Another way ; create pline from a list ; by Alan H (command "_pline") (while (= (getvar "cmdactive") 1 ) (repeat (setq x (length lst)) (command (nth (setq x (- x 1)) lst)) ) (command "") ) Quote Link to comment Share on other sites More sharing options...
eldon Posted July 18, 2017 Share Posted July 18, 2017 Writing a lisp to draw one polyline seems an awful lot of effort with maximum chance of mistakes whilst typing all those digits. If your data is in the form of a csv file of coordinates, there are simpler ways of drawing a polyline. Quote Link to comment Share on other sites More sharing options...
Nuggi Posted October 20, 2020 Share Posted October 20, 2020 Dear, those lisps are pretty suitable for line polylines, I hope somebody help to make it into arc polylines. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.