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
Solved! Go to Solution.
@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].
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.]
Give this a shot
(setq s "C:\\P\\Blabla\\C1\\aha.txt") (command "-mtext" (getpoint) "_w" "0" (vl-prin1-to-string s) "")
~'J'~
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
(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
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
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