Author Topic: make a selection set "previous"  (Read 694 times)

0 Members and 1 Guest are viewing this topic.

domenicomaria

  • Bull Frog
  • Posts: 418
make a selection set "previous"
« 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 ?


ribarm

  • Gator
  • Posts: 2829
  • Marko Ribar, architect
Re: make a selection set "previous"
« Reply #1 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...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

dexus

  • Newt
  • Posts: 85
Re: make a selection set "previous"
« Reply #2 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:

domenicomaria

  • Bull Frog
  • Posts: 418
Re: make a selection set "previous"
« Reply #3 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") )

BIGAL

  • Swamp Rat
  • Posts: 1096
  • 40 + years of using Autocad
Re: make a selection set "previous"
« Reply #4 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 "))
A man who never made a mistake never made anything

domenicomaria

  • Bull Frog
  • Posts: 418
Re: make a selection set "previous"
« Reply #5 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
« Last Edit: July 26, 2022, 09:13:44 AM by domenicomaria »

tombu

  • Bull Frog
  • Posts: 282
  • ByLayer=>Not0
Re: make a selection set "previous"
« Reply #6 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 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.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1336
  • Marco
Re: make a selection set "previous"
« Reply #7 on: July 30, 2022, 11:26:39 AM »
try:

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

(command "move" "p" "")


domenicomaria

  • Bull Frog
  • Posts: 418
Re: make a selection set "previous"
« Reply #8 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 . . .


Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1336
  • Marco
Re: make a selection set "previous"
« Reply #9 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: