Jump to content

Recommended Posts

Posted

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

Posted

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
Posted
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?

Posted (edited)

Sure .. change the ssget filter:

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

 

Edited by ronjonp
  • Like 1
Posted

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
Posted (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 by Shablab
Posted

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

 

 

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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