select touching object

select touching object

ganeshgatkul1
Enthusiast Enthusiast
2,614 Views
16 Replies
Message 1 of 17

select touching object

ganeshgatkul1
Enthusiast
Enthusiast

ganeshgatkul1_0-1654787064060.png

Hello every one,

I have to select object or entity which touches the last created line through point and this line has to draw after user select only one point on the screen and second point of line will be (polar pt1 0 10000)

After drawing this line, the objects (i.e lwpolyline, polyline in red color only) which touches or crosses the line has to select

0 Likes
2,615 Views
16 Replies
Replies (16)
Message 2 of 17

pendean
Community Legend
Community Legend
0 Likes
Message 3 of 17

Kent1Cooper
Consultant
Consultant

Is the Line actually needed for anything other than to select the other object that it crosses?  If you don't actually need the Line, the selection can be made with a simple Fence selection from the User's point pt1 to the point at (polar pt1 0 10000).

Kent Cooper, AIA
0 Likes
Message 4 of 17

john.uhden
Mentor
Mentor

@ganeshgatkul1 

AND

You can add a filter if you want to limit your selection to a combination of object types, layers, colors, etc.

John F. Uhden

0 Likes
Message 5 of 17

Sea-Haven
Mentor
Mentor

Like Kent

 

(setq pt1 (getpoint "\nPick 1st point ") pt2 (polar pt1 0.0 10000))
(setq ss (ssget "F" (list pt1 pt2)))
0 Likes
Message 6 of 17

ganeshgatkul1
Enthusiast
Enthusiast

I have to select object which touches to the that line

0 Likes
Message 7 of 17

Kent1Cooper
Consultant
Consultant

@ganeshgatkul1 wrote:

I have to select object which touches to the that line


... and that code will select it, even if "that line" is only a virtual line [the Fence selection] -- it's not necessary to actually draw a Line object, unless [this was my first question] you will need the Line itself for some purpose other than finding the object it crosses.

Kent Cooper, AIA
0 Likes
Message 8 of 17

ganeshgatkul1
Enthusiast
Enthusiast

I need that line for searching nearby closed polyline and the text entity inside that closed  polyline

 

0 Likes
Message 9 of 17

Kent1Cooper
Consultant
Consultant

@ganeshgatkul1 wrote:

I need that line for searching nearby closed polyline and the text entity inside that closed  polyline


If that's the only thing you need it for, then no, you don't need it as a drawn Line.  That searching can be accomplished without drawing an actual Line, using just the two points that would be the ends of such a Line if it were drawn.  Do you need a drawn Line object for any other purpose?

Kent Cooper, AIA
0 Likes
Message 10 of 17

ganeshgatkul1
Enthusiast
Enthusiast
I don't need line object. Purpose of that line is to select first touching closed polyline just like command Fastsel
0 Likes
Message 11 of 17

Sea-Haven
Mentor
Mentor

It is sounding like you did not test ? When using the fence "F" option you do not actually use an object like a Line or a PLINE but rather a list of points. A line 2 points a pline as many as the vertices of the pline.

 

(setq ss (ssget "F" co-ords )) so co-ords would be a list of points.

0 Likes
Message 12 of 17

Kent1Cooper
Consultant
Consultant

@ganeshgatkul1 wrote:
I don't need line object. Purpose of that line is to select first touching closed polyline....

See Message 5.  Or, to expand on that to find only red closed Polylines:

 

(setq

  pt1 (getpoint "\nPick 1st point: ")

  pt2 (polar pt1 0 10000)
  ss (ssget "F" (list pt1 pt2) '((0 . "LWPOLYLINE") (-4 . "&") (70 . 1) (62 . 1)))

)

Kent Cooper, AIA
0 Likes
Message 13 of 17

calderg1000
Mentor
Mentor

Dear @ganeshgatkul1 

 If you need to do the polygon selection, it doesn't require lisp. It is enough to select it directly.
Or if you can't do it with the Fastsel command.
You should be aware that the Fastsel command has behavior that depends on the FSMODE variable.
Although for your case it may be the same unless you have more entities that can be touched by the selected line.
If you only require the line to select the polygon and everything inside or intersecting it. Try the following code.

 

(defun c:pb (/ p)
  (setq p (getpoint "\nPick point "))
  (vl-cmdf "boundary" p "")
  (sssetfirst
    nil
    (ssget
      "_cp"
      (mapcar 'cdr
              (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (entlast)))
      )
    )
  )
  (entdel (entlast))
)

 

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes
Message 14 of 17

ganeshgatkul1
Enthusiast
Enthusiast

Hello @calderg1000 

Is it possible to create selection set of  closed polyline when user select  inside at any point of that closed polyline with selection filter for layer.

 your routing select all closed polyline which touches or cross  each other.

 

0 Likes
Message 15 of 17

Sea-Haven
Mentor
Mentor

We have all given a answer for pick 1 point just use a suitable search distance, if you make it real big you will get extra objects, you can work out the closest one to the pick point but I am not going to provide anything.

0 Likes
Message 16 of 17

Kent1Cooper
Consultant
Consultant

@ganeshgatkul1 wrote:

... with selection filter for layer. ....


The DXF code number for the Layer is 8.  So you can, for example, add a Layer filter to the (ssget) filter list in Message 12:

....

  ss (ssget "F" (list pt1 pt2) '((0 . "LWPOLYLINE") (-4 . "&") (70 . 1) (62 . 1) (8 . "YourLayerName")))

....

which will find closed red Polylines that cross that Fence line, only on that Layer.

Kent Cooper, AIA
0 Likes
Message 17 of 17

ganeshgatkul1
Enthusiast
Enthusiast

i have to select only that closed polylinein which user select inside any point in that closed pipeline out from outer point

0 Likes