Shablab Posted February 26, 2019 Share Posted February 26, 2019 I have a line that crosses through multiple polygons. Is there a LISP to give me a count of how many polygons this line goes through? Quote Link to comment Share on other sites More sharing options...
ronjonp Posted February 26, 2019 Share Posted February 26, 2019 Here is a quick one .. all objects must be on screen. (defun c:foo (/ e p s) (cond ((and (setq e (car (entsel "\nPick a polyline: "))) (setq p (mapcar 'cdr (vl-remove-if '(lambda (x) (/= 10 (car x)))(entget e)))) (setq s (ssget "_F" p)) ) (print (1- (sslength s))) (sssetfirst nil s) ) ) (princ) ) 1 Quote Link to comment Share on other sites More sharing options...
Shablab Posted February 26, 2019 Author Share Posted February 26, 2019 36 minutes ago, ronjonp said: Here is a quick one .. all objects must be on screen. (defun c:foo (/ e p s) (cond ((and (setq e (car (entsel "\nPick a polyline: "))) (setq p (mapcar 'cdr (vl-remove-if '(lambda (x) (/= 10 (car x)))(entget e)))) (setq s (ssget "_F" p)) ) (print (1- (sslength s))) (sssetfirst nil s) ) ) (princ) ) That works great. Is there a way to only select crossed lines only on a selected layer? Quote Link to comment Share on other sites More sharing options...
ronjonp Posted February 26, 2019 Share Posted February 26, 2019 (edited) Sure .. change the ssget filter: (setq s (ssget "_F" p '((0 . "line") (8 . "yourlayer")))) Edited February 26, 2019 by ronjonp 1 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 27, 2019 Share Posted February 27, 2019 A little bit more (setq lay (cdr (assoc 8 (entget (car (entsel "pick object for layer")))))) (setq s (ssget "_F" p (list (cons 0 "line") (cons 8 lay)))) 1 Quote Link to comment Share on other sites More sharing options...
Shablab Posted February 27, 2019 Author Share Posted February 27, 2019 (edited) 13 hours ago, BIGAL said: A little bit more (setq lay (cdr (assoc 8 (entget (car (entsel "pick object for layer")))))) (setq s (ssget "_F" p (list (cons 0 "line") (cons 8 lay)))) This doesn't seem to be working properly. It doesn't select any after "pick object for layer". Edited February 27, 2019 by Shablab Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 28, 2019 Share Posted February 28, 2019 There must be some hidden characters in the ssget line, I removed the "f" p and it did not work when I pasted into cad. Re-tested and Ok Retype the line in notepad. Command: (setq s (ssget "x" (list (cons 0 "Line")(cons 8 lay)))) <Selection set: 55> (sslength s) 6 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.