Arepo Posted March 15, 2018 Share Posted March 15, 2018 TxtFormat.pdf Can anyone help me format some dimension text through LISP? I would like to get the text formatted as horizontally stacked fractions w/ no space between inches and fractions. E.g. (setq txt 3.08203) (rtos txt 4 5) gets me 3 3/32", but I want it formatted as 3 followed by 3/32" horizontally stacked & no space between them. Thank you. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted March 15, 2018 Share Posted March 15, 2018 Your example result shows them vertically stacked? Quote Link to comment Share on other sites More sharing options...
Arepo Posted March 15, 2018 Author Share Posted March 15, 2018 I'm trying to get the text formatted as shown in pdf attached, I guess AutoCAD calls it horizontally stacked, but I think it can be called vertically as well, basically I want it as inches (no feet) followed by inch fractions stacked on top of each other, followed by " (inch sign), no spaces anywhere. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 16, 2018 Share Posted March 16, 2018 This is two seperate things dimensions and text if you rtos the dim value then its a string not a dimension any more, so would need to use I think mtext, thank god for metric. If its a dimension may be able to do as dimension style but would possibly reflect true dimension length. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted March 16, 2018 Share Posted March 16, 2018 You do not need Lisp code for this. You can set up a dim style. DIMLUNIT=5 DIMFRAC=0 DIMPOST=""" Quote Link to comment Share on other sites More sharing options...
Arepo Posted March 16, 2018 Author Share Posted March 16, 2018 Thanks, but I already had variables set this way and it won't work. This text overrides the true dimension text and is shown in ft & in and diagonal fractions, but my other dimensions are inches only and horizontal fractions. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 17, 2018 Share Posted March 17, 2018 As I said earlier what happens if you dont rtos the txt. The dimension style handles the way it displays the value. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted March 18, 2018 Share Posted March 18, 2018 @Arepo: Maybe I have misunderstood, but I think setting up a dimstyle would work. See the attached dwg. TestDimstyle.dwg Quote Link to comment Share on other sites More sharing options...
Arepo Posted March 20, 2018 Author Share Posted March 20, 2018 Setting up a dimstyle works, but the problem is that the text extracted from obj definition (42 . 3.03975) is shown as 3.03975 (in this case), formatted in decimal inches. So when I paste it in a different place it loses its format shown in dimstyle. I was trying to extract the text from dimension obj, keep its format shown there or manipulate 3.03975 in a way that shows fractional inches & paste it somewhere else. I was basically trying to get a function whose input would be 3.0975 and output formatted as horiz. fractional inch, if there is such a thing. Thanks for your help, anyway. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted March 20, 2018 Share Posted March 20, 2018 Reverse engineering formatted MTEXT I came up with this: (defun c:foo (/ i n s) (if (setq i (getdist "\nEnter distance: ")) (progn (setq s (rtos i 4 5)) (setq s (cond ((setq n (vl-string-search " " s)) (substr (rtos 500.03975 4 5) 1 5) (strcat "\\A1;" (substr s 1 n) "{\\H0.7x;\\S" (vl-string-right-trim "\"" (substr s (+ 2 n))) ";}\"" ) ) (s) ) ) (entmake (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(67 . 0) '(8 . "MTEXT") '(100 . "AcDbMText") (cons 10 (getvar 'viewctr)) (cons 40 (/ (getvar 'viewsize) 16.)) '(41 . 0.0) '(46 . 0.0) '(71 . 5) '(72 . 1) (cons 1 s) '(7 . "ROMANS") '(11 1.0 0.0 0.0) ) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Arepo Posted March 21, 2018 Author Share Posted March 21, 2018 Thank you RonJonp, you put a lot of effort into this, I appreciate your help. It works nicely. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted March 21, 2018 Share Posted March 21, 2018 Thank you RonJonp, you put a lot of effort into this, I appreciate your help. It works nicely. Glad to help Quote Link to comment Share on other sites More sharing options...
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.