Author Topic: Force prompt user to select an entity with SSGE even if there is already selecte  (Read 193 times)

0 Members and 1 Guest are viewing this topic.

V@no

  • Newt
  • Posts: 25
  • AutoCAD 2023
I'd like to use SSGET to prompt user to select certain entities (let's say only lines). However if there is already a selection but doesn't pass the filter (a circle selected) SSGET returns nil instead of prompt user to select.

Is there a way force to prompt user without clearing the selection?

Basically, what I'm trying to accomplish is: prompt user so select a single entity (using ":S"). Highlight that entity, prompt user to select second entity but don't allow select first one.

During these prompts I also allow user change options, therefor I'm running SSGET in a loop, however on second "prompt" it automatically returns nil instead of prompting user.

Any ideas how to achieve this?

Thank you.

Code - Auto/Visual Lisp: [Select]
  1. (DEFUN c:test (/ loop num filter str ss sss ent1 ent2)
  2.     (SETQ loop   T
  3.           num    0
  4.           filter nil
  5.           str    "first"
  6.           sss    (SSADD)
  7.     )
  8.     (WHILE loop
  9.         (PRINC (STRCAT "\nSelect " str " item: "))
  10.         (SETQ ss (SSGET "_:S" filter))
  11.         (print ss)
  12.         (IF (AND ss (> (SSLENGTH ss) 0) (= num 0))
  13.             (PROGN
  14.                 (SETQ ent1   (ENTGET (SSNAME ss 0))
  15.                       filter (LIST (CONS -4 "!=") (CAR ent1))
  16.                       num    (1+ num)
  17.                       str    "second"
  18.                       sss    (SSADD (SSNAME ss 0) sss)
  19.                 )
  20.             )
  21.             (PROGN
  22.                 (SETQ loop nil)
  23.  
  24.                 (IF ss
  25.                     (SETQ ent2 (SSNAME ss 0)
  26.                           sss  (SSADD ss sss)
  27.                     )
  28.                 )
  29.             )
  30.         )
  31.         (SSSETFIRST nil sss)
  32.     )
  33.     (PRINC "\nfirst item: ")
  34.     (PRINC ent1)
  35.     (PRINC "\nsecond item: ")
  36.     (PRINC ent2)
  37.     (PRINC)
  38. )

ribarm

  • Gator
  • Posts: 3297
  • Marko Ribar, architect
Try this mod... But selection of grips were not preserved when selected the same entity and because of that added (GETSTRING) after (SSSETFIRST)...

Code - Auto/Visual Lisp: [Select]
  1. (DEFUN c:seltst ( / *error* loop num str hgl sss ss ent1 ent2 )
  2.  
  3.   (DEFUN *error* ( m )
  4.     (IF hgl
  5.       (SETVAR (QUOTE highlight) hgl)
  6.     )
  7.     (IF m
  8.       (PROMPT m)
  9.     )
  10.     (PRINC)
  11.   )
  12.  
  13.   (SETQ loop T)
  14.   (SETQ num 0)
  15.   (SETQ str "first")
  16.   (SETQ hgl (GETVAR (QUOTE highlight)))
  17.   (SETVAR (QUOTE highlight) 1)
  18.   (SETQ sss (SSADD))
  19.   (WHILE loop
  20.     (PRINC (STRCAT "\nSelect " str " item : "))
  21.     (IF (AND ent1 (SSMEMB ent1 ss))
  22.       (SSDEL ent1 ss)
  23.     )
  24.     (WHILE (OR (NOT ss) (AND ss (= (SSLENGTH ss) 0)))
  25.       (SETQ ss (SSGET "_+.:E:S"))
  26.     )
  27.     (COND
  28.       ( (AND ss (= (SSLENGTH ss) 1) (= num 0))
  29.         (SETQ ent1 (SSNAME ss 0))
  30.         (SETQ num (1+ num))
  31.         (SETQ str "second")
  32.         (SSADD ent1 sss)
  33.       )
  34.       ( T
  35.         (SETQ loop nil)
  36.         (IF (AND ss (= (SSLENGTH ss) 1) (EQ ent1 (SETQ ent2 (SSNAME ss 0))))
  37.           (PROGN
  38.             (SETQ loop T)
  39.             (SSDEL ent1 ss)
  40.           )
  41.           (IF (OR (NOT ss) (AND ss (= (SSLENGTH ss) 0)))
  42.             (SETQ loop T)
  43.           )
  44.         )
  45.         (IF (AND ent2 (NOT (EQ ent1 ent2)))
  46.           (SSADD ent2 sss)
  47.         )
  48.       )
  49.     )
  50.     (SSSETFIRST nil sss)
  51.     (IF (OR (AND ent1 (NOT ent2)) (AND ent1 ent2 (EQ ent1 ent2)))
  52.       (PROGN
  53.         (GETSTRING "\nENTER TO CONTINUE...")
  54.         (SSSETFIRST)
  55.       )
  56.     )
  57.   )
  58.   (PRINC "\nFirst item : ")
  59.   (PRINC ent1)
  60.   (PRINC "\nSecond item : ")
  61.   (PRINC ent2)
  62.   (*error* nil)
  63. )
  64.  

M.R.
« Last Edit: May 02, 2024, 02:38:44 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3297
  • Marko Ribar, architect
Just to add note...
I tested my mod. in BricsCAD and it behaves good, but in AutoCAD it's very buggy...
Sorry, but I may not find apropriate solution for both environments...
Regards...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3297
  • Marko Ribar, architect
Test it now...
I think that now is good for both and BricsCAD and AutoCAD...

Regards, M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube