TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: domenicomaria on July 22, 2022, 03:37:05 AM

Title: make a selection set "previous"
Post by: domenicomaria on July 22, 2022, 03:37:05 AM
I need to make "previous" a selection set.

(setq ss1 (ssget) )
(setq ss2 (ssget) )

I need that ss1 must be the "previous" selection set

But
(command "move" "p" "")
moves ss2 and not ss1.

To solve it i use :
Code - Auto/Visual Lisp: [Select]
  1. (defun SS-MAKE-PREVIOUS (ss / ohl)
  2.    (setq ohl (getvar "highlight"))
  3.    (setvar "highlight" 0)
  4.    (vl-cmdf "select" ss "")
  5.    (setvar "highlight" ohl)
  6.    ss
  7. )

But it is not elegant, because I have to use "command" or "vl-cmdf" . . .

Is there another solution ?

Title: Re: make a selection set "previous"
Post by: ribarm on July 22, 2022, 04:32:34 AM
(setq ss1 (ssget))
(setq ss2 (ssget))

(sssetfirst nil nil)
(sssetfirst nil ss1)

(ssget "_P") ;;; => selected ss1 instead of ss2

But here it's better this :
(ssget "_I") ;;; => implied selection - always useful after (sssetfirst nil ss) which highlights selection set ss...
Title: Re: make a selection set "previous"
Post by: dexus on July 22, 2022, 04:34:39 AM
Do you mean the current selected items?
Then you can use:
Code - Auto/Visual Lisp: [Select]
  1. (ssget "_I")

Or the actual items selected for the last function, you can use:
Code - Auto/Visual Lisp: [Select]
  1. (ssget "_p")

Also here is a very helpful reference: http://www.lee-mac.com/ssget.html

Edit: Aah, ribarm beat me by 2 minutes, I need to type quicker  :oops:
Title: Re: make a selection set "previous"
Post by: domenicomaria on July 22, 2022, 06:06:19 AM
so this one could be the solution

(defun SS-MAKE-PREVIOUS (ss)  (sssetfirst nil ss) (ssget "_I") )
Title: Re: make a selection set "previous"
Post by: BIGAL on July 22, 2022, 09:46:02 PM
Why not move ss1 ?

You should be able to make multiple selection sets and use SET to make them like SS+x as variable name so could have as many as you want then can use same method to retrieve sss+x in move SS1. Not tested very hard.


Code: [Select]
(setq x 12)
(setq pt1 '(0 0 0) pt2 '(100 100 0))
(set (read (strcat "SS" (rtos x 2 0))) (ssget))

(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "move !ss" (rtos x 2 0) " "  " "  "!pt1 "  "!pt2 "))
Title: Re: make a selection set "previous"
Post by: domenicomaria on July 23, 2022, 03:01:30 AM
sometimes a lisp routine
does some things and creates or modifies some objects.

For the user, after using this routine
it can be useful to easily select
all new objects created or modified.

 So from the command line
 for example he can say:
 move previous
Title: Re: make a selection set "previous"
Post by: tombu on July 23, 2022, 10:13:50 AM
irneb posted SelectResults.lsp at https://forums.augi.com/showthread.php?81175-select-result-lisp-modification#5 (https://forums.augi.com/showthread.php?81175-select-result-lisp-modification#5) which creates selection sets of objects produced by commands with a reactor so you can select them easily. Lisp needs to be loaded when you open a drawing.

In the lisp set $Result-Length to how many previous sets you want to keep.
Title: Re: make a selection set "previous"
Post by: Marc'Antonio Alessi on July 30, 2022, 11:26:39 AM
try:

(setq ss2 (ssget) ) ; 1
(setq ss1 (ssget) ) ; 2 > previous

(command "move" "p" "")

Title: Re: make a selection set "previous"
Post by: domenicomaria on July 30, 2022, 01:56:23 PM
try:

(setq ss2 (ssget) ) ; 1
(setq ss1 (ssget) ) ; 2 > previous

(command "move" "p" "")

Marco, I'm sorry, but I don't understand your answer . . .

the PREVIOUS selection set, is latest thing that SSGET returns . . .

But I need to MAKE PREVIOUS, ANOTHER selection set . . .

Title: Re: make a selection set "previous"
Post by: Marc'Antonio Alessi on July 30, 2022, 03:57:09 PM
try:

(setq ss2 (ssget) ) ; 1
(setq ss1 (ssget) ) ; 2 > previous

(command "move" "p" "")

Marco, I'm sorry, but I don't understand your answer . . .

the PREVIOUS selection set, is latest thing that SSGET returns . . .

But I need to MAKE PREVIOUS, ANOTHER selection set . . .
Ok… sorry, ignore my reply. ;)   :oops: