gS7 Posted February 17, 2017 Posted February 17, 2017 Hi Guys How to Create Line for coordinates from list using lambda function Please need help for solve this (defun c:test(/ lst ) (setq lst '((1515.32 999.613 0.0) (2314.23 1081.97 0.0) (1690.57 752.536 0.0) (2458.55 829.747 0.0) (1685.41 474.574 0.0) (2716.26 443.689 0.0)) ) (mapcar (function (lambda (x y) [color="red"] (command "line" x y "")[/color] ???? )) lst ) ) Quote
Grrr Posted February 17, 2017 Posted February 17, 2017 (mapcar '(lambda (x y) (entmakex (list (cons 0 "LINE") (cons 10 x) (cons 11 y)))) lst (append (cdr lst) (list (last lst))) ) Or: (mapcar '(lambda (x) (entmakex (list (cons 0 "LINE") (cons 10 (car x)) (cons 11 (cadr x))))) (mapcar 'list lst (append (cdr lst) (list (last lst)))) ) EDIT: Or if you use LM's entmake functions, then you could just (defun LWPoly (lst cls) ; LM (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) ) ) ) do this: (LWPoly lst 0) Quote
gS7 Posted February 17, 2017 Author Posted February 17, 2017 Grrr That was awesome and i don't want to create only 3 Line Entity's for example '(1 1) '(2 2) '(3 3) Please waiting for your reply Quote
Grrr Posted February 17, 2017 Posted February 17, 2017 Grrr That was awesome and i don't want to create only 3 Line Entity's for example '(1 1) '(2 2) '(3 3) Please waiting for your reply If you want to create lines from a point list, you have to group the items so each one consists of 2 points (a line is defined of 2 points) : Instead of such list '(1 1) '(2 2) '(3 3) you'll have to use: (list '((1 1) (2 2)) ; line #1 '((2 2) (3 3)) ; line #2 '((3 3) (1 1)) ; line #3 (if you want to close the shape) ) Quote
gS7 Posted February 17, 2017 Author Posted February 17, 2017 If you want to create lines from a point list, you have to group the items so each one consists of 2 points (a line is defined of 2 points) :Instead of such list '(1 1) '(2 2) '(3 3) you'll have to use: (list '((1 1) (2 2)) ; line #1 '((2 2) (3 3)) ; line #2 '((3 3) (1 1)) ; line #3 (if you want to close the shape) ) Grrr thank you It is helped me lot Quote
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.