folderdash Posted May 2, 2018 Posted May 2, 2018 Hi I need a lisp routine that can draw a new polyline by connecting selected lines vertices in x or y value order.(İncreasing or decreasing does not matter) Thank you very much Quote
BIGAL Posted May 2, 2018 Posted May 2, 2018 A double sort that may help. Ps website is having problems ? ; sorts on 1st two items (setq lst (vl-sort lst '(lambda (x y) (cond ((= (cadr x)(cadr y)) (< (car x)(car y))) ((< (cadr x)(cadr y))) )))) Quote
folderdash Posted May 2, 2018 Author Posted May 2, 2018 A double sort that may help. Ps website is having problems ? ; sorts on 1st two items (setq lst (vl-sort lst '(lambda (x y) (cond ((= (cadr x)(cadr y)) (< (car x)(car y))) ((< (cadr x)(cadr y))) )))) What will i write to command line to run this routine? PS: yes web site has problems now. Quote
BIGAL Posted May 2, 2018 Posted May 2, 2018 You need to post some idea of what your trying to achieve. The internet problem is stopping my crystal ball from working. Quote
folderdash Posted May 2, 2018 Author Posted May 2, 2018 You need to post some idea of what your trying to achieve. The internet problem is stopping my crystal ball from working. I have hundreds of individualy drawn polylines.I need to draw new polylines on them but the new polylines need to be drawn in order with decreasing or increasing X values or (Y values optionaly) Thank you Quote
BIGAL Posted May 2, 2018 Posted May 2, 2018 Still waiting for an image or dwg can not help without that. Quote
folderdash Posted May 2, 2018 Author Posted May 2, 2018 Still waiting for an image or dwg can not help without that. Unable to display content. Adobe Flash is required. Please check the video in the link.The white poly is existing and i have hundreds of it.The magenta line is what i want to have to draw in order with x value or sometimes y value.I hope its now clear. Thank you Quote
BIGAL Posted May 3, 2018 Posted May 3, 2018 (edited) Ok it makes sense now it can be done easily using sort a list of points based on X or Y. My 1st post is sort on X&Y will try to post something a bit later need to do some work now. ; pline co-ords example ; By Alan H (defun getcoords (ent) (vlax-safearray->list (vlax-variant-value (vlax-get-property obj "Coordinates" ) ) ) ) ; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z (defun co-ords2xy () (setq len (length co-ords)) (if (= (vla-get-objectname obj) "AcDbLwpolyline") (setq numb (/ len 2)) ; even and odd check required (setq numb (/ len 2))) (setq I 0) (repeat numb (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) )) ; odd (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords)(nth (+ I 2) co-ords) )) (setq co-ordsxy (cons xy co-ordsxy)) (setq I (+ I 2)) ) ) ; program starts here (defun C:ahjoinX ( / co-ordsxy lst) (setq obj (vlax-ename->vla-object (car (entsel "\nplease pick pline")))) (setq co-ords (getcoords obj)) (co-ords2xy) (setq lst (vl-sort co-ordsxy (function (lambda (e1 e2) (< (car e1) (car e2))))) ) (command "_pline") (while (= (getvar "cmdactive") 1 ) (repeat (setq x (length lst)) (command (nth (setq x (- x 1)) lst)) ) (command "") ) (princ) ) (C:ahjoinx) Edited May 4, 2018 by BIGAL Quote
folderdash Posted May 4, 2018 Author Posted May 4, 2018 Thank you.That works for X values, but do i have to eachtime "appload" the lisp to run it?Is there a command to run that lisp? Quote
BIGAL Posted May 4, 2018 Posted May 4, 2018 Code changed to command line version type ahjoinx for next, it will do 1st on loading. Just a quick 1 the old code if you typed (ah:joinx) it would repeat. Also you mentioned Y as choice this would use the cadr in the sort instead of car. Quote
folderdash Posted May 7, 2018 Author Posted May 7, 2018 Thank you very much.That's exactly what i need. 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.