Jump to content

Recommended Posts

Posted

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

Posted

Lee cracked the 2K barrier and its been what, almost 7 months? Smokin! You da man! :)

Posted

-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.

Posted

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 :(

Posted
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 :)

Posted

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?

Posted
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:

Posted

Correct me if I'm wrong, but wouldn't the behavior of the function vary according to the variable PICKFIRST?

Posted

Lee - if items are highlighted (ssget) will select those and will not prompt user..

Posted

Ahh, thanks Carl,

 

So I will have to add a line to "unhighlight" the selection set before invoking the ssget function.

Posted

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. :(

Posted
So I will have to add a line to "unhighlight" the selection set before invoking the ssget function.

 

(sssetfirst nil nil)

 

o:)

 

*** EDIT ***

Oops. You already have found it.

Posted

Thanks ASMI,

 

but can you explain why the LISP sometimes works and sometimes doesnt?

 

It seems quite temperamental :(

Posted

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

Posted

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

Posted
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=

Posted
=lee' you,re welcome' what a remarkable feat you have there=

 

Thanks Wizman :)

  • 10 years later...
Posted

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)
  )

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...