Jump to content

How to select objects that touch a line?


M76

Recommended Posts

ssget won't select the objects toching a line, only those that cross it.

(ssget "_F" (list p1 p2) ) didn't select anything

 

What method is the best for selecting these objects, if I know the endpoints of the line?

 

I've tried to create a polygon around the line, but I screwed something up in this code, I'm not sure what. It only works if the angle of the line is below 180.

 

(setq sp-angle (angle p1 p2))
(setq sp1 (polar p2 (+ sp-angle (/ pi 4)) puffer))
(setq sp2 (polar p2 (- sp-angle (/ pi 4)) puffer))
(setq sp3 (polar p1 (- (abs (- pi sp-angle)) (/ pi 4)) puffer))
(setq sp4 (polar p1 (+ (abs (- pi sp-angle)) (/ pi 4)) puffer))

Link to comment
Share on other sites

What method is the best for selecting these objects, if I know the endpoints of the line?

 

Don't have any code of mine on hand, but recall a function from an old friend.

 

The master John F. Uhden.

 

Here is the link:

http://www.cadlantic.com/Freebies.htm

 

And see if SSGETENDS.LSP could help, among some other great stuff available there.

Link to comment
Share on other sites

You could use a fuzz factor .... say 0.001 and calc the point beyond

(polar p1 (angle p1 p2)(+ 0.001 (distance p1 p2)))

 

That only extends the line, I'd have to create a polygon that encloses the line. Which I tried to do in the first post, but there is a problem with the angles.

Link to comment
Share on other sites

Don't have any code of mine on hand, but recall a function from an old friend.

 

The master John F. Uhden.

 

Here is the link:

http://www.cadlantic.com/Freebies.htm

 

And see if SSGETENDS.LSP could help, among some other great stuff available there.

 

Thanks but that only selects objects near the ends of the line, which is fairly easy to do almost every lsp I created uses something like this. What I need is to select all objects along the line.

Link to comment
Share on other sites

This?

 

(defun GetTouching (ent fuzz / p1 p2 ang pi/2)    
 (setq p1 (cdr (assoc 10 (entget ent)))
       p2 (cdr (assoc 11 (entget ent)))

       ang (angle p1 p2) pi/2 (/ pi 2.))    

 (ssget "_CP" (list (polar p1 (+ ang pi/2) fuzz)
                    (polar p1 (- ang pi/2) fuzz)
                    (polar p2 (- ang pi/2) fuzz)
                    (polar p2 (+ ang pi/2) fuzz))))



(defun c:test (/ ent)
 (if (and (setq ent (car (entsel "\nSelect Line: ")))
          (eq "LINE" (cdr (assoc 0 (entget ent)))))
   (sssetfirst nil (GetTouching ent 0.001)))
 (princ))

Link to comment
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
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...