Creating diagonal stacked number in MTEXT with Autolisp from a variable

  • Thread starter Thread starter Brian56
  • Start date Start date
B

Brian56

Hi there;

A colleague of mine and I are trying to create an MTEXT object from a calculated decimal number, saved as a variable in AutoLISP.

When making the calculation, we are able to get the value to be stored as a fractional number (say 6 1/4 for example), but when appending the variable into MTEXT, I want the space removed and the fraction to be diagonally stacked.

Can someone please help?

Thanks
 
What you need to do is to replace the fraction with the stacking codes:

"6 1/4" changes to "6{\\H0.7x;\\S1/4;}"

What I do is search for the fraction and then substitute:

(setq txt "6 1/4"
fratxt (routine to search for fractions in the string) ; should
return " 1/4"
frahgt "{\\H0.7x;\\S"
norhgt ";}"
txt (subst (strcat frahgt (substr fratxt 2) norhgt) fratxt txt)
)


The reason I don't show the (routine to search for fractions in the string)
is that what I have is a routine the replaces %%code fractions, i.e. if
%%251 is a stacked 1/4, the routine searches for %%251 and returns 1/4.

You might want to verify the \\S code, that makes horizontally stacked
fractions, I don't remember what the code is that makes diagonally stacked
fractions. You can probably find it in Help somewhere.
 
Thanks for the insight.

To diagonally stack a fraction, you need the # symbol between the numerator and denomenator of the fraction instead of the / symbol.

I had the idea of breaking down the fractional number into it's individual numbers, but was trying to get around this an easier way. My other option is to live with the horizontal stacking and save a bit of a headache.

Thanks again.
 
Back
Top