PDA

View Full Version : Using a polyline as a selection window/fence area


ReachAndre
2007-03-12, 08:25 PM
Hello all,
so I thought of this and would like to figure it out, could definately use some help.
I am trying to use a polyline (which is already created) as a window for selecting objects.
Here is a quick draft of what I am trying to do, this does not work, but hopefully it explains what I am trying to do.

(defun c:pselection ()
(if
(= (Select polyline here)"");select polyline for window
(c:pline)
);Create pline if one is not selected
(setq newselset (Select all unlocked items within polyline boundaries))
(command "select" newselset "" "");make selection "previous"
(princ)
)

has anybody done anything like this already? I think it woudl be awfully useful. Open to suggestions, criticisms and pretty much anything else there is.

tyshofner
2007-03-12, 09:03 PM
Hello,

Here is an example of what you want:


(setq e_bound (car (entsel "\nSelect closed polyline boundary: ")));Select Polyline
(foreach dp (entget e_bound) (if (= (car dp) 10) (setq pnt_lst (append pnt_lst (list (cdr dp))))));Build point list
(setq ss (ssget "F" (append pnt_lst (list (car pnt_lst)))));Create selection set


**edit**
Noticed I was filtering for blocks when creating the selection set, so I removed the filter.
**edit**

By chance are you working on THIS (http://forums.augi.com/showthread.php?t=55056) request?

I saw this post as well and thought it was an intseresting idea. I started to work on a routine, got it to erase the objects, but then decided I wanted to add some more functionality to it. So at the moment the routine is in a non-functional (or postable) state. I've pretty much got it done though so I'll try to finish it up and post it today or tomorrow, but for now the above code should help you out.

Ty :mrgreen:

ReachAndre
2007-03-12, 10:16 PM
I was not working on that request, I thought erase with fence worked for what they were asking. I was just thinking about how this would be awfully useful. Just copied down your code, will try it momentarily.
Thanks,
Andre

.T.
2007-03-12, 11:56 PM
For this part:


(if
(= (Select polyline here)"");select polyline for window
(c:pline)
);Create pline if one is not selected


Maybe something like:

(defun c:test ()
(if (setq ent (entsel "\nSelect pline or <Enter> to create one: "))
(setq ent (entget ent))
(progn
(command "pline")
(while (not (zerop (getvar "cmdactive")))
(command pause)
)
(setq ent (entget (entlast)))
)
)
;do the rest of your stuff...
(princ)
)

.T.
2007-03-13, 07:39 AM
Or maybe:

(defun c:test (/ ent ocmd)
(while (not ent)
(if (setq ent (entsel "\nSelect pline or <Enter> to create one: "))
(setq ent (entget (car ent)))
(progn
(setq ocmd (getvar "cmdecho"))
(setvar "cmdecho" 1)
(command "pline")
(while (not (zerop (getvar "cmdactive")))
(command pause)
)
(setq ent (entget (entlast)))
(setvar "cmdecho" ocmd)
)
)
(if (not (wcmatch (cdr (assoc 0 ent)) "*POLYLINE"))
(progn
(setq ent nil)
(princ "\nNot a polyline. Try again. ")
)
)
)
;now you have the pline data to do the rest of your stuff...
(princ)
)