Roy_043 Posted September 26, 2016 Share Posted September 26, 2016 (edited) @ Grrr: The undocumented ssget option ":L-I" is new to me. Do you by any chance know if ":L-" can be added to other ssget options (":L-X", ":L-CP" etc.)? BricsCAD also supports (ssget ":L-I" ...). Edited February 23, 2017 by Roy_043 Contrary to what I said before BC does support (ssget "_:L-I" ...) as well as (ssget "_I:L"...). Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted September 26, 2016 Share Posted September 26, 2016 @Roy... No it can't be done, but Kent1Cooper from autodesk forum discovered this example : (if (not (equal (sssetfirst nil (ssget ["_X" or "_A" or "_CP" etc.] [points/pointlist] [filter])) '(nil nil))) (setq ss (ssget "_:L")) ;;; - this works like "-I" Implied method and isolates only unlocked entities from previous (sssetfirst) gripped and selected entities ) Then you can use "ss" variable in any way you want : for ex. (vlax-for x (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))) ... ), or (repeat (setq i (sslength ss)) (setq ent (ssname ss (setq i (1- i)))) ... ) HTH, (It helped me lots of times...) M.R. Quote Link to comment Share on other sites More sharing options...
Grrr Posted September 26, 2016 Share Posted September 26, 2016 Roy, I'm not aware of any of these.. perhaps trial and error would be the answer. By the way for this particular case I have googled that #1 problem you mentioned, and found this thread https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/combining-ssget-selection-methods-implied-not-locked/td-p/3654290 This test also works for me, but I don't have BrisCAD to test on: (defun C:test ( / SS ) (if (setq SS (ssget "_I" )) (progn (setq SS (ssget ":L-P" )) (sssetfirst nil SS) (vla-Regen (vla-get-ActiveDocument (vlax-get-acad-object)) acActiveViewport) ) ) ) Quote Link to comment Share on other sites More sharing options...
alanjt Posted September 26, 2016 Share Posted September 26, 2016 Daaaaaang, I didn't know "_:L-I" existed. Nice. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted September 27, 2016 Share Posted September 27, 2016 @Marko: Thanks for sharing. But there is an issue if all entities are on locked layers. In that case the user will be prompted to make a selection. Your suggestion can be somewhat simplified: (if (cadr (sssetfirst nil (ssget "_X"))) (setq ss (ssget "_:L")) ) @Grrr: Thank you for the additional information. I doubt if ":L-P" works as you expect it to. In BricsCAD using just ":L" works. That may also be the case in AutoCAD. Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted September 27, 2016 Share Posted September 27, 2016 @Roy Nothing else comes to my mind, but this : (alert "If prompted : Select objects: - HIT ENTER") (if (cadr (sssetfirst nil (ssget "_X"))) (setq ss (ssget "_:L")) ) Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted September 27, 2016 Share Posted September 27, 2016 (edited) @Roy, it looks crazy, but on my netbook it worked... (defun ssunlocked ( / cmde ss ) (vl-load-com) (setq cmde (getvar 'cmdecho)) (setvar 'cmdecho 0) (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "_.COMMANDLINE\n") (if (cadr (sssetfirst nil (ssget "_X" '((0 . "CIRCLE"))))) ;;; <- use your preselection (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "(sssetfirst nil (ssget \"_P\"))\n(setq ss (ssget \"_:L\"))\n\n") (setq ss nil) ) (setvar 'cmdecho cmde) ss ) Edited September 28, 2016 by marko_ribar Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted September 28, 2016 Share Posted September 28, 2016 Very creative Marko! But IMO it is too much of a workaround. Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted September 28, 2016 Share Posted September 28, 2016 IMO, even more workaround needed as I updated my previous post... Quote Link to comment Share on other sites More sharing options...
Grrr Posted September 28, 2016 Share Posted September 28, 2016 Roy, here are 2 suggestions of mine: (defun C:test ( / SS e i ) (if (setq SS (ssget "_I")) (progn (sssetfirst nil nil) (repeat (setq i (sslength SS)) (if (= 4 (logand 4 (cdr (assoc 70 (tblsearch "LAYER" (cdr (assoc 8 (entget (setq e (ssname SS (setq i (1- i)))))))))))) (ssdel e SS) ) ) ); progn (setq SS (ssget "_:L")) ); if (if SS (sssetfirst nil SS)) (princ) ); defun (defun c:test ( / acDoc acSS SS ) (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (if (setq SS (ssget)) (progn (vlax-map-collection (setq acSS (vla-get-ActiveSelectionSet acDoc)) (function (lambda (x) (if (= (vla-get-Lock (vla-item (vla-get-Layers acDoc) (vlax-get x 'Layer))) :vlax-true) (ssdel (vlax-vla-object->ename x) SS) ; <- I wanted to go completely with Visual here (using vla-RemoveItems) ) ); lambda ) ); vlax-map-collection (vla-delete acSS) (sssetfirst nil SS) (vla-Regen acDoc acActiveViewport) ); progn ); if acSS (princ) );| defun |; (vl-load-com) (princ) But I think this iteration approach may be obvious for you, so maybe use code like this as a subfunction? Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted September 28, 2016 Share Posted September 28, 2016 Grrr, thanks for an input, but IMHO I think you're missing the point of the problem... The task should be formulated as this : find the simplest way to make standard selection filters work in combination with option to filter entities from unlocked layers... The point is that you may use it in coding situations in any lisp where certain preselection filter was used and you wish to accomplish filtering that filter by making selection set of entities belonging to unlocked layers... So examples like iteration through selection set are not the solution (it takes lots of coding and beside that it's not practical as you may have very large number of entities you need to process through iteration...) Quote Link to comment Share on other sites More sharing options...
Grrr Posted September 28, 2016 Share Posted September 28, 2016 Hi marko, Yes I don't think this is the best solution which I suggested (just wanted to throw it as an option), however apart of the amount of coding I was wondering how (ssget ":L") mode actually works - is it some type of reactor that excludes entities not matching the criteria? otherwise it has to be iteration. What if someone creates a reactor like this ? - only for prompting the SS Quote Link to comment Share on other sites More sharing options...
pvsvprasad Posted September 29, 2016 Author Share Posted September 29, 2016 Give this a shot; Sorry for late reply sir, Your code is exactly working. thank you for sharing. Best regards. Quote Link to comment Share on other sites More sharing options...
pvsvprasad Posted September 29, 2016 Author Share Posted September 29, 2016 Dear Masters, Thank you all for yours great help. Best Wishes. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 29, 2016 Share Posted September 29, 2016 Sorry for late reply sir, Your code is exactly working. thank you for sharing. Best regards. Nice. You are welcome. Quote Link to comment Share on other sites More sharing options...
OMEGA-ThundeR Posted September 29, 2016 Share Posted September 29, 2016 Give this a shot; (defun c:Test ( / len sad sel ) ;; Tharwat - 24.09.16 ;; (if (and (setq len (getdist "\nSpecify Minimum length :")) (princ "\nSelect Lines & Polylines :") (setq sad (ssadd) sel (ssget "_:L" '((0 . "LINE,*POLYLINE")))) ) ((lambda (x / e ) (while (setq e (ssname sel (setq x (1+ x)))) (if (< (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) len) (ssadd e sad)) ) ) -1 ) ) (sssetfirst nil sad) (princ) ) (vl-load-com) Nice code, however, i't would work even better if there was an positive or nagative option (select longer than given lengt or shorter than given length). I'm not so good in Lisp, but trying some minus or plus sign in the equation doesn't seem to do it (not at the positions i place it anyway ). Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 29, 2016 Share Posted September 29, 2016 Nice code, however, i't would work even better if there was an positive or nagative option (select longer than given lengt or shorter than given length). I'm not so good in Lisp, but trying some minus or plus sign in the equation doesn't seem to do it (not at the positions i place it anyway ). Haha it is not that sign but this sign Give this a kick. (defun c:Test ( / len sad sel kwd sgn) ;; Tharwat - 24.09.16 ;; (if (and (setq len (getdist "\nSpecify length :")) (princ "\nSelect Lines & Polylines :") (setq sad (ssadd) sel (ssget "_:L" '((0 . "LINE,*POLYLINE")))) (not (initget 7 "Longer Shoter")) (setq kwd (getkword "\nSpecify [Longer/Shorter] :")) (setq sgn (if (= kwd "Shoter") < >)) ) ((lambda (x / e ) (while (setq e (ssname sel (setq x (1+ x)))) (if (sgn (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) len) (ssadd e sad)) ) ) -1 ) ) (sssetfirst nil sad) (princ) ) (vl-load-com) 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.