mrmanagerr Posted March 30, 2011 Share Posted March 30, 2011 Im practicing for my CAD certification test and im trying to select all objects inclosed in a poly line. Right now i have a bunch of random circles and a random figure drawn in the middle of a bunch of circles. How do i select ONLY the circles that are completely in the object?? P.S. I would add a picture but i dont know how to take a screenshot on windows xp. Quote Link to comment Share on other sites More sharing options...
Jack_O'neill Posted March 30, 2011 Share Posted March 30, 2011 Much depends on exactly what you are trying to accomplish. Are you selecting these things manually, or trying to write a lisp routine that selects only circles? If you are doing just with your mouse, then obviously you can go round and pick the ones you want. Alternately, you can drag a window or crossing around the area where the circles are, then deselect the stuff you don't want. You can put the circles on thier own layer, and freeze the layers the other objects are on. They'll disappear when you do that, leaving only the circles behind. There are probably a hundred other ways to do it too. To take a screen shot, hit the "prt scrn" button just to the right of the F12 key. That will capture everything on your screen (or both screens if you have dual monitors) to your windows clipboard. Then you can open Paint or your favorite photo editor, paste it in and crop out anything you don't wish to share. This will have the advantage of making the file smaller too. Then save it as a JPG with a name you can remember. Sounds more complicated than it really is. After you've done it a couple times, it will be easy. Quote Link to comment Share on other sites More sharing options...
nestly Posted March 30, 2011 Share Posted March 30, 2011 One method would be to use SELECT with the WPolygon option to select all the objects completely within the polygon boundary, then while those objects are still selected, start QSELECT and filter only for circles. Here's a demo. http://screencast.com/t/5LE7obOkK Quote Link to comment Share on other sites More sharing options...
mrmanagerr Posted March 30, 2011 Author Share Posted March 30, 2011 One method would be to use SELECT with the WPolygon option to select all the objects completely within the polygon boundary, then while those objects are still selected, start QSELECT and filter only for circles. Here's a demo. http://screencast.com/t/5LE7obOkK Thats exactly what I needed thanks! Much depends on exactly what you are trying to accomplish. Are you selecting these things manually' date=' or trying to write a lisp routine that selects only circles? If you are doing just with your mouse, then obviously you can go round and pick the ones you want. Alternately, you can drag a window or crossing around the area where the circles are, then deselect the stuff you don't want. You can put the circles on thier own layer, and freeze the layers the other objects are on. They'll disappear when you do that, leaving only the circles behind. There are probably a hundred other ways to do it too. To take a screen shot, hit the "prt scrn" button just to the right of the F12 key. That will capture everything on your screen (or both screens if you have dual monitors) to your windows clipboard. Then you can open Paint or your favorite photo editor, paste it in and crop out anything you don't wish to share. This will have the advantage of making the file smaller too. Then save it as a JPG with a name you can remember. Sounds more complicated than it really is. After you've done it a couple times, it will be easy.[/quote'] Now I know how to take screenshots! Thanks you Both!! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 31, 2011 Share Posted March 31, 2011 Select, WP within polygon, CP crossing polygon, F fence touches object, W window left to right v's right to left Quote Link to comment Share on other sites More sharing options...
designerstuart Posted March 31, 2011 Share Posted March 31, 2011 but there isn't a way to click the object, say, polyline, and have all its contents selected is there?ie. you still have to draw a polygon so if the bounding object is a circle a very long process might be required. jack's answer is true - so many other ways! Quote Link to comment Share on other sites More sharing options...
Jack_O'neill Posted March 31, 2011 Share Posted March 31, 2011 If you get a 100 autocad users in the same room and ask how to do something, you could probably get 90 different ways! Quote Link to comment Share on other sites More sharing options...
alanjt Posted March 31, 2011 Share Posted March 31, 2011 Seemed interesting. Works on Circles, Ellipses and close Polylines... (defun c:SWC (/ _pac add ss i temp i2) ;; Select Within Curve ;; Alan J. Thompson, 03.31.11 (vl-load-com) (defun _pac (e / l v d lst) (setq d (- (setq v (/ (setq l (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e))) 100.)))) (while (< (setq d (+ d v)) l) (setq lst (cons (vlax-curve-getPointAtDist e d) lst)) ) ) (princ "\nSelect closed curves to select object(s) within: ") (if (setq add (ssadd) ss (ssget '((-4 . "<OR") (0 . "CIRCLE,ELLIPSE") (-4 . "<AND") (0 . "*POLYLINE") (-4 . "&=") (70 . 1) (-4 . "AND>") (-4 . "OR>") ) ) ) (progn (repeat (setq i (sslength ss)) (if (setq temp (ssget "_WP" (_pac (ssname ss (setq i (1- i)))))) (repeat (setq i2 (sslength temp)) (ssadd (ssname temp (setq i2 (1- i2))) add)) ) ) (sssetfirst nil add) (ssget "_I") ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
designerstuart Posted March 31, 2011 Share Posted March 31, 2011 great fun alan, thanks. knew it would only be a matter of time before you turned up..... Quote Link to comment Share on other sites More sharing options...
nestly Posted March 31, 2011 Share Posted March 31, 2011 Dang Alan, I wish I could write AutoLISP like that. Probably half the lisps I use were written by you. Quote Link to comment Share on other sites More sharing options...
alanjt Posted March 31, 2011 Share Posted March 31, 2011 Dang Alan, I wish I could write AutoLISP like that. Probably half the lisps I use were written by you. Here's one that will do both, WP (within polygon) and CP (crossing polygon). I had to go a different round that just using "CP" since just bogged the computer down stepping through all the created points (to account for Circles, Ellipses and arcs withing a polyline) and step through a crossing selection set of the bounding box of each selected object and see if it intersected with of the selected objects. (defun c:SWC (/ _pac add ss i e temp it o a b pts tempC i3 ec) ;; Select Within/Crossing Curve ;; Alan J. Thompson, 03.31.11 (vl-load-com) (defun _pac (e / l v d lst) (setq d (- (setq v (/ (setq l (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e))) 100.)))) (while (< (setq d (+ d v)) l) (setq lst (cons (vlax-curve-getPointAtDist e d) lst)) ) ) (initget 0 "Crossing Within") (setq *SWC:Opt* (cond ((getkword (strcat "\nSpecify selection method witin curve [Crossing/Within] <" (cond (*SWC:Opt*) ((setq *SWC:Opt* "Crossing")) ) ">: " ) ) ) (*SWC:Opt*) ) ) (princ "\nSelect closed curves to select object(s) within: ") (if (setq add (ssadd) ss (ssget '((-4 . "<OR") (0 . "CIRCLE,ELLIPSE") (-4 . "<AND") (0 . "*POLYLINE") (-4 . "&=") (70 . 1) (-4 . "AND>") (-4 . "OR>") ) ) ) (progn (repeat (setq i (sslength ss)) (if (setq temp (ssget "_WP" (_pac (setq e (ssname ss (setq i (1- i))))))) (repeat (setq i2 (sslength temp)) (ssadd (ssname temp (setq i2 (1- i2))) add)) ) (if (eq *SWC:Opt* "Crossing") (progn (vla-getboundingbox (setq o (vlax-ename->vla-object e)) 'a 'b) (setq pts (mapcar 'vlax-safearray->list (list a b))) (if (setq tempC (ssget "_C" (list (caar pts) (cadar pts) 0.) (list (caadr pts) (cadadr pts) 0.) ) ) (repeat (setq i3 (sslength tempC)) (if (vlax-invoke o 'Intersectwith (vlax-ename->vla-object (setq ec (ssname tempC (setq i3 (1- i3))))) acExtendNone ) (ssadd ec add) ) ) ) ) ) ) (sssetfirst nil add) (ssget "_I") ) ) (princ) ) I'm sure to get flamed shortly for posting all this code in the beginner area. Quote Link to comment Share on other sites More sharing options...
Vince_Aquarian Posted February 8, 2018 Share Posted February 8, 2018 Hi Alan, I was looking for a similar solution and I found this incredible solution. Could you please add a deselect option too just by clicking a polyline. It goes some thing like this :- So first step : User has the opportunity to select every thing/ or things he wants to select/ or by clicking a polyline to select every thing inside that closed polyline/ or crossing polyline selection. Second step: (User gets the opportunity to deselect any things he is already selected) User has the opportunity to deselect things he wants to deselect/ or by clicking a polyline to deselect every thing inside that closed polyline/ or crossing polyline deselection. May you please include this option too in the routine? Regards, VA Quote Link to comment Share on other sites More sharing options...
Jibby Posted March 25, 2018 Share Posted March 25, 2018 Hi, i know that Alan created a Lisp to select all object in a polygon, but is there a way to select all object within the polygon as well as the polygon. eg: i have a lot of closed Polygons with text inside them and some without text i want to select and move all Polygons that have the text/object inside them including the enclosed text/object. thanks for the help guy/girls Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 26, 2018 Share Posted March 26, 2018 If you look at the selection method it looks for *text within a pline (setq ss (ssget "WP" coordsxy (list (cons 0 "*Text")))), so a simple test if ss is null then dont move pline. This is a variation on Alans code only uses vertices. It is an example as it was written to the poster request. ; Text in polygons ; By Alan H may 2013 (vl-load-com) (defun getcoords (ent) (vlax-safearray->list (vlax-variant-value (vlax-get-property (vlax-ename->vla-object ent) "Coordinates" ) ) ) ) (defun co-ords2xy () ; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z (setq numb (/ (length co-ords) 2)) (setq I 0) (repeat numb (setq xy (list (nth I co-ords)(nth (+ I 1) co-ords) )) (setq coordsxy (cons xy coordsxy)) (setq I (+ I 2)) ) ; end repeat ) ; end defun ; program starts here ; choose output file change acdatemp to what you want (setq fname (strcat "c:/alan/" (getstring "\nEnter file name "))) (setq fout (open fname "w")) (setq plobjs (ssget (list (cons 0 "lwpolyline")))) (setq numb1 (sslength plobjs)) (setq x numb1) (repeat numb1 (setq obj (ssname plobjs (setq x (- x 1)))) (setq co-ords (getcoords obj)) (co-ords2xy) ; write pline co-ords here (setq numb3 (length co-ords)) (setq z numb3) (setq ansco-ords "") (repeat numb3 (setq ansco-ords (strcat ansco-ords (rtos (nth (setq z (- z 1)) co-ords) 2 3 ) " " )) ) (setq ans (strcat "Pline " ansco-ords)) (write-line ans fout) (setq ansco-ords "") (setq ss (ssget "WP" coordsxy (list (cons 0 "Text,Mtext")))) ; selection set of text within polygon (if (= ss nil) (princ "\nnothing inside") (progn (setq coordsxy nil) ; reset for next time (setq numb2 (sslength ss)) (setq y numb2) (repeat numb2 (setq anstext (vlax-get-property (vlax-ename->vla-object (ssname ss (setq y (- y 1)))) "Textstring")) (princ anstext) ; change to write text to file (write-line (strcat "text " anstext) fout) (princ "\n") ) ; end repeat2 (setq ss nil) ; reset for next poly ) ) ) ; end repeat1 (close fout) (princ) Quote Link to comment Share on other sites More sharing options...
Keyhylyn Posted March 13, 2019 Share Posted March 13, 2019 Hello, i have autocad 2017 on mac os and it seems it can't load vl-load-com...thus the lisp above don't work for me... Is there a lisp to select all objects within and crossing a closed polyline that could work on a mac? Thank you!! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 13, 2019 Share Posted March 13, 2019 (edited) There is a entget method of getting the pline co-ords its actually less lines than my VL method I thought I had it saved it uses the entnext assoc 10 which is the points. Wrote this give it a try. Refer to other posts use these co-ords in the "WP" option ; Pline co-ord points ;By Alan H March 2019 (defun AH:PLCORDS ( / ent subent 3d pts pnt ptlst) (setq ent (entget (car (entsel "Pick pline")))) (if (= (cdr (assoc 0 ent)) "LWPOLYLINE")(princ)(setq 3d "Y")) (setq ptlst '()) (foreach subent ent (if (= (car subent) 10) (progn (setq pnt (cdr subent)) (setq pts (strcat (rtos (car pnt) 2 3) "," (rtos (cadr pnt) 2 3))) (if (= 3d "Y") (setq pts (strcat pts ","(rtos (cadr pnt) 2 3))) ) (setq ptlst (cons pts ptlst)) ) ) ) (princ ptlst) ) ; example calling (setq co-ords (AH:PLCORDS)) Edited March 13, 2019 by BIGAL Quote Link to comment Share on other sites More sharing options...
cad&cnc Posted February 11, 2020 Share Posted February 11, 2020 Looking for the above routine (select all objects within polyline) in vba. Anybody have anything like that. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 12, 2020 Share Posted February 12, 2020 Just rewrite using methods in code examples. There are VBA examples for ssget etc just goggle. Quote Link to comment Share on other sites More sharing options...
Dhammike Posted April 25, 2020 Share Posted April 25, 2020 ("426778.706,511487.183" "426778.706,511487.183" "426778.112,511487.971" "426772.443,511496.941" "426776.979,511499.830" "426787.010,511505.902" "426793.976,511509.940" "426798.865,511503.555" "426800.713,511499.200") I got above list of coordinate for polygon . Now i want use this coordinate list with ssget "WP" function. How can i use it. I want select objects within that polygon. i used below command. (setq ss4 (ssget "_WP" coords (list (cons 0 "*Text")))) i got error message.; error: too many arguments If any one can solve this problem. Thanks in advance Dhammike Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 25, 2020 Share Posted April 25, 2020 Your coordinates are not considered points in AutoLISP, but rather just lists of literal strings - the point list argument supplied to ssget when using a selection mode such as Window Polygon will need to be a list of lists, in which each sublist contains 2 or 3 numerical values representing the X, Y & Z coordinates, e.g.: '((426778.706 511487.183) (426778.706 511487.183) (426778.112 511487.971) ... ) You'll therefore need to transform your current list into this format, perhaps using something like the following: (mapcar '(lambda ( x ) (read (strcat "(" (vl-string-translate "," " " x) ")"))) lst) Though, there are many other ways to achieve the same. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.