Lee Mac Posted March 4, 2009 Posted March 4, 2009 I recently posted a code in a separate thread which utilised the "sssetfirst" command to highlight the selection set upon completion of the LISP. However, when the LISP is re-invoked, it does not prompt for a new selection set and just takes the entities that were selected using sssetfirst previously. I don't fully understand sssetfirst, and I'm not sure what I'm doing wrong, but if anyone could offer any insight into this I would be very grateful Thanks Lee PS> link to other thread containing posted code: http://www.cadtutor.net/forum/showpost.php?p=218783&postcount=5 Quote
ReMark Posted March 4, 2009 Posted March 4, 2009 Lee cracked the 2K barrier and its been what, almost 7 months? Smokin! You da man! Quote
CarlB Posted March 4, 2009 Posted March 4, 2009 -So what is that code supposed to do? I ran "test" a few times and it does prompt for a selection each time. --ok if any items are highlighted/gripped, it does not prompt for a selection. And for some reason it doesn't always show that there is a "pickset" so you have to hit 'regen' to see grips then 'esc' to clear them, then running "test" prompts you. Quote
Lee Mac Posted March 4, 2009 Author Posted March 4, 2009 Its meant to select the inverse of the selection set created by the user when prompted. This seems to work for the first time, but not after that Quote
Lee Mac Posted March 4, 2009 Author Posted March 4, 2009 Lee cracked the 2K barrier and its been what, almost 7 months? Smokin! You da man! Thanks ReMark, I was a little dormant when I first joined, but now I've got into it a bit more Quote
CALCAD Posted March 4, 2009 Posted March 4, 2009 Lee, I think sssetfirst only highlights an existing set. Your selection set 'ss' is left open when your program ends. Don't you just need to set 'ss' nil at the end? Quote
Lee Mac Posted March 4, 2009 Author Posted March 4, 2009 Lee, I think sssetfirst only highlights an existing set. Your selection set 'ss' is left open when your program ends. Don't you just need to set 'ss' nil at the end? I thought that by localising the variable ss, I was setting it to nil anyway.. :wink: Quote
uddfl Posted March 4, 2009 Posted March 4, 2009 Correct me if I'm wrong, but wouldn't the behavior of the function vary according to the variable PICKFIRST? Quote
CarlB Posted March 4, 2009 Posted March 4, 2009 Lee - if items are highlighted (ssget) will select those and will not prompt user.. Quote
Lee Mac Posted March 4, 2009 Author Posted March 4, 2009 Ahh, thanks Carl, So I will have to add a line to "unhighlight" the selection set before invoking the ssget function. Quote
Lee Mac Posted March 4, 2009 Author Posted March 4, 2009 Ok, so I have this now: (defun c:test (/ ss i elst invss) (sssetfirst nil nil) (setq ss (ssget) i (sslength ss) elst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) invss (ssget "X" (list (cons 410 (getvar "CTAB"))))) (while (not (minusp (setq i (1- i)))) (if (member (cdar (entget (ssname invss i))) elst) (ssdel (ssname invss i) invss))) (sssetfirst nil invss) (princ)) But it still seems very temperamental, and I can't see what could be going wrong. Quote
ASMI Posted March 4, 2009 Posted March 4, 2009 So I will have to add a line to "unhighlight" the selection set before invoking the ssget function. (sssetfirst nil nil) *** EDIT *** Oops. You already have found it. Quote
Lee Mac Posted March 4, 2009 Author Posted March 4, 2009 Thanks ASMI, but can you explain why the LISP sometimes works and sometimes doesnt? It seems quite temperamental Quote
wizman Posted March 5, 2009 Posted March 5, 2009 im not sure i understand your goal here lee, but maybe this: (defun c:test (/ elst i invss ss) (sssetfirst nil nil) ;; above same with (command "_.select" "_r" "_all" "") (setq ss (ssget) i (sslength ss) elst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) invss (ssget "X" (list (cons 410 (getvar "CTAB")))) ) ;_ end_setq (while (not (minusp (setq i (1- i)))) (ssdel (ssname ss i) invss) ) ;_ end_while ;; another way to write ;;(sssetfirst nil invss) (apply 'sssetfirst (list nil invss)) (princ) ) ;_ end_defun Quote
Lee Mac Posted March 5, 2009 Author Posted March 5, 2009 Thanks Wizman, Your code has demonstrated new ways of accomplishing certain tasks - thank you. It just so happens that I had completely forgotton one function that would be ideal for such a situation - luckily CAB did not... Thanks once again, Lee Quote
wizman Posted March 5, 2009 Posted March 5, 2009 Lee cracked the 2K barrier and its been what, almost 7 months? Smokin! You da man! =lee' you,re welcome' what a remarkable feat you have there= Quote
Lee Mac Posted March 5, 2009 Author Posted March 5, 2009 =lee' you,re welcome' what a remarkable feat you have there= Thanks Wizman Quote
Andrew@HOB Posted August 8, 2019 Posted August 8, 2019 About a decade late to the game, but through my recent web queries, I still was not able to find a tried and true solution to the finicky sssetfirst. Luckily, through trial and error, I was able to find a solution. It seems that when using sssetfirst with an active selection (ssget "_I") etc, sssetfirst would always return the processed selection set. However, when allowing a user to provide a selection, sssetfirst would not return the selection until a new selection was started. I tried many variations on PICKADD, clearing the active selection with (sssetfirst nil nil), and many other things. The bandaid that I found, which is completely baffling, was to issue (princ) prior to (sssetfirst nil ss). (defun c:dd (/ ss cc en) (setq ss (ssget '((0 . "LINE"))) cc (sslength ss)) (while (not (minusp (setq cc (1- cc)))) (setq en (ssname ss cc)) (if (minusp (car (cdr (assoc 10 (entget en))))) (setq ss (ssdel en ss)) ) ) (princ) ; This princ was added to allow sssetfirst to return the selection on screen (sssetfirst nil ss) (princ) ) 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.