Author Topic: ssget filter errors  (Read 3469 times)

0 Members and 1 Guest are viewing this topic.

whdjr

  • Guest
ssget filter errors
« on: October 01, 2005, 12:14:56 PM »
Why does this not work?
Are you allowed to put handles in your ssget filters?

Code: [Select]
(ssget '((0 . "INSERT")
          (66 . 1)
          (2 . "R-NAME")
          (-4 . "<NOT")
          (5 . "345AD7"))
)

It gives me an error 63 (filter error) when I try to run it.  I tried the '<not' before and after the handle with no luck.  It only works without the handle.  Can anyone verify this for me?

Peter Jamtgaard

  • Guest
Re: ssget filter errors
« Reply #1 on: October 01, 2005, 12:36:34 PM »
Try this. The not filter requires 2 parts
It might work

Code: [Select]
(ssget '((0 . "INSERT")
(66 . 1)
(2 . "R-NAME")
(-4 . "<NOT")
(5 . "345AD7")
(-4 . "NOT>"); revised
         )
)

It gives me an error 63 (filter error) when I try to run it. I tried the '<not' before and after the handle with no luck. It only works without the handle. Can anyone verify this for me?
« Last Edit: October 01, 2005, 12:44:49 PM by Peter Jamtgaard »

whdjr

  • Guest
Re: ssget filter errors
« Reply #2 on: October 01, 2005, 01:02:21 PM »
Try this. The not filter requires 2 parts
It might work
No go.  I tried that already but I tried it again and it still didn't work.

LE

  • Guest
Re: ssget filter errors
« Reply #3 on: October 01, 2005, 01:19:39 PM »
You cannot use group 5 with ssget.... it won't be recognize.... that's why

MP

  • Seagull
  • Posts: 17530
Re: ssget filter errors
« Reply #4 on: October 01, 2005, 01:25:32 PM »
You cannot filter on group 5, you have to do something like this --

Code: [Select]
(defun RemoveHandlesFromSS ( ss handles / i ename )

    (setq handles (mapcar 'strcase handles))
   
    (if (eq 'pickset (type ss))
        (repeat (setq i (sslength ss))
            (if
                (member
                    (cdr
                        (assoc 5
                            (entget
                                (setq ename
                                    (ssname ss
                                        (setq i (1- i))
                                    )
                                )
                            )
                        )
                    )
                    handles
                )
                (ssdel ename ss)
            )
        )
    )
   
    ss
   
)

Then --

Code: [Select]
(setq ss
    (RemoveHandlesFromSS
        (ssget
           '(   (0 . "INSERT")
                (66 . 1)
                (2 . "R-NAME")
            )
        )
       '("345AD7")
    )
)

Coded blind so may need massaging.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

MP

  • Seagull
  • Posts: 17530
Re: ssget filter errors
« Reply #5 on: October 01, 2005, 01:37:11 PM »
Think you have it backwards Luis, he DOESN'T want the entity sporting that handle.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

CAB

  • Global Moderator
  • Seagull
  • Posts: 10377
Re: ssget filter errors
« Reply #6 on: October 01, 2005, 01:43:54 PM »
Scratching Head
If the handle is unique then he does want a specific object, no? :?
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17530
Re: ssget filter errors
« Reply #7 on: October 01, 2005, 01:46:58 PM »
Looks to me like he wants all blocks named "R-NAME" that have attributes except the one with the handle "345AD7", at least that is what the code in the first post suggests to me.

:)
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

CAB

  • Global Moderator
  • Seagull
  • Posts: 10377
Re: ssget filter errors
« Reply #8 on: October 01, 2005, 01:49:37 PM »
Oh, I missed the NOT. :-o
In that case your solution look perfect for that.
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17530
Re: ssget filter errors
« Reply #9 on: October 01, 2005, 02:03:59 PM »
Something a little more flexible might be --

Code: [Select]
(defun RemoveFromPicksetIf ( ss func )
    ;;  The supplied func must take one
    ;;  argument, an ename. What it does
    ;;  we don't care, but if it returns
    ;;  a non nil result remove the entity
    ;;  from the pickset
    (if (eq 'pickset (type ss))
        (repeat (setq i (sslength ss))
            (if
                (func
                    (setq ename
                        (ssname ss
                            (setq i (1- i))
                        )
                    )
                )
                (ssdel ename ss)
            )
        )
    )
    ss
)

Then he'd might use it thusly --

Code: [Select]
(setq ss
    (RemoveFromPicksetIf
        (ssget
           '(   (0 . "INSERT")
                (2 . "R-NAME")
                (66 . 1)
            )
        )
        (lambda (ename)
            (eq "345AD7"
                (cdr
                    (assoc 5
                        (entget ename)
                    )
                )
            )
        )
    )
)
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

whdjr

  • Guest
Re: ssget filter errors
« Reply #10 on: October 01, 2005, 02:32:16 PM »
Thanks guys you answered my question and gave more as always.

What I did while I was waiting was to get the entities supplied from 'ssget' and then used 'vl-remove' to remove the entity I didn't need because I already had the entity name from earlier in my code.  I was just trying to shorcut that by ecluding that block via it's handle; but that's a no go.

Thanks again guys.

Crank

  • Swamp Rat
  • Posts: 1443
Re: ssget filter errors
« Reply #11 on: October 01, 2005, 02:36:55 PM »
Code: [Select]
(ssdel (handent "345AD7") (ssget '((0 . "INSERT")(66 . 1)(2 . "R-NAME"))))

 Vault Professional 2018     /      Building Design Suite Ultimate 2017     /     AEC Collection 2018 + 2019 +2020

MP

  • Seagull
  • Posts: 17530
Re: ssget filter errors
« Reply #12 on: October 01, 2005, 02:38:07 PM »
Good stuff Mr. Crank. For succinctness that's a winner.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

whdjr

  • Guest
Re: ssget filter errors
« Reply #13 on: October 01, 2005, 10:30:56 PM »
Code: [Select]
(ssdel (handent "345AD7") (ssget '((0 . "INSERT")(66 . 1)(2 . "R-NAME"))))


I Like!  :-)

MP

  • Seagull
  • Posts: 17530
Re: ssget filter errors
« Reply #14 on: October 02, 2005, 11:42:15 AM »
Make sure you use a valid handle for the succinct version lest there be an immediate "earth shattering kaboom".

/Marvin

:lol:
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox