mstb Posted March 25, 2020 Posted March 25, 2020 hello every one I want to find the length of a text I don't mean the number of characters, for example every text has a height and length I want that length Thanks all Quote
BIGAL Posted March 25, 2020 Posted March 25, 2020 Not exact depends on font (/ (* (strlen str) ht) 1.4) ? It varies for say IIIIIII and WWWWWWW Quote
dlanorh Posted March 25, 2020 Posted March 25, 2020 1 hour ago, mstb said: hello every one I want to find the length of a text I don't mean the number of characters, for example every text has a height and length I want that length Thanks all Is the text already in the drawing or in a lisp Quote
mstb Posted March 25, 2020 Author Posted March 25, 2020 (edited) yes It is in the drawing I actually want to transfer the elevation codes that are in the drawing so that the insertion point falls on the dot point Of course, this way I have to use the right font, which is a problem (I mean, the font that gives a space to all the characters) excuse me for may bad english Edited March 25, 2020 by mstb Quote
eldon Posted March 25, 2020 Posted March 25, 2020 22 minutes ago, mstb said: ........so that the insertion point falls on the dot point It would be very handy if AutoCAD provided a dot justification. But the length of the text is not all that helpful, as elevation texts can have varying number of digits before the decimal point. Quote
mstb Posted March 25, 2020 Author Posted March 25, 2020 (edited) 31 minutes ago, eldon said: It would be very handy if AutoCAD provided a dot justification. But the length of the text is not all that helpful, as elevation texts can have varying number of digits before the decimal point. Exactly . First, I wanted to break the elevation code into three parts, one before and one last, almost self-contained and in the right position, but now I had three texts that I wanted to put together as if I were back in the first place. (defun c:s () (setq ss (ssget '((0 . "TEXT")))) (setq n (sslength ss)) (setq li nil) (setq k -1) (repeat n (setq k (1+ k)) (setq s (ssname ss k)) (setq en (entget s)) (setq ang (cdr (assoc 50 en))) (setq hi (cdr (assoc 40 en))) (setq la (cdr (assoc 8 en))) (setq po (cdr (assoc 11 en))) (setq txt (cdr (assoc 1 en))) (setq m (strlen txt)) (setq d1 "") (setq d2 "") (setq i 0) (setq j 1) (repeat m (setq i (1+ i)) (setq let (substr txt i 1)) (if (/= let ".") (cond ((= j 1) (setq d1 (strcat d1 let))) ((= j 2) (setq d2 (strcat d2 let))) ) (setq j (1+ j)) ) ) (setq li (append li (list (list d1 d2)))) ) (entmake (list (cons 0 "TEXT") (cons 8 "la") (cons 72 2) (cons 73 0) (cons 1 d1) (cons 10 po) (cons 11 po) (cons 40 hi) (cons 50 ang) ) ) (entmake (list (cons 0 "TEXT") (cons 8 "la") (cons 72 1) (cons 73 0) (cons 1 ".") (cons 10 po) (cons 11 po) (cons 40 hi) (cons 50 ang) ) ) (entmake (list (cons 0 "TEXT") (cons 8 "la") (cons 72 0) (cons 73 0) (cons 1 d2) (cons 10 po) (cons 11 po) (cons 40 hi) (cons 50 ang) ) ) (princ) ) It 's ok . But now I have three texts! Edited March 25, 2020 by mstb Quote
dlanorh Posted March 25, 2020 Posted March 25, 2020 43 minutes ago, mstb said: yes It is in the drawing I actually want to transfer the elevation codes that are in the drawing so that the insertion point falls on the dot point Of course, this way I have to use the right font, which is a problem (I mean, the font that gives a space to all the characters) excuse me for may bad english Look at Courier New or Monospac821BT Quote
mstb Posted March 25, 2020 Author Posted March 25, 2020 4 minutes ago, dlanorh said: Look at Courier New or Monospac821BT yes. Thanks.But it would have been much better if I hadn't changed the font Quote
eldon Posted March 25, 2020 Posted March 25, 2020 Perhaps this thread might provide food for thought Quote
mstb Posted March 25, 2020 Author Posted March 25, 2020 8 minutes ago, eldon said: Perhaps this thread might provide food for thought Thank you very much Quote
BIGAL Posted March 26, 2020 Posted March 26, 2020 30 year old civil design software did this not Autocad it had an option the decimal point was on the point. If the insertion point is one of the 9 points available pretty easy to move text. Maybe C-C if you want the decimal point then yes a problem. Like Dlanorh look at a monospaced font. Post an image of what you want. Quote
mstb Posted March 26, 2020 Author Posted March 26, 2020 2 hours ago, BIGAL said: 30 year old civil design software did this not Autocad it had an option the decimal point was on the point. If the insertion point is one of the 9 points available pretty easy to move text. Maybe C-C if you want the decimal point then yes a problem. Like Dlanorh look at a monospaced font. Post an image of what you want. Thank you very much Quote
mstb Posted March 26, 2020 Author Posted March 26, 2020 Where is wrong؟!!! (command "STYLE" "new" "italic" "" "" "" "" "" "") It's ok (command "STYLE" "new" "Monospac821 BT" "" "" "" "" "" "") But This one ?!!!! Quote
BIGAL Posted March 26, 2020 Posted March 26, 2020 Try this (entmake '( (0 . "STYLE") (100 . "AcDbSymbolTableRecord") (100 . "AcDbTextStyleTableRecord") (2 . "Mono") (70 . 0) (40 . 0.0) (41 . 1.0) (50 . 0.0) (71 . 0) (3 . "Monospac821 BT.TTF") (4 . "") ) ) Quote
dlanorh Posted March 26, 2020 Posted March 26, 2020 3 hours ago, mstb said: Where is wrong؟!!! (command "STYLE" "new" "italic" "" "" "" "" "" "") It's ok (command "STYLE" "new" "Monospac821 BT" "" "" "" "" "" "") But This one ?!!!! If you are going to use MonoSpac821 BT, I already have a lisp that returns the approximate middle of the dot (decimal point). It's scales OK, but was primally written to work with drawings in metres (text sizes less than 1.0) Quote
mstb Posted March 26, 2020 Author Posted March 26, 2020 1 hour ago, BIGAL said: Try this (entmake '( (0 . "STYLE") (100 . "AcDbSymbolTableRecord") (100 . "AcDbTextStyleTableRecord") (2 . "Mono") (70 . 0) (40 . 0.0) (41 . 1.0) (50 . 0.0) (71 . 0) (3 . "Monospac821 BT.TTF") (4 . "") ) ) Thank you very much Quote
mstb Posted March 26, 2020 Author Posted March 26, 2020 2 minutes ago, dlanorh said: If you are going to use MonoSpac821 BT, I already have a lisp that returns the approximate middle of the dot (decimal point). It's scales OK, but was primally written to work with drawings in metres (text sizes less than 1.0) Thank you very much Quote
dlanorh Posted March 26, 2020 Posted March 26, 2020 1 hour ago, BIGAL said: Try this (entmake '( (0 . "STYLE") (100 . "AcDbSymbolTableRecord") (100 . "AcDbTextStyleTableRecord") (2 . "Mono") (70 . 0) (40 . 0.0) (41 . 1.0) (50 . 0.0) (71 . 0) (3 . "Monospac821 BT.TTF") (4 . "") ) ) Stop stealing my Mono textstyle. Quote
Lee Mac Posted March 26, 2020 Posted March 26, 2020 There is no need to create temporary text objects, nor guess the width using the number of characters and a factor, just use the textbox AutoLISP function. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.