Results 1 to 5 of 5

Thread: It’s possible AutoCAD selection save (s1, s2, s3 etc.) & use selection after some time

  1. #1
    Member
    Join Date
    2007-04
    Posts
    25
    Login to Give a bone
    0

    Exclamation It’s possible AutoCAD selection save (s1, s2, s3 etc.) & use selection after some time

    It’s possible AutoCAD selection save (s1, s2, s3 etc.) & use selection after some time

    Just like Photoshop selection

  2. #2
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: It’s possible AutoCAD selection save (s1, s2, s3 etc.) & use selection after some time

    Do you want to reuse the selection sets inside some lisp or inside a command?

    If the former, the ssget function saves a selection set to a variable in ram. This can be reused at any time thereafter as long as the selection set's not been cleared.

    For a command line version it could be a bit more complex. And it also depends on how you want it to work. Should the user be asked for 4 selection sets and then these get used randomly as per the user's key presses? Or should the last 4 selections be remembered - so you basically have Previous x 4?

  3. #3
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,805
    Login to Give a bone
    0

    Default Re: It’s possible AutoCAD selection save (s1, s2, s3 etc.) & use selection after some time

    Quote Originally Posted by sachindkini View Post
    It’s possible AutoCAD selection save (s1, s2, s3 etc.) & use selection after some time

    Just like Photoshop selection
    Using Autolisp, you can. When asked to make a selection, enter this at the command prompt:

    (setq ss1 (ssget))

    From that point in, in the same drawing, you can respond to the prompt for selection with the string "!ss1"

    (note the "ss1" part can be almost any string that starts with a letter)
    R.K. McSwain | CAD Panacea |

  4. #4
    Member
    Join Date
    2007-04
    Posts
    25
    Login to Give a bone
    0

    Smile Re: It’s possible AutoCAD selection save (s1, s2, s3 etc.) & use selection after some time

    Quote Originally Posted by irneb View Post
    Do you want to reuse the selection sets inside some lisp or inside a command?

    If the former, the ssget function saves a selection set to a variable in ram. This can be reused at any time thereafter as long as the selection set's not been cleared.

    For a command line version it could be a bit more complex. And it also depends on how you want it to work. Should the user be asked for 4 selection sets and then these get used randomly as per the user's key presses? Or should the last 4 selections be remembered - so you basically have Previous x 4?
    Dear Sir,
    thx for reply

    yes. reuse the selection sets inside some lisp or inside a command

  5. #5
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: It’s possible AutoCAD selection save (s1, s2, s3 etc.) & use selection after some time

    Quote Originally Posted by sachindkini View Post
    Dear Sir,
    thx for reply

    yes. reuse the selection sets inside some lisp or inside a command
    I'm still not clear as to how you want these. If you want to reuse the selection sets within some lisp, then do something like this:
    Code:
    (defun c:CommandName (/ n en ed)
      (princ "\nSelect 1st set of entities: ")
      (setq ss1 (ssget))
      (princ "\nSelect 2nd set of entities: ")
      (setq ss2 (ssget))
      (princ "\nSelect 3rd set of entities: ")
      (setq ss3 (ssget))
      (princ "\nSelect 4th set of entities: ")
      (setq ss4 (ssget))
    
      ;; Step through 1st selection set one at a time
      (setq n 0)
      (while (< n (sslength ss1))
        (setq en (ssname ss1 n)) ;Get the ename of the nth entity in ss1
        (setq n (1+ n)) ;Increment counter
      )
    
      ;; Use the 2nd selection set in a copy command
      (command "._COPY" ss2 "" pause)
      (while (> (getvar "CMDACTIVE") 0) (command pause))
    
      ;; Various other ways of using the 4 selection sets in any order or any
      ;; number of times, until they are explicitly set to nil
    
      (princ "\nSS1, SS2, SS3, SS4 are saved selection sets. Prefix with ! to use.")
      (princ)
    )
    Note it saves the selection sets to 4 global variables which would thus be available to all other lisp functions. However, there's a limit on the amount of current selection sets ... so this is not a very good idea, but let's press on regardless .

    If you want to reuse these as an argument for a command, then you could go with RK's example of prefixing the selection sets with an exclamation point (!) - as shown on the 2nd last line of the defun. Or you can create a wrapper function to send the selection set to the command line, e.g.
    Code:
    (defun c:s1 (/) (command ss1) (princ))
    (defun c:s2 (/) (command ss2) (princ))
    (defun c:s3 (/) (command ss3) (princ))
    (defun c:s4 (/) (command ss4) (princ))
    Then you can type 's1 / 's2 / 's3 / 's4 at the command prompt to invoke the lisp transparently. You can't send these "saved" selection sets to a lisp command argument. Not using lisp anyway.

    Now here's my real question: how do you want to "create" these selection sets. When you say you want to reuse them in a command, the most usefull I can think of would be to have some form of Previous, 2ndPrevious, 3rdPrevious ....

    If this is the case, then you'll need a command reactor to check if the previous selection set has changed. If so add it to a global list of selection sets, and discard the last from the list if the list reaches a predefined length (e.g. 4). Then you'll require a similar idea as per the wrapper functions above. For lisps to reuse these selection sets they can directly access the list. Unfortunately I don't see any way that the wrapper functions would pass the selection sets to other lisp functions when they ask for a selection through ssget.

Similar Threads

  1. CP34-3: Getting the Correct Selection Set Every Time
    By Autodesk University in forum Customization and Programming
    Replies: 0
    Last Post: 2013-03-30, 02:12 AM
  2. Save Selection Set
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 6
    Last Post: 2010-07-05, 06:59 PM
  3. Help: Can't save a FILTER selection set
    By stykface in forum AutoCAD General
    Replies: 1
    Last Post: 2009-05-07, 12:53 PM
  4. save Selection Box
    By Bryan Thatcher in forum Revit Architecture - General
    Replies: 4
    Last Post: 2009-02-04, 05:55 PM
  5. Can I Save a Selection Set
    By sfraney in forum Revit Architecture - General
    Replies: 9
    Last Post: 2006-08-09, 11:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •