Creating diagonal stacked number in MTEXT with Autolisp from a variable

Discussion in 'AutoCAD' started by Brian56, Feb 10, 2005.

  1. Brian56

    Brian56 Guest

    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
     
    Brian56, Feb 10, 2005
    #1
  2. 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.
     
    Allen Johnson, Feb 10, 2005
    #2
  3. Brian56

    Brian56 Guest

    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.
     
    Brian56, Feb 11, 2005
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.