Jump to content
Shablab

Count of Polygons crossed with Polyline

Recommended Posts

Shablab

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?

 

image.thumb.png.b81204912ff2a00d4c3c569048b3ceb1.png

Share this post


Link to post
Share on other sites
ronjonp

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)
)

 

  • Like 1

Share this post


Link to post
Share on other sites
Shablab
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?

Share this post


Link to post
Share on other sites
ronjonp

Sure .. change the ssget filter:

(setq s (ssget "_F" p '((0 . "line") (8 . "yourlayer"))))

 

Edited by ronjonp
  • Like 1

Share this post


Link to post
Share on other sites
BIGAL

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))))

  • Like 1

Share this post


Link to post
Share on other sites
Shablab
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 by Shablab

Share this post


Link to post
Share on other sites
BIGAL

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

 

 

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...