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

Annoying MTEXT characters

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Anonymous
706 Views, 7 Replies

Annoying MTEXT characters

I have file paths that include folders beginning with P and C1. When I (entmake these to an MTEXT entity I get a new paragraph (\\P) and red text (\\C1). Anybody know how to get around this?

 

 

S

7 REPLIES 7
Message 2 of 8
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

I have file paths that include folders beginning with P and C1. When I (entmake these to an MTEXT entity I get a new paragraph (\\P) and red text (\\C1). Anybody know how to get around this?

....


A.  Can you use plain Text instead of Mtext?

B.  Can you get it to use the single-forward-slash instead of the double-back-slash format?  [That would require conversion if you're getting the content from something like the DWGPREFIX System Variable.]

C.  Maybe a substitution of (chr ...) for some character(s) or other [whether the slashes or the P and C I couldn't say off-hand].

Kent Cooper, AIA
Message 3 of 8
Kent1Cooper
in reply to: Anonymous

Or maybe, before you use it as Mtext content, you could replace all double backslashes in the filepath with two backslashes and a space.  That still ought to read well enough informationally, to someone looking at a printed drawing.

 

I find other letters also make trouble -- see codes in Help under "Format Multiline Text in an Alternate Text Editor".

 

[Not only do the double backslashes give you that problem in Mtext content, but the website thinks they're links to something, which it can't find if you pick on them.]

Kent Cooper, AIA
Message 4 of 8
Hallex
in reply to: Anonymous

Give this a shot

(setq s "C:\\P\\Blabla\\C1\\aha.txt")
(command "-mtext" (getpoint) "_w" "0" (vl-prin1-to-string s) "")

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 5 of 8
Anonymous
in reply to: Hallex

Chaps,

 

Both good solutions.

 

I'd already resorted to TEXT over MTEXT and this actually helps me with adding hyperlinks. The flipping of the slash might prove unfavourable with the bosses, but the additional space between the slash and P or C is viable.

 

(vl-prin1-to-string does the job although it includes double-quotes which may (or may not) be able to be removed - I'll look into it further.

 

Thanks for the help.

 

S

Message 6 of 8
Shneuph
in reply to: Anonymous

(Defun C:Mtext_of_Dwgprefix (/ mtlist)

(setq text (getvar "dwgprefix"))

 

(setq count 1)
(repeat (strlen text)
  (if (= (substr text count 1) "\\")
    (progn
      (setq text (strcat (substr text 1 count) "\\" (substr text (1+ count))))
      (setq count (+ count 1))
    );progn
  );if
  (setq count (1+ count))
);repeat
   

(cons 1 (princ (strcat (getvar "dwgprefix"))))

(setq mtlist (list
  '(0 . "MTEXT")
  '(100 . "AcDbEntity")
  '(67 . 0)
  '(410 . "Model")
  '(8 . "0")
  '(100 . "AcDbMText")
  (cons 10 (getpoint "\nSelect Point for Mtext: "))
  '(40 . 0.0)
  '(46 . 0.0)
  '(71 . 1)
  '(72 . 5)
  (cons 1 text)
  '(7 . "Standard")
  '(210 0.0 0.0 1.0)
  '(11 1.0 0.0 0.0)
  '(50 . 0.0)
  '(73 . 1)
  );list
);setq
 
(entmake mtlist)

(princ)
);defun

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
Message 7 of 8
Shneuph
in reply to: Shneuph

NO!  This is better...

 

 

 

(Defun C:Mtext_of_Dwgprefix (/ mtlist)

(setq text (getvar "dwgprefix"))

(setq count 1)
(repeat (strlen text)
  (if (= (substr text count 1) "\\")
    (progn
      (setq text (strcat (substr text 1 count) (substr text count)))
      (setq count (+ count 1))
    );progn
  );if
  (setq count (1+ count))
);repeat
   

(cons 1 (princ (strcat (getvar "dwgprefix"))))

(setq mtlist (list
  '(0 . "MTEXT")
  '(100 . "AcDbEntity")
  '(67 . 0)
  '(410 . "Model")
  '(8 . "0")
  '(100 . "AcDbMText")
  (cons 10 (getpoint "\nSelect Point for Mtext: "))
  '(40 . 0.0)
  '(46 . 0.0)
  '(71 . 1)
  '(72 . 5)
  (cons 1 text)
  '(7 . "Standard")
  '(210 0.0 0.0 1.0)
  '(11 1.0 0.0 0.0)
  '(50 . 0.0)
  '(73 . 1)
  );list
);setq
 
(entmake mtlist)

(princ)
);defun

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
Message 8 of 8
Anonymous
in reply to: Shneuph

How stupid am I? [rhetorical]

 

I'd started with the contents of an RTEXT which already had the \\\\ in it. Thinking that looked silly I changed them to \\... and that's when the problems started!

 

An alternative to Shneuph Doggy-Dog's (repeat could be,

 

  (while (vl-string-search "\\" text)
    (setq text (vl-string-subst "%%%%" "\\" text))
    )
  (while (vl-string-search "%%%%" text)
    (setq text (vl-string-subst "
\\\\" "%%%%" text))
    )

 

or...

 

  (foreach txt '(("%%%%" "\\") ("\\\\" "%%%%"))
    (while (vl-string-search (car txt) text)
      (setq text (vl-string-subst (cadr txt) (car txt) text))
      )
    )


S

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

Post to forums  

Autodesk Design & Make Report

”Boost