building a selection set using the pline is another animal.
While this can be a bit tricky it is not real difficult. For example, using straight lisp, you can select any object or group of objects using
;window polygon
;all objects in a window
(ssget "_wp" pline_vertice_list)
or
;crossing polygon
;all objects crossed by and in the polygon
(ssget "_cp" pline_vertice_list)
Now to obtain the points, you need to get the DXF code 10 of all of the vertices. If you are using LWPolylines then this is a snap, if you are using regular polylines then it is a bit more coding.
Either way, you can take your pick.
;select a lwpolyline and put the entity data in a list
(setq lwpolyline_data_list (entget (car (entsel "\nSelect lwpolyline: "))))
;as long as there is another point in the data list
(while (setq point (member (assoc 10 lwpolyline_data_list)))
;add the point to the vertice list
(setq pline_vertice_list (append pline_vertice_list (list (cdr (assoc 10 point)))))
;then decrement the list so we don't get the same point twice
(setq lwpolyline_data_list (cdr lwpolyline_data_list))
)
or
;select a polyline and put the entity data in a list
(setq pline_data_list (entget (car (entsel "\nSelect polyline: "))))
;as long as we have not reached the end of the complex polyline object
(while (/= (cdr (assoc 0 pline_data_list)) "SEQEND")
;grab the point data of the vertice
(setq pline_vertice_list (append_pline_vertice_list (list (cdr (assoc 10 pline_data_list)))))
;then find the next entry in the complex polyline
(setq pline_data_list (entget (entnext (cdr (assoc -1 pline_data_list)))))
Now, you can select the pline, and select objects within the pline window.
Now you want to create a layer, you can simply entmake one, but instead of using a whole list of the data, lets just create one from an existing layer, like perhaps 0 since we always have one anyway.
;grab layer 0 data
(setq layer_list (entget (tblobjname "layer" "0")))
;recreate a list with a text layer
(setq layer_list (subst (cons 2 "NEWLAYERNAME")(assoc 2 layer_list) layer_list))
;now lets turn the layer off
(setq layer_list (subst (cons 62 (- 0 (abs(cdr (assoc 62 layer_list)))))(assoc 62 layer_list) layer_list))
;now lets actually create it
(entmake layer_list)
Of course there are other much simpler ways to create a layer, but by using this method, you become more familiar with HOW to modify the layer tables with pure lisp instead of relying strictly on the "command" interface.
Now I have added a few comments to let you know what happens in each of the different segments as well as giving some idea about how to go about building such a routine as you request.
In fact, I think that since I have made this little bit of code, I will post a module in the "show your stuff" section that will create any layer for you using the data you want as default.
Good luck