Ahankhah Posted October 1, 2011 Posted October 1, 2011 Hi friends, is it possible to add behaviors defined by (initget) function to (ssget) (As most of you know, it is possible for other input functions such as (entsel), (entselp), (getpoint), ...) An example is like this: Command: mycommand Select objects, or [by Style/by Layer/by Color/...]: s Select text object to get its style: . . . I appreciate any help Quote
Lee Mac Posted October 1, 2011 Posted October 1, 2011 You cannot use the initget function with ssget. Only the following functions can be used with initget: getint, getreal, getdist, getangle, getorient, getpoint, getcorner, getkword, entsel, nentsel, nentselp. Quote
pBe Posted October 1, 2011 Posted October 1, 2011 (edited) Try something like this: (defun c:test (/ Prcd gr Npt Mode Par ) (prompt "\nSelect objects, or [by Style/by Layer/by Color/...]:") (while (null Prcd) (setq gr (grread nil 4 2) Mode (car gr)) (cond ((= 3 Mode) (princ "\nSelect Mode") (setq Objects (ssget "_C" (cadr gr) (setq Npt (Getcorner (cadr gr) "\nOther Corner:")))) (foreach mp (vl-remove-if 'listp (mapcar 'cadr(ssnamex Objects))) (redraw mp 3)) (setq Prcd T)) ((and (= 2 Mode) (setq Par (member (cAdr gr) '(67 76 83 99 108 115)))) (princ (strcat "\nYou Pressed " (chr (car Par)))) (setq Prcd T)) ) ) (princ) ) I leave the rest to your imagination HTH Edited October 1, 2011 by pBe Replace sssetfirst with redraw Quote
GP_ Posted October 1, 2011 Posted October 1, 2011 Also try this. (defun C:TEST () (setq SEL (ssadd)) (initget "S L C") (setq a (entsel "\nSelect objects, or by [style/Layer/Color]...:")) (if (= a "S") (progn ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ) ) (if (= a "L") (progn ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ) ) (if (= a "S") (progn ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ) ) (if (and (/= a nil)(/= a "S")(/= a "L")(/= a "C")) (progn (setq SEL (ssadd (car a) SEL)) (command "_select" SEL pause) (setq SEL (ssget "_P")) ) ) (if (= a nil) (progn (command "_select" "_BOX" (cadr (grread T)) pause) (setq SEL (ssget "_P")) ) ) ) 1 Quote
Ahankhah Posted October 1, 2011 Author Posted October 1, 2011 You cannot use the initget function with ssget. Only the following functions can be used with initget: getint, getreal, getdist, getangle, getorient, getpoint, getcorner, getkword, entsel, nentsel, nentselp. You are right Lee, but I am seeking a way to imitate initget for ssget. Quote
Ahankhah Posted October 1, 2011 Author Posted October 1, 2011 Also try this. (defun C:TEST () (setq SEL (ssadd)) (initget "S L C") (setq a (entsel "\nSelect objects, or by [style/Layer/Color]...:")) (if (= a "S") (progn ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ) ) (if (= a "L") (progn ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ) ) (if (= a "S") (progn ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ) ) (if (and (/= a nil)(/= a "S")(/= a "L")(/= a "C")) (progn (setq SEL (ssadd (car a) SEL)) (command "_select" SEL pause) (setq SEL (ssget "_P")) ) ) (if (= a nil) (progn (command "_select" "_BOX" (cadr (grread T)) pause) (setq SEL (ssget "_P")) ) ) ) Thank you GP_ for your reply, but has no options like Implied Windowing, etc. Quote
Lee Mac Posted October 1, 2011 Posted October 1, 2011 but I am seeking a way to imitate initget for ssget. Attached is an old program of mine, an attempt to create a UCS-Aligned ssget function, it could be modified to add extra options. Lee UCS-ssget.lsp Quote
GP_ Posted October 1, 2011 Posted October 1, 2011 ...but has no options like Implied Windowing, etc. You want the egg and the hen. (defun C:TEST (/ a b option) (setq SEL (ssadd)) (initget "? ST LA CO W L C B ALL F WP CP G A R M P U AU SI SU O") (setq a (entsel "\nSelect objects, or by [sTyle/LAyer/COlor]...: ")) (if (= a "?") (progn (setq b nil) (while (not (member b (list "W" "L" "C" "B" "BOX" "ALL" "F" "WP" "CP" "G" "A" "R" "M" "P" "U" "AU" "SI" "SU" "O"))) (prompt "Expects a point or" ) (prompt "\nWindow/Last/Crossing/BOX/ALL/Fence/WPolygon/") (prompt "CPolygon/Group/Add/Remove/Multiple/Previous/") (prompt "Undo/AUto/SIngle/SUbobject/Object ") (prompt "\nSelect objects:" ) (setq b (strcase (getstring))) (if (= b nil) (exit)) ) (setq a b) ) ) (if (= a "ST") (progn ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ) ) (if (= a "LA") (progn ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ) ) (if (= a "CO") (progn ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ) ) (if (and (/= a nil) (not (member a (list "?" "ST" "LA" "CO" "W" "L" "C" "B" "BOX" "ALL" "F" "WP" "CP" "G" "A" "R" "M" "P" "U" "AU" "SI" "SU" "O") ) ) ) (progn (setq SEL (ssadd (car a) SEL)) (command "_select" SEL pause) (setq SEL (ssget "_P")) ) ) (if (= a nil) (progn (command "_select" "_BOX" (cadr (grread T)) pause) (setq SEL (ssget "_P")) ) ) (if (member a (list "W" "L" "C" "B" "BOX" "ALL" "F" "WP" "CP" "G" "A" "R" "M" "P" "U" "AU" "SI" "SU" "O")) (progn (setq option (strcat "_" a)) (command "_select" option pause) (setq SEL (ssget "_P")) ) ) ) Quote
Ahankhah Posted October 2, 2011 Author Posted October 2, 2011 Attached is an old program of mine, an attempt to create a UCS-Aligned ssget function, it could be modified to add extra options. Lee It is fine Lee. Your brain is a treasure, thank you very much Quote
Ahankhah Posted October 2, 2011 Author Posted October 2, 2011 You want the egg and the hen. (defun C:TEST (/ a b option) (setq SEL (ssadd)) (initget "? ST LA CO W L C B ALL F WP CP G A R M P U AU SI SU O") (setq a (entsel "\nSelect objects, or by [sTyle/LAyer/COlor]...: ")) (if (= a "?") (progn (setq b nil) (while (not (member b (list "W" "L" "C" "B" "BOX" "ALL" "F" "WP" "CP" "G" "A" "R" "M" "P" "U" "AU" "SI" "SU" "O"))) (prompt "Expects a point or" ) (prompt "\nWindow/Last/Crossing/BOX/ALL/Fence/WPolygon/") (prompt "CPolygon/Group/Add/Remove/Multiple/Previous/") (prompt "Undo/AUto/SIngle/SUbobject/Object ") (prompt "\nSelect objects:" ) (setq b (strcase (getstring))) (if (= b nil) (exit)) ) (setq a b) ) ) (if (= a "ST") (progn ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ) ) (if (= a "LA") (progn ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ) ) (if (= a "CO") (progn ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ) ) (if (and (/= a nil) (not (member a (list "?" "ST" "LA" "CO" "W" "L" "C" "B" "BOX" "ALL" "F" "WP" "CP" "G" "A" "R" "M" "P" "U" "AU" "SI" "SU" "O") ) ) ) (progn (setq SEL (ssadd (car a) SEL)) (command "_select" SEL pause) (setq SEL (ssget "_P")) ) ) (if (= a nil) (progn (command "_select" "_BOX" (cadr (grread T)) pause) (setq SEL (ssget "_P")) ) ) (if (member a (list "W" "L" "C" "B" "BOX" "ALL" "F" "WP" "CP" "G" "A" "R" "M" "P" "U" "AU" "SI" "SU" "O")) (progn (setq option (strcat "_" a)) (command "_select" option pause) (setq SEL (ssget "_P")) ) ) ) GP_, thank you very much. Your code is a great help Quote
Ahankhah Posted October 2, 2011 Author Posted October 2, 2011 You want the egg and the hen. A nice statement. We say in Persian: You want both the God and the date. Quote
pBe Posted October 2, 2011 Posted October 2, 2011 This is as close as i can get with implied selections (defun c:test (/ Prcd gr Npt Mode Par ) (prompt "\nSelect objects, or [by Style/by Layer/by Color/...]:") (while (null Prcd) (setq gr (grread nil 4 2) Mode (car gr)) (cond ((= 3 Mode) (princ "\nSelect Mode") (initget 32) (setq Npt (Getcorner (cadr gr) "\nOther Corner:")) (setq Objects (ssget (if (< (car (cadr gr))(car Npt)) "_W" "_C") (cadr gr) npt )) (foreach mp (vl-remove-if 'listp (mapcar 'cadr(ssnamex Objects))) (redraw mp 3)) (setq Prcd T)) ((and (= 2 Mode) (setq Par (member (cAdr gr) '(67 76 83 99 108 115)))) (princ (strcat "\nYou Pressed " (chr (car Par)))) (setq Prcd T)) ) ) (princ) ) Hope this helps Quote
Ahankhah Posted October 2, 2011 Author Posted October 2, 2011 This is as close as i can get with implied selections (defun c:test (/ Prcd gr Npt Mode Par ) (prompt "\nSelect objects, or [by Style/by Layer/by Color/...]:") (while (null Prcd) (setq gr (grread nil 4 2) Mode (car gr)) (cond ((= 3 Mode) (princ "\nSelect Mode") (initget 32) (setq Npt (Getcorner (cadr gr) "\nOther Corner:")) (setq Objects (ssget (if (< (car (cadr gr))(car Npt)) "_W" "_C") (cadr gr) npt )) (foreach mp (vl-remove-if 'listp (mapcar 'cadr(ssnamex Objects))) (redraw mp 3)) (setq Prcd T)) ((and (= 2 Mode) (setq Par (member (cAdr gr) '(67 76 83 99 108 115)))) (princ (strcat "\nYou Pressed " (chr (car Par)))) (setq Prcd T)) ) ) (princ) ) Hope this helps pBe, your great help is appreciated. Thank you very much. Quote
pBe Posted October 2, 2011 Posted October 2, 2011 You are welcome Ahankhah. I'm sure you'll figure out the rest like error trapping and the like. Quote
Lee Mac Posted October 2, 2011 Posted October 2, 2011 It is fine Lee. Your brain is a treasure, thank you very much Thanks Mehrdad, I hope it helps you towards your goal. Quote
GP_ Posted October 2, 2011 Posted October 2, 2011 GP_, thank you very much. Your code is a great help You're welcome. Quote
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.