rog1n Posted August 24, 2019 Share Posted August 24, 2019 Hello, is possible to make a ssget that the user can only select for example two circles and one polyline? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 24, 2019 Share Posted August 24, 2019 It's possible, but not as part of a single ssget expression - you would need to construct a loop such as: (defun c:test ( / s ) (while (and (setq s (ssget '((0 . "CIRCLE,LWPOLYLINE")))) (or (/= 3 (sslength s)) (vl-some '/= '("CIRCLE" "CIRCLE" "LWPOLYLINE") (acad_strlsort (mapcar '(lambda ( i ) (cdr (assoc 0 (entget (ssname s i))))) '(0 1 2))) ) ) ) (princ "\nPlease select two circles and a polyline.") ) (if s (princ "\nThe user selected two circles and a polyline.") (princ "\nThe user cancelled the selection.") ) (princ) ) 1 Quote Link to comment Share on other sites More sharing options...
rog1n Posted August 24, 2019 Author Share Posted August 24, 2019 19 minutes ago, Lee Mac said: It's possible, but not as part of a single ssget expression - you would need to construct a loop such as: (defun c:test ( / s ) (while (and (setq s (ssget '((0 . "CIRCLE,LWPOLYLINE")))) (or (/= 3 (sslength s)) (vl-some '/= '("CIRCLE" "CIRCLE" "LWPOLYLINE") (acad_strlsort (mapcar '(lambda ( i ) (cdr (assoc 0 (entget (ssname s i))))) '(0 1 2))) ) ) ) (princ "\nPlease select two circles and a polyline.") ) (if s (princ "\nThe user selected two circles and a polyline.") (princ "\nThe user cancelled the selection.") ) (princ) ) Thank you Lee Mac, this exactly I needed. Quote Link to comment Share on other sites More sharing options...
Grrr Posted August 24, 2019 Share Posted August 24, 2019 Just leaving this (I had fun) - ('((L) (vl-every ''((x)(member x L)) '(("LWPOLYLINE" . 1) ("CIRCLE" . 2)))) ('(( f SS ) (if SS (f SS (1- (sslength SS)) nil))) '(( SS i c / itm k ) (if (<= 0 i) (f SS (1- i) (if (setq itm (assoc (setq k (cdr (assoc 0 (entget (ssname SS i))))) c)) (subst ('((itm)(cons (car itm) (1+ (cdr itm)))) itm) itm c) (cons (cons k 1) c) ) ) c ) ) (ssget '((0 . "CIRCLE,LWPOLYLINE"))) ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 24, 2019 Share Posted August 24, 2019 6 hours ago, Grrr said: Just leaving this (I had fun) - ('((L) (vl-every ''((x)(member x L)) '(("LWPOLYLINE" . 1) ("CIRCLE" . 2)))) ('(( f SS ) (if SS (f SS (1- (sslength SS)) nil))) '(( SS i c / itm k ) (if (<= 0 i) (f SS (1- i) (if (setq itm (assoc (setq k (cdr (assoc 0 (entget (ssname SS i))))) c)) (subst ('((itm)(cons (car itm) (1+ (cdr itm)))) itm) itm c) (cons (cons k 1) c) ) ) c ) ) (ssget '((0 . "CIRCLE,LWPOLYLINE"))) ) ) Try selecting other objects in addition to two circles and a polyline Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 24, 2019 Share Posted August 24, 2019 7 hours ago, rog1n said: Thank you Lee Mac, this exactly I needed. You're most welcome 1 Quote Link to comment Share on other sites More sharing options...
Grrr Posted August 25, 2019 Share Posted August 25, 2019 3 hours ago, Lee Mac said: Try selecting other objects in addition to two circles and a polyline Ah, right.. (vl-every ''((x)(member x L)) '(("LWPOLYLINE" . 1) ("CIRCLE" . 2))) should be (and (= 2 (length L)) (vl-every ''((x)(member x L)) '(("LWPOLYLINE" . 1) ("CIRCLE" . 2)))) Or for a better performance, include the check before processing the SS - (if SS (f SS (1- (sslength SS)) nil)) the above must be changed to (if (and SS (= 3 (sslength SS))) (f SS (1- (sslength SS)) nil)) Thanks Lee! Quote Link to comment Share on other sites More sharing options...
David Bethel Posted August 25, 2019 Share Posted August 25, 2019 Maybe : (defun c:test (/ ls cs fs ss i en ed) (setq ls (ssadd) cs (ssadd) fs (ssadd)) (while (/= (sslength fs) 3) (setq fs (ssadd)) (and (princ "\nSelect 2 Lines and 1 Circle: ") (setq ss (ssget '((0 . "LINE,CIRCLE")))) (= (sslength ss) 3) (setq i 0) (while (setq en (ssname ss i)) (setq ed (entget en)) (cond ((= "LINE" (cdr (assoc 0 ed))) (ssadd en ls) (ssadd en fs)) ((= "CIRCLE" (cdr (assoc 0 ed))) (ssadd en cs) (ssadd en fs))) (setq i (1+ i))) (= (sslength ls) 2) (= (sslength cs) 1) fs)) fs) You would need to tweak LINE vs POLYLINE vs LWPOLYLINE -David Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 25, 2019 Share Posted August 25, 2019 (edited) Maybe another way ‘(“circle” “circle” “Polyline”) use the nth and force a check till correct object picked. List can get bigger. On iPad no code. Edited August 25, 2019 by BIGAL 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.