Author Topic: SSGET Select objects & or Window selection with filter  (Read 1343 times)

0 Members and 1 Guest are viewing this topic.

dubb

  • Swamp Rat
  • Posts: 1105
SSGET Select objects & or Window selection with filter
« on: July 20, 2021, 08:47:13 PM »
How do I SSGET with a window & or single object selection with a filter?

This will end ssget after I select a single object but I want to continue selecting objects one by one or using a window until i press enter.
Code: [Select]
(ssget "_+.:E:S")

kpblc

  • Bull Frog
  • Posts: 396
Re: SSGET Select objects & or Window selection with filter
« Reply #1 on: July 21, 2021, 12:33:55 AM »
Why not to use simple (ssget) ?
Sorry for my English.

gumbtg

  • Mosquito
  • Posts: 12
Re: SSGET Select objects & or Window selection with filter
« Reply #2 on: July 21, 2021, 08:52:46 AM »
Check the SSGET reference write up from Lee Mac here: http://www.lee-mac.com/ssget.html

You can really just use a normal SSGET function if you want. It allows for a selection set. Which you can then filter using the normal list filtering.

dubb

  • Swamp Rat
  • Posts: 1105
Re: SSGET Select objects & or Window selection with filter
« Reply #3 on: July 21, 2021, 11:38:58 AM »
Thanks! Here is what I came up with. Its a block select script used to select similar blocks.
Code: [Select]
(defun c:foo()
(setq blkname (vla-get-effectivename (vlax-ename->vla-object (car(entsel "\nPlease select a block!")))))
(setq ss (ssget))
  (setq i 0)
  (while (<= i (- (sslength ss)1))
  (if(/= (vla-get-effectivename (vlax-ename->vla-object (ssname ss i))) blkname)
    (ssdel (ssname ss i) ss)
    (setq i (1+ i))
    )
  )
(sssetfirst nil ss)
  )

ronjonp

  • Needs a day job
  • Posts: 7526
Re: SSGET Select objects & or Window selection with filter
« Reply #4 on: July 21, 2021, 01:34:21 PM »
Thanks! Here is what I came up with. Its a block select script used to select similar blocks.
Code: [Select]
(defun c:foo()
(setq blkname (vla-get-effectivename (vlax-ename->vla-object (car(entsel "\nPlease select a block!")))))
(setq ss (ssget))
  (setq i 0)
  (while (<= i (- (sslength ss)1))
  (if(/= (vla-get-effectivename (vlax-ename->vla-object (ssname ss i))) blkname)
    (ssdel (ssname ss i) ss)
    (setq i (1+ i))
    )
  )
(sssetfirst nil ss)
  )
Food for thought:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ b i ss)                 ; <-localize variables
  2.   (if (and ;; Get selection
  3.            (setq b (car (entsel "\nPlease select a block!")))
  4.            ;; Make sure selection is valid
  5.            (vlax-property-available-p (setq b (vlax-ename->vla-object b)) 'effectivename)
  6.            ;; Get effective name
  7.            (setq b (vla-get-effectivename b))
  8.            ;; Create a filter using our block name and *U* blocks ( modified dynamic )
  9.            (setq ss (ssget (list '(0 . "INSERT") (cons 2 (strcat "`*U*," b)))))
  10.       )
  11.     (progn (foreach i (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
  12.              (if (/= (vla-get-effectivename (vlax-ename->vla-object i)) b)
  13.                (ssdel i ss)
  14.              )
  15.            )
  16.            (sssetfirst nil ss)
  17.     )
  18.   )
  19.   (princ)
  20. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC