Author Topic: ssget filter to exclude an anonymous block name  (Read 2670 times)

0 Members and 1 Guest are viewing this topic.

David Bethel

  • Swamp Rat
  • Posts: 656
ssget filter to exclude an anonymous block name
« on: November 30, 2017, 07:34:47 AM »
Morning,

I'm wanting to select a single anonymous INSERT and then select additional INSERTs without highlighting the previous selection

Code - Auto/Visual Lisp: [Select]
  1. defun c:foo (/ en ss as en ed bn)
  2.   (while (not en)
  3.          (and (princ "\nSelect Main WCS Anonymous Block To Add To...")
  4.               (setq ss (ssget (list (cons 0 "INSERT")
  5.                                     (cons 2 "`*U*")
  6.                                     (cons 67 0)
  7.                                     (list 210 0 0 1))))
  8.               (= (sslength ss) 1)
  9.               (setq en (ssname ss 0)
  10.                     ed (entget en)
  11.                     bn (cdr (assoc 2 ed)))))
  12.  
  13.    (while (not as)
  14.           (princ "\nSelect INSERTs To Add...")
  15.           (setq as (ssget (list (cons 0 "INSERT")
  16.                                 (cons -4 "<NOT")
  17.                                   (cons 2 bn)
  18.                                 (cons -4 "NOT>")
  19.                                   ))))
  20.    (prin1))
  21.  
  22.  

I've tried all kinds of filter / syntax without any luck
Code: [Select]

(cons 2 (strcat "~" bn))

(cons 2 (strcat "~`" bn))


Any suggestions

( there will be additional filters on the adding picks )

TIA  -David
« Last Edit: November 30, 2017, 09:00:29 AM by David Bethel »
R12 Dos - A2K

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: ssget filter to exclude an anonymous block name
« Reply #1 on: November 30, 2017, 08:28:21 AM »
Hi,

Try like this:

Code - Auto/Visual Lisp: [Select]
  1. (setq as (ssget
  2.            (list
  3.              (cons 0 "INSERT")
  4.              (cons -4 "<NOT")
  5.              (cons 2 bn)
  6.              (cons -4 "NOT>")
  7.            )
  8.          )
  9. )

Note the dxf code is -4 instead of 4.
Speaking English as a French Frog

David Bethel

  • Swamp Rat
  • Posts: 656
Re: ssget filter to exclude an anonymous block name
« Reply #2 on: November 30, 2017, 09:03:31 AM »

Thanks for the catching my typo


Sorry, but the "<NOT" filter doesn't work either

I'm sure it has to do with the leading asterisk in the block name

-David
R12 Dos - A2K

ronjonp

  • Needs a day job
  • Posts: 7526
Re: ssget filter to exclude an anonymous block name
« Reply #3 on: November 30, 2017, 10:14:15 AM »
Not a block name filter, but this seems to work:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/ en ss as en ed p)
  2.   (while (not en)
  3.     (and (princ "\nSelect Main WCS Anonymous Block To Add To...")
  4.          (setq ss (ssget (list (cons 0 "INSERT") (cons 2 "`*U*"))))
  5.          (= (sslength ss) 1)
  6.          (setq en (ssname ss 0)
  7.                ed (entget en)
  8.                p  (assoc 10 ed)
  9.          )
  10.     )
  11.   )
  12.   (while (not as)
  13.     (princ "\nSelect INSERTs To Add...")
  14.     (setq as (ssget (list '(0 . "INSERT") '(-4 . "<>,<>") p)))
  15.   )
  16.   (prin1)
  17. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

PKENEWELL

  • Bull Frog
  • Posts: 309
Re: ssget filter to exclude an anonymous block name
« Reply #4 on: November 30, 2017, 10:16:18 AM »
Hi David,

I don't have the time to test this at the moment, but could it be that when you are specifying the "bn" variable, you are re-referencing it from the selection, and the "*" in the block name is no longer escaped as in your original selection set? Perhaps (strcat "`" bn)?

I'm not sure if that will work. I don't know if the string when referenced from the ename is already escaped? I guess it wouldn't hurt to give it a try.

In any case Ronjonp's solution is probably a better choice (He posted while I was replying LOL).
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

David Bethel

  • Swamp Rat
  • Posts: 656
Re: ssget filter to exclude an anonymous block name
« Reply #5 on: November 30, 2017, 12:54:06 PM »
finally figured it out :

Code: [Select]
(while (not as)
          (princ "\nSelect INSERTs To Add...")
          (setq as (ssget (list (cons 0 "INSERT")
                                (cons -4 "<NOT")
                                  (cons 2 (strcat "`" bn))
                                (cons -4 "NOT>")
                                  ))))

Ron, with our system, ironically there can be multiple blocks inserted at the very same point ( a common origin point of an assembly )

Here the oven, dolly base RH open burner, salamander broiler and support shelf are all inserted and the same point.

Thanks!  -Davod
R12 Dos - A2K

ronjonp

  • Needs a day job
  • Posts: 7526
Re: ssget filter to exclude an anonymous block name
« Reply #6 on: November 30, 2017, 01:13:40 PM »
Glad you got it sorted :) You could also just ssdel the ename from your second selection set too. I know it will get selected again, but not processed.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

David Bethel

  • Swamp Rat
  • Posts: 656
Re: ssget filter to exclude an anonymous block name
« Reply #7 on: November 30, 2017, 01:20:33 PM »
Ron,

That (ssdel) is exactly what I have been doing.

It is more visual thing.  I don't want the main unit to be highlighted during the 2nd ssget selection call

-David
R12 Dos - A2K

PKENEWELL

  • Bull Frog
  • Posts: 309
Re: ssget filter to exclude an anonymous block name
« Reply #8 on: November 30, 2017, 01:38:04 PM »
finally figured it out :

You're Welcome  :-D
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt