Jump to content

Dimension Text Format


Arepo

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...