claire2017 Posted August 15, 2018 Share Posted August 15, 2018 Hi, Does anyone know how to select multiple polylines so autocad automatically selects both the polylines themselves and all the objects inside them (in this case circles and text). I've found this - wsp.lsp which selects objects within the polyline but will only let you select one polyline at a time and also doesn't select the polyline itself. I don't really know much about lsp files apart from how to copy and paste them and know nothing about VBA! Have attached the lsp and an image of what i'm trying to do. Thanks in advance, Claire wps.lsp Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 15, 2018 Share Posted August 15, 2018 This is very close to what you want posted here a while ago now. (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:/acadtemp/" (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...
claire2017 Posted August 15, 2018 Author Share Posted August 15, 2018 Thanks Bigal. Please exuse my lack of knowledge, but I'm not sure how to work this. So I copy and save as a lsp? Then how do I run the command? Quote Link to comment Share on other sites More sharing options...
claire2017 Posted August 15, 2018 Author Share Posted August 15, 2018 I worked that out but for some reason it will only let me type it in once and the next time i run it it comes up as unknown command. When it does run and i select the polyline it comes up with this... Select objects: Pline -76192.494 18343.941 -75964.185 18343.941 -76205.790 17768.383 -76434.099 17768.383 nothing inside; error: bad argument type: streamp nil Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 24, 2018 Share Posted August 24, 2018 The example writes out the answers to a file that is located in a known directory c:\Acadtemp and works ! You did not sya what you want to do with the text found. For cadtutor when I copied and pasted the code to vlide hidden characters pooped up in particular "?" this caused errors when I went to run. Not sure if its something to do with Notepad++ any way code reposted. (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:/acadtemp/" (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...
claire2017 Posted August 24, 2018 Author Share Posted August 24, 2018 Thanks for your reply BigAl, I actually ended up finding someone to modify the wps lisp & it works perfectly! ;;Polyline/circle select - www.cadstudio.cz - www.cadforum.cz ;;(use the WPS command or 'WPS inside an object selection prompt) (defun C:WPS (/ i elist at cmde cen rad p1 impl) (setq cmde (getvar "cmdecho")) (setvar "cmdecho" 0) (prompt "\nSelect the bounding circles and polylines: ") (setq ss (ssget '((-4 . "<OR") (0 . "CIRCLE") (0 . "LWPOLYLINE") (-4 . "OR>") ) ) ) (setq cou (sSLENGTH ss) re 0 ) (repeat cou (setq elist (entget (ssname ss re)) i 0 ) (setvar "OSMODE" (boole 7 (getvar "OSMODE") 16384)) (if (zerop (getvar "CMDACTIVE")) (progn (setq impl T) (command "_select")) ) (command "_wp") ; or _CP (if (= (cdr (assoc 0 elist)) "CIRCLE") (progn (setq cen (cdr (assoc 10 elist)) rad (cdr (assoc 40 elist)) ) (repeat 90 ; 360/4 0.06981317=4*pi/180 (setq p1 (polar cen (* i 0.06981317) rad) i (1+ i) ) ; (command "_POINT" (trans p1 0 1)) (command (trans p1 0 1)) ) ) ; else (repeat (length elist) (setq at (nth i elist) i (1+ i) ) ; (if (= (car at) 10) (command (cdr at))) (if (= (car at) 10) (command (trans (cdr at) 0 1)) ) ) ) ;if CIRCLE (command "") (setvar "OSMODE" (boole 2 (getvar "OSMODE") 16384)) (setvar "cmdecho" cmde) (setq re (1+ re)) ) (if impl (progn (command "") (setq c 0) (setq sp (ssget "_P")) (repeat (sslength sp) (ssadd (ssname sp c) ss) (setq c (1+ c)) ) (sssetfirst nil ss) ) ) (initget "Yes No") (if (= (getkword "\nDo you want to GROUP this set? Yes/<No> :") "Yes" ) (progn (command ".-group" "c" "*" "group_desc" ss "") (sssetfirst nil ss) ) ) (princ) ) wpsmodified.lsp Quote Link to comment Share on other sites More sharing options...
Metachik Posted September 22, 2018 Share Posted September 22, 2018 My answer is not a lisp routine...but you might not know this quick way to select a group...I'm thinking maybe you are clicking on 6 individual items in turn; one polyline, one number and the 4 circles inside the polyline, individually. Well, those 6 clicks can be reduced to 2 like this....how to click to highlight as much as possible in one swoop; click in the top right corner and drag to bottom left, the highlighter box goes green. This green box picks up everything within it in one stroke, including things partially within the green. So stretching it over just as far as this (see first image below) will select the polyline and everything that is within it except for the one bottom left circle (see the second image) which you can just click on to add to the selection. This leaves everything outside of the polyline unselected So if you can reduce your 6 selects down to just 2 On this occasion make sure you don't to highlight in the opposite direction, from the bottom left corner upwards to top right; because you'll get a blue highlighter box, which will pick up less, it will only pick up the whole items within it, so (in the 3rd image, see below) you'll see in one stroke it won't pick up the polyline, it'll just pick up 3 circles and the number in one swoop. So you'll only be halving your selects down to 3. Good luck and hope someone can give you a lisp routine to get it down to just one select!! Quote Link to comment Share on other sites More sharing options...
claire2017 Posted September 22, 2018 Author Share Posted September 22, 2018 Thanks Metachik, I maybe didn't use a good image to post, in reality the chevron shape is surrounded by a bunch of other shapes that are in the way of the selection square. I did find a lisp that does the trick though - posted above. 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.