ssget on layer with strange name

ssget on layer with strange name

bcddss
Enthusiast Enthusiast
528 Views
6 Replies
Message 1 of 7

ssget on layer with strange name

bcddss
Enthusiast
Enthusiast

hi,

 

I have a ssget formula to select all from a layer. But if the layer name is like "[342]", the function return nil. Can help me someone? Thank you.

Ahags
0 Likes
Accepted solutions (1)
529 Views
6 Replies
Replies (6)
Message 2 of 7

cadffm
Consultant
Consultant

Hi,

 

what a great idea to use wildcard characters in named objects 🙂

 

read more about autocad WILDCARDS, f.e. here: https://help.autodesk.com/view/ACD/2022/DEU/?guid=GUID-EC257AF7-72D4-4B38-99B6-9B09952A53AD

 

 

[342] => (ssget "_X" '((8 . "`[342`]")))

Sebastian

0 Likes
Message 3 of 7

bcddss
Enthusiast
Enthusiast

i have a lisp and not reading the layer with wild cards returning nil. I don't use that wild cards in my drawings. they came from outside!  😄

Ahags
0 Likes
Message 4 of 7

cadffm
Consultant
Consultant

they came always from outside or a Co-workers 😁

Sebastian

0 Likes
Message 5 of 7

bcddss
Enthusiast
Enthusiast

something like that:

(setq LAY (cdr (assoc 8 (entget e))))

(ssget "_X" (list (cons 8 LAY))

 

so, how do i make the LAY variable to be useable?

Ahags
0 Likes
Message 6 of 7

cadffm
Consultant
Consultant
Accepted solution

>>(setq LAY (cdr (assoc 8 (entget e))))

>>(ssget "_X" (list (cons 8 LAY))

>>so, how do i make the LAY variable to be useable?

 

You have to edit the string "[342]" this way that the result looks like "`[342`]"

So you have to write a function that check each char in your string and if it is an wildcard character,

add a "`" char to the string in front of this char.

 

Create the function to work with all wildcards, otherwise you will stumpled next over a layer with name "123.4"

or "wow#****" and so on.

 

 

For a very practiced one it is just a single line code,

but it is okay if you need 10 or 50 lines. Importend is just the result!

 

As starter for you:

(defun MyOwnQuoteStr (STR)

...

(mapcar 'chr (vl-string->list STR))

...

)

 

 

Try this: (mapcar 'chr (vl-string->list LAY))

Now, you can use FOREACH (or mapcar or whatever)

 

{sorry, I like to help programming, but not by publish the whole solution}

Sebastian

0 Likes
Message 7 of 7

bcddss
Enthusiast
Enthusiast

thank you, i will make the function. Good day!

 i think i use the Lee Mac function 😅

 

http://www.lee-mac.com/escapewildcards.html

Ahags
0 Likes