Author Topic: SSGET with and without preselected objects?  (Read 1713 times)

0 Members and 1 Guest are viewing this topic.

Peter2

  • Swamp Rat
  • Posts: 653
SSGET with and without preselected objects?
« on: October 13, 2023, 09:43:48 AM »
I want to start a lisp-routine with this behaviour:

a) If objects are currently selected, store them: (setq ss (ssget))
b) If no objects are selected, to something else.

Way a) is clear, but it avoids step b). If it founds nothing, it asks the user for input instead of continuing.

How to do it right?

Regards
Peter
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

ribarm

  • Gator
  • Posts: 3282
  • Marko Ribar, architect
Re: SSGET with and without preselected objects?
« Reply #1 on: October 13, 2023, 10:03:21 AM »
Code: [Select]
(defun c:foo ( / ss )
  (if (setq ss (ssget "_I"))
    (if (setq ss (ssget "_:L"))
      (progn
      ;;; do stuff with ss ;;;
      )
      (progn
      ;;; do stuff with ss preselection but not with selection ss - you hit ENTER when asked "Select objects: ";;;
      )
    )
    (progn
    ;;; else do stuff without ss (nothing is preselected) ;;;
    )
  )
  (princ)
)
« Last Edit: October 13, 2023, 10:07:24 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Peter2

  • Swamp Rat
  • Posts: 653
Re: SSGET with and without preselected objects?
« Reply #2 on: October 13, 2023, 10:33:26 AM »
Thanks Marco
the "_I" is something I ignored until now - oh, oh  :embarrassed:  :whistling:

And the additional "_:L" is sophisticated ;-)

Have a good time!
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

BIGAL

  • Swamp Rat
  • Posts: 1419
  • 40 + years of using Autocad
Re: SSGET with and without preselected objects?
« Reply #3 on: October 13, 2023, 08:11:35 PM »
additional "_:L" is sophisticated

have a look at Lee-mac ssget functions for some more handy options.
A man who never made a mistake never made anything

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: SSGET with and without preselected objects?
« Reply #4 on: October 16, 2023, 04:37:10 AM »