asdfgh Posted May 19, 2022 Posted May 19, 2022 Hello Everyone, First I want to thank everyone for helping in this forum, you really inspire me and helped me alot. I have some polylines, long polylines in red and yellow color, and small magenta polylines near the red and yellow polylines, the magenta polylines are near the vertex of the red and yellow polylines by less than 50mm distance. What i want is a lisp to count number of magenta polylines near the yellow polylines and count number of magenta polylines near near red polylines each result is separate ( So the result in this sample should be 6 for yellow and 3 for red). You can find the attached drawing as a reference. Can anyone help with that ? Thanks is advance. Note: if it is hard to get it, Can there be a lisp to only select the magenta polylines near any polylines i select ? new block.dwg Quote
mhupp Posted May 19, 2022 Posted May 19, 2022 (edited) Since everything is on the same layer I splits up the polylines based on their color. then calculate a small area at the endpoints to see if anything magenta polylines are inside. totally useless if the polylines are any other color. (defun C:COUNT (/ ) (prompt (strcat "\nArrows at yellow Polylines: " (itoa (count 2)))) (prompt (strcat "\nArrows at red Polylines: " (itoa (count 1)))) (princ) ) (defun count (col / c ss ent lst pt1 pt2) (setq c 0) (if (setq ss (ssget "_X" (list '(0 . "*POLYLINE") (cons 62 col)))) (foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) (setq lst (vl-remove-if 'not (mapcar (function (lambda (p) (if (= 10 (car p)) (cdr p)))) (entget ent)))) (setq pt1 (mapcar '- (car lst) '(100 100))) (setq pt2 (mapcar '+ (car lst) '(100 100))) (if (ssget "_C" pt1 pt2 '((0 . "*POLYLINE") (62 . 6))) (setq c (+ c 1)) ) (setq pt1 (mapcar '- (last lst) '(100 100))) (setq pt2 (mapcar '+ (last lst) '(100 100))) (if (ssget "_C" pt1 pt2 '((0 . "*POLYLINE") (62 . 6))) (setq c (+ c 1)) ) ) ) c ) : COUNT Arrows at yellow Polylines: 6 Arrows at red Polylines: 3 Edited May 19, 2022 by mhupp 2 Quote
asdfgh Posted May 30, 2022 Author Posted May 30, 2022 Thanks for your reply really helped me alot 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.