Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Try to put double backslash in a multiline attribute.

10 REPLIES 10
Reply
Message 1 of 11
fk
Advocate
724 Views, 10 Replies

Try to put double backslash in a multiline attribute.

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

10 REPLIES 10
Message 2 of 11
_Tharwat
in reply to: fk

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)
                  )))

Message 3 of 11
fk
Advocate
in reply to: _Tharwat

This is a single line attribute. Try a multiple line attribute.

 

\Freddy

 

Message 4 of 11
pbejse
in reply to: fk

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))      )
    )
  )

 

Message 5 of 11
fk
Advocate
in reply to: pbejse

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

 

Message 6 of 11
pbejse
in reply to: fk

Make it so Freddy

 

Glad i could help

 

Cheers

 

 

 

Message 7 of 11
fk
Advocate
in reply to: fk

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

Message 8 of 11
pbejse
in reply to: fk

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)
    )
  )

 

Message 9 of 11
fk
Advocate
in reply to: pbejse

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

Message 10 of 11
fk
Advocate
in reply to: fk

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

Message 11 of 11
pbejse
in reply to: fk

Yup, that will do, that is if you want to include the "" (double quote)

 

Glad it works for you

 

Cheers

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost