(setq SSET (ssget "_X" (list '(0 . "INSERT")(cons 2 "block@01"))))
The statement above returns nil, even though there are many blocks with that name in the drawing. The rename command will not let me rename this block. Any suggestions for selecting them all. If I insert a new block and leave the @ symbol out and change the code to
(setq SSET (ssget "_X" (list '(0 . "INSERT")(cons 2 "block01"))))
it will work. Any suggestions for filtering a selection set for blocks that contain the @ symbol in it?
Thanks.
Command: (wcmatch "a@t" "*\@*")
T
???
Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.
The @ symbol is a wildcard operator which will match any single alphabetic character [A-Z,a-z], hence your filter will not find a match since the "@" character is not an alphabetic character:
_$ (wcmatch "@" "@")
nil
To mark the @ wildcard operator symbol as a literal character so that it is instead interpreted as the "@" character, use the ` (reverse quote) wildcard operator:
_$ (wcmatch "@" "`@") T
Hence, for your ssget filter list:
(ssget "_X" '((0 . "INSERT") '(2 . "block`@01")))
This logic applies to all other wildcard operators that are to be interpreted as literal characters.
(princ"\n 1: ") (prin1 (wcmatch "a@t" "*\@*"))
(princ"\n 2: ") (prin1 (wcmatch "at" "*\@*"))
both get T here.
And cannot find a means of searching for the '@' within the ssget filter.
The explicit match,
(if (= "@" (substr bns 6 1) ) (princ " matched " ))
@stevor wrote:(princ"\n 1: ") (prin1 (wcmatch "a@t" "*\@*"))
(princ"\n 2: ") (prin1 (wcmatch "at" "*\@*"))both get T here.
And cannot find a means of searching for the '@' within the ssget filter.
....
It's the reverse-quote@ character ` that you want, rather than the backslash character \, to "escape" reading @ as a special character and read it literally. As you have it, the @ in the pattern argument is "satisfied" by both the a and the t, since it's the wildcard for any alphabetic character, and both of those qualify. The backslash is used as an escape character or special-function trigger in other situations, but within (wcmatch) it's not the one for reading wild-card characters literally.
Substituting ` for \ in your (wcmatch) functions:
(wcmatch "a@t" "*`@*")
T
@because the literal @ character is in the 'string' argument. But
(wcmatch "at" "*`@*")
nil
because now it's not.
Good to know. I figured as much about the wildcard, but what if routine has a block name as a variable? Like
(Cons 2 BLOCKNAME)
Consider a function such as:
(defun LM:FixWildcards ( str ) (vl-list->string (apply 'append (mapcar '(lambda ( c ) (if (member c '(35 64 46 42 63 126 91 93 45 44)) (list 96 c) (list c) ) ) (vl-string->list str) ) ) ) ) (vl-load-com)
Passing this function your block name:
_$ (LM:FixWildcards "block@01") "block`@01"
@Redraiderr2009 wrote:(setq SSET (ssget "_X" (list '(0 . "INSERT")(cons 2 "block@01"))))The statement above returns nil, even though there are many blocks with that name in the drawing. The rename command will not let me rename this block. ....
You can@ Rename that Block, if you want to be rid of the complications it causes. [At least, I can, in my ol' 2004 version.] I made a Block with a @ in its name, and all of these worked for me:
1. get into the Rename dialog box, pick that name from the list, and in the Old Name: slot, add a reverse-quote character@ before the @ prior to picking the Rename To: button. [I assume that's the approach you tried, that wouldn't let you Rename it without the ` in the old name.]
Or
2. type -RENAME for the command-line version, choose the Block option, and type in the old Block name without a ` in it.
Or the AutoLISP equivalent of 2:
3. (command "_.rename" "_b" "old@name" "newname")
without a ` in the old name.
...so I selected the wrong escape key on my absentminded keyboard.
Has anybody tried this:
(strcat "*" (chr 64) "*")
???
Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.
scot-65 wrote:
Has anybody tried this:
(strcat "*" (chr 64) "*")
Considering the other posts in this thread explaining the use of the reverse quote escape character, why do you think your suggestion would make a difference?
(strcat "*" (chr 64) "*") will return "*@*"
which, when used in a wcmatch expression will just match any alphabetic character in a string...
Lee,
Can you help me please….?
I have been trying to figure out a LISP routine that would be able to create a table out of the attributes, collected from a selection of dynamic blocks in order to create a BOM.
After hours of research, I can’t seem to figure out how to select all my blocks via wildcards.
I have come to the conclusion that the most user friendly way, would be to utilize selection set collector you have created in your DeleteBlocksV1-1.lsp.
I have been able to remove the references of “delete” from your code, however, I then can’t quite figure how to utilize the set selection and place the attribute results into a table.
Can you tell me if this is even possibly please?
Kindest Regards
Gary
Perfectly explained.
And to add the reverse quote:
(vl-string-subst "`@" "@" "block@01")
John F. Uhden