selection set using existing polygon

islam.a.hamza95
Observer
Observer

selection set using existing polygon

islam.a.hamza95
Observer
Observer

Hi all,

sorry if this question seems to be silly, i am beginner at autolisp 

I want to create  selection set from an existing polyline that the user picks.  The selection set should select everything inside of the closed polyline.

and i tried all arguments I know in ssget function and it didn't work for me.

can anyone help me ?

 

0 Likes
Reply
896 Views
9 Replies
Replies (9)

ВeekeeCZ
Consultant
Consultant

If your polygon is lwpolyline without arc segments, you can use the attachment. That's probably not mine but looks good as an example of how to approach such a task.

0 Likes

calderg1000
Mentor
Mentor

Regards  @islam.a.hamza95 

For what you require there are many examples in the forums. But if you want to learn, to start with the ssget method, you can use the following:

 

 

;;;1. Select the polyline and apply any method to get the list of points of its vertices
(setq p_list(entget(car(entsel"\nSelect the LwPolyline: "))))
;;;..........
;;;2. Apply the SSGET method, Polygon window. To select objects that are inside the selected polygon
(setq s (sssetfirst nil (ssget "_wp" (list p_list))))

 

 

 To learn, try first, if you can't, ask for help..., here we are happy to help


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

Sea-Haven
Mentor
Mentor

Sometimes also want "CP".

 

For pline pts

 

(setq plent (entsel "\nPick pline"))
(if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))))
(princ co-ord)

Note if you have arcs it becomes more complicated and need to use facets around the arcs.

 

0 Likes

pbejse
Mentor
Mentor

@islam.a.hamza95 wrote:

...and i tried all arguments I know in ssget function and it didn't work for me

 


 

CP
Crossing polygon selection; all objects crossing and inside of the specified polygon.
syntax is
(ssget "_CP"  [pt-list] [filter-list])

 

You need to retrieve the vertices of the selected polyline.

Note that objects visible in the drawing area at the time of selection  will be selected

 

HTH

Kent1Cooper
Consultant
Consultant

@calderg1000 wrote:
...
(setq p_list(entget(car(entsel"\nSelect the LwPolyline: "))))
(setq s (sssetfirst nil (ssget "_wp" (list p_list))))

That feeds the entire entity data list for the Polyline into the (ssget) function for a window polygon, but it can't take that -- it needs a list of points only.

 

Command: (setq s (sssetfirst nil (ssget "_wp" (list p_list))))
; error: bad list of points

Kent Cooper, AIA
0 Likes

calderg1000
Mentor
Mentor

Dear @Kent1Cooper 

It's true, although my intention was just to give the OP an idea, to start. But surely I should have been much more explicit. Here is the complete code that allows the selection of objects inside a polygon (Lwpolyline)

(defun c:SelW (/ p_list p_coord)
  (setq p_list (entget (car (entsel "\nSelect the LwPolyline: "))))
  (if (setq
        p_coord (mapcar 'cdr
                        (vl-remove-if-not '(lambda (x) (= (car x) 10)) p_list)
                )
      )
    (sssetfirst nil (ssget "_wp" p_coord))
  )
)

 

 


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

hosneyalaa
Advisor
Advisor

 

Hi
Please- maybe get further help,
upload such sample.dwg

 

0 Likes

_Tharwat
Advisor
Advisor

What's if a user missed to select any object, what would happen ?

Of course an error message will be printed on command line and what's more it will break up the routine.

 

Again suppose a user picked another object which is does not have DXF 10 , what will happen ?

I will leave this answer for you.

 

Besides all of the above, the object(s) must be visible in current screen limits as @pbejse announced earlier. 😉

0 Likes

Sea-Haven
Mentor
Mentor

To make sure pick a pline can use this idea use ssget with E: option but also (0 . "LWPOLYLINE") as a filter it will then ignore a pick wrong object. You then use (ssname ss 0) to get pline object back out of the selection. Wrap it in a while to make sure correct pick.

 

(setq ss (ssget "_+.:E:S" '((0 . "LWPOLYLINE")))) I selected a line
Select entities: nil 

(setq ss  (ssget "_+.:E:S" '((0 . "LWPOLYLINE")))) I selected a pline
Select entities:<Selection set: 0000000068F17D70>

(setq ent (entget  (ssname ss 0)))

(setq ent (entget (ssname ss 0)))
((-1 . <Entity name: 68f15230>) (0 . "LWPOLYLINE") (5 . "11C49") (330 . <Entity name: 3eecdcb0>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "DEFAULT") (370 . -1) (100 . "AcDbPolyline") (90 . 3) (70 . 0) (43 . 0.0) (38 . 0.0) (39 . 0.0) (10 0.8 -9.8) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 1.93319257450986 -2.89233218885884) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (10 11.2740839009524 -3.94482885279246) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (210 0.0 0.0 1.0))

 

 

 

0 Likes