Wednesday, March 29, 2006


You can place superscripts or subscripts in your Mtext by cheating the Stacking options.

Mtext has several different ways to display fractions (or tolerancing.) AutoCAD calls this formatting stacking. By default, Mtext displays fractions entered with a forward slash as vertically stacked, fractions using the number sign as diagonally stacked, and fractions (or tolerances) with a caret as vertically stacked with no line.

Notice the last option. What would happen if we stacked something without a value on one side of the caret? Yep, we get a subscript or a superscript. Consider the following example Mtext:

To force stacking, highlight the caret and the text, right-click, and choose Stack from the menu. Notice in the example above that we place the caret before the subscripted text but after the superscripted text. Top and Bottom respective values are blank (that is, don't select anything.) For greater control over stacking options, select Stack Properties from the right-click menu.


At 10:31 PM , Anonymous David said...

Can you do the superscript for the third number after coma with lisp? I need to have 1.345 written 1.34 and 5 up. I've seen it in Archicad but I only use AutoCAD.

At 3:45 PM , Anonymous Anonymous said...

Yes you can. In dimensioning this is fairly simple. The code for stacking is \S[top][seperator][bottom]; The seperator options are / for horizontal line, # for diagonal line, and ^ for no line.

If you are trying to accomplish this in an mtext situation, it is a little bit trickier. Start by creating a fraction. In your case try "1.34 5/8" If you have autostack on then "5/8" will stack itself otherwise select "5/8", right click and choose "stack" from the menu. Once the fraction is stacked, select it, right click, and select "properties" from the menu. Then you can delete the bottom half of the fraction and choose "Tolerance" for the style. I'm sure there must be an easier way to accomplish this, but this works without too much effort.

At 8:25 PM , Blogger Ward Romberger said...

That's not quite David asked for. He wanted a lisp routine to do it. Here's one (very simple, with little decision making ability and no error checking) that will do what he asked. It takes the third character following a comma and superscripts it.

For example, in the string
LEN = 1,234,567 LF
The characters 4 and 7 would be superscripted.

(defun c:3rdup ( / 3rd ent len new pos str )
(setq ent (entget (car (entsel)))
str (cdr (assoc 1 ent))
new "")
(setq pos (vl-string-search "," str))
(setq 3rd (substr str (+ pos 4) 1)
new (strcat new (substr str 1 (+ pos 3)) "{\\S" 3rd "^;}")
str (substr str (+ pos 5))))
(setq new (strcat new str)
ent (subst (cons 1 new) (assoc 1 ent) ent))
(entmod ent)

This code likely looks horrible in Blogger. Cut and Paste it into the Visual LISP Editor (VLISP) and type Ctrl-Alt-F to format the code into a more readable form.


Post a Comment

Subscribe to Post Comments [Atom]

<< Home