BUG: Naming a Layout with #

BUG: Naming a Layout with #

Anonymous
Not applicable
227 Views
2 Replies
Message 1 of 3

BUG: Naming a Layout with #

Anonymous
Not applicable
Try this...

Name a Layout with the number sign in it, i.e. "RFI #077", and try the
following code to create a selection set of all block with certain name. You
will need to substitute the "$i_*" with your block name specification. It
will return nil even though these blocks exist.

(setq ss1 (ssget "x" (list (cons 0 "insert") (cons 2 "$i_*")(cons 410
(getvar "ctab")))))

Now rename your layout to exclude the number sign, i.e. "RFI 077", and try
the code again and it will return a selection set.

Jim Dee
0 Likes
228 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Hi Jim,
This is due to Autocad allowing the special symbols (that (wcmatch) uses as
wildcards) to be used in Layout names. And although we'd call it a bug, they
seem to have chosen to overlook it. This can be done with layers, too, btw.
There was a discussion about this anomoly sometime ago.

Jeff

"Jim Dee" wrote in message
news:4981597@discussion.autodesk.com...
Try this...

Name a Layout with the number sign in it, i.e. "RFI #077", and try the
following code to create a selection set of all block with certain name. You
will need to substitute the "$i_*" with your block name specification. It
will return nil even though these blocks exist.

(setq ss1 (ssget "x" (list (cons 0 "insert") (cons 2 "$i_*")(cons 410
(getvar "ctab")))))

Now rename your layout to exclude the number sign, i.e. "RFI 077", and try
the code again and it will return a selection set.

Jim Dee
0 Likes
Message 3 of 3

Anonymous
Not applicable
Jim,

Have you tried to escape the pound sign?


(setq ctab (getvar "ctab"))
"test#"

(setq ctab (escChrs ctab "#"))
"test`#"

(ssget "x" (list (cons 0 "insert") (cons 2 "test")(cons 410 ctab)))




; Jason Piercey . September 10th, 2003
; function to return a list of single character
; strings from the characters within a stirng.
; {string] - string to 'characterize'
; return: list of strings
; examples:
; (strChr "Abc") -> ("A" "b" c")
; (strChr "A b c") -> ("A" " " "b" " " c")
; revised: 02/02/04 added function call
(defun strChr (string)
(mapcar
(function
(lambda (x)
(vl-list->string (list x))
)
)
(vl-string->list string)
)
)

; Jason Piercey . September 10th, 2003
; function to return a string with escaped characters
; [string] - string, to search
; [escape] - string, characters to escape
; example:
; (escChrs "abc" "a") -> "`abc"
; (escChrs "abca" "a") -> "`abc`a"
; file dependencies: strChr.lsp
(defun escChrs (string escape)
(setq string (strChr string))
(setq escape (strChr escape))
(apply
'strcat
(foreach x string
(if (vl-position x escape)
(setq string (subst (strcat "`" x) x string)))
string
)
)
)

--
Autodesk Discussion Group Facilitator



"Jim Dee" wrote in message
news:4981597@discussion.autodesk.com...
Try this...

Name a Layout with the number sign in it, i.e. "RFI #077", and try the
following code to create a selection set of all block with certain name. You
will need to substitute the "$i_*" with your block name specification. It
will return nil even though these blocks exist.

(setq ss1 (ssget "x" (list (cons 0 "insert") (cons 2 "$i_*")(cons 410
(getvar "ctab")))))

Now rename your layout to exclude the number sign, i.e. "RFI 077", and try
the code again and it will return a selection set.

Jim Dee
0 Likes