Author Topic: ssget filter errors  (Read 3439 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: 17529
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: 17529
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: 10376
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: 17529
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: 10376
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: 17529
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: 17529
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: 17529
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

CAB

  • Global Moderator
  • Seagull
  • Posts: 10376
Re: ssget filter errors
« Reply #15 on: October 02, 2005, 12:44:14 PM »
How about this?
Code: [Select]
(setq ss
       (vl-catch-all-apply 'ssdel
                           (list (handent "345AD7")
                                 (ssget '((0 . "INSERT") (66 . 1) (2 . "R-NAME")))
                           )
       )
)
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.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: ssget filter errors
« Reply #16 on: October 02, 2005, 02:32:50 PM »
WHd...

what you realy need to do ?
« Last Edit: October 02, 2005, 02:47:45 PM by Andrea »
Keep smile...

MP

  • Seagull
  • Posts: 17529
Re: ssget filter errors
« Reply #17 on: October 02, 2005, 03:48:03 PM »
I like the new indenting style Alan, very easy to discern the parentage.

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

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ssget filter errors
« Reply #18 on: October 02, 2005, 03:53:33 PM »
hehehe ..
yeah, nothing worse than illegitimate code.

Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

MP

  • Seagull
  • Posts: 17529
Re: ssget filter errors
« Reply #19 on: October 02, 2005, 03:54:15 PM »
 :-D
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

MP

  • Seagull
  • Posts: 17529
Re: ssget filter errors
« Reply #20 on: October 02, 2005, 04:32:16 PM »
Humour aside, I don't think that's a good approach Alan, and here's why --

If we assume we have a drawing that has valid entities in it you'll agree, this should retrieve all the entities correct?

Code: [Select]
(ssget "x")
Now let's filter it using your code and supply a bogus handle to the affore mentioned code --

Code: [Select]
(setq ss
    (vl-catch-all-apply 'ssdel
        (list (handent "BOGUS")
            (ssget "x")
        )
    )
)

Instead of a selection set containing all the entities being assigned to variable ss we get a bound error object. Not so good me thinks.

If you're bent on using vl-catch-all-apply here's an interesting alternate (of many) just for fun --

Code: [Select]
(vl-catch-all-apply
   '(lambda ( )
        (setq ss
            (ssdel (handent "BOGUS")
                (setq ss
                    (ssget "x")
                )
            )
        )   
    )
)

If the supplied handle is valid AND the corresponding ename a member of the inner most ss it will be removed and the resulting (slimmed down) selection set assigned to ss, otherwise the original selection set will remain assigned to ss. The entire code snip does return an error object which we have chosen to discard in this case.

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

CAB

  • Global Moderator
  • Seagull
  • Posts: 10376
Re: ssget filter errors
« Reply #21 on: October 02, 2005, 06:12:59 PM »
I see, I guess I would drop back to this.
Code: [Select]
(setq ss (ssget "x"))
(and (handent "BOGUS")
     (ssdel (handent "BOGUS") ss))
I wasn't married to that code just tried to figure a way to catch the error. :-)
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: 17529
Re: ssget filter errors
« Reply #22 on: October 02, 2005, 07:07:50 PM »
Yep.

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

whdjr

  • Guest
Re: ssget filter errors
« Reply #23 on: October 03, 2005, 09:14:35 AM »
WHd...

what you realy need to do ?
What I am doing is selecting a block with attributes as a reference block.  I am then asking the user to select more of the same block; however I wanted the ssget filter to remove the original block if it was selected in the selection set.  I have it set up right now that after it makes the selection set and returns all the entities I use vl-remove to delete the original referenced block.  If the block is in the set then it is deleted or if the block is not in the set then the set is passed back with no errors to worry about.

I just was looking for a way to remove the block using the ssget function. :-)

Thanks for all the help you guys have given and ofcourse the great discussion I started. :mrgreen: