TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: whdjr on October 01, 2005, 12:14:56 PM
-
Why does this not work?
Are you allowed to put handles in your ssget filters?
(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?
-
Try this. The not filter requires 2 parts
It might work
(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?
-
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.
-
You cannot use group 5 with ssget.... it won't be recognize.... that's why
-
You cannot filter on group 5, you have to do something like this --
(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 --
(setq ss
(RemoveHandlesFromSS
(ssget
'( (0 . "INSERT")
(66 . 1)
(2 . "R-NAME")
)
)
'("345AD7")
)
)
Coded blind so may need massaging.
-
Think you have it backwards Luis, he DOESN'T want the entity sporting that handle.
-
Scratching Head
If the handle is unique then he does want a specific object, no? :?
-
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.
:)
-
Oh, I missed the NOT. :-o
In that case your solution look perfect for that.
-
Something a little more flexible might be --
(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 --
(setq ss
(RemoveFromPicksetIf
(ssget
'( (0 . "INSERT")
(2 . "R-NAME")
(66 . 1)
)
)
(lambda (ename)
(eq "345AD7"
(cdr
(assoc 5
(entget ename)
)
)
)
)
)
)
-
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.
-
(ssdel (handent "345AD7") (ssget '((0 . "INSERT")(66 . 1)(2 . "R-NAME"))))
-
Good stuff Mr. Crank. For succinctness that's a winner.
-
(ssdel (handent "345AD7") (ssget '((0 . "INSERT")(66 . 1)(2 . "R-NAME"))))
I Like! :-)
-
Make sure you use a valid handle for the succinct version lest there be an immediate "earth shattering kaboom".
/Marvin
:lol:
-
How about this?
(setq ss
(vl-catch-all-apply 'ssdel
(list (handent "345AD7")
(ssget '((0 . "INSERT") (66 . 1) (2 . "R-NAME")))
)
)
)
-
WHd...
what you realy need to do ?
-
I like the new indenting style Alan, very easy to discern the parentage.
:-o
-
hehehe ..
yeah, nothing worse than illegitimate code.
-
:-D
-
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?
(ssget "x")
Now let's filter it using your code and supply a bogus handle to the affore mentioned code --
(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 --
(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.
:)
-
I see, I guess I would drop back to this.
(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. :-)
-
Yep.
(http://www.theswamp.org/screens/mp/nodding.gif)
-
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: