Hi.
We have a LISP routine that write (strcat (getvar "DWGPREFIX") (getvar "DWGNAME")) to an attribute that has multiple lines. If the drawing name (getvar "DWGNAME") starts with P, AutoCAD seems to interpret it as new line. If the attribute is single line it works well. Someone that have any suggestions to fix this problem.
Thanks in advance.
\Freddy
Can you please post the line of codes that fails wthin your routine ?
- check the following codes and try them yourself . it returns the name of the drawing correctely .
(defun c:Test nil
(entmakex (list (cons 0 "ATTDEF")
(cons 10 (getpoint "\n Specify point:"))
(cons 40 1.)
(cons 1 "Wawwwwww")
(cons 3 "Say something")
(cons 2 (strcat (getvar "DWGPREFIX") (getvar "DWGNAME")))
(cons 70 1)
)))
Try this way
(defun c:test (/ bk) (setq bk (vlax-ename->vla-object (car (nentsel "\nSelect Text/Atribute:")))) (vla-put-textstring bk (strcase (strcat (getvar 'Dwgprefix) (chr 92) (getvar 'Dwgname)) ) ) )
Great. It worked. I need to check the string from (getvar "DWGPREFIX") for directories that start with P though. Maybe there are other characters who behave as control codes as well. Perhaps it is best to rebuild the string again with ascii code 92
Anyway, thanks.
\Freddy
This works if the file name starts with letter P but not if any folder names starts with letter P. Someone that have a solution for that?
Thanks in advance.
\Freddy
Freddy,
Thought you had a handle on this?
Lets try another approach
(defun c:test (/ bk fn) (setq bk (vlax-ename->vla-object (car (nentsel "\nselect text/atribute:")) ) ) (setq fn (strcase (strcat (getvar 'dwgprefix) (getvar 'dwgname)))) (if (vl-string-search "\\P" fn) (vla-put-textstring bk (substr (vl-string-subst "\\" "\\\\" (vl-prin1-to-string fn)) 2 (+ (strlen fn) 2) ) ) (vla-put-textstring bk fn) ) )
Works great. Thanks. I searches and replace all the backslashes in stead of only \P in case there are other control codes that I'm not aware of. Thanks again.
\Freddy
Hi agian.
This is actually enough:
(defun c:test (/ bk fn)
(setq bk (vlax-ename->vla-object
(car (nentsel "\nselect text/atribute:"))
)
)
(setq fn (strcase (strcat (getvar 'dwgprefix) (getvar 'dwgname))))
(vla-put-textstring
bk
(vl-prin1-to-string fn)
)
)
\Freddy