Format text in Fields

Discussion in 'AutoCAD' started by randy benson, Jun 8, 2004.

  1. randy benson

    randy benson Guest

    I don't see a way to format an objects' length to say, 2 decimal places in a
    Field, and therefore in a Table, using the command line; is there a way to
    do it programmatically using vlisp/VBA?
     
    randy benson, Jun 8, 2004
    #1
  2. Here is another way to do it, _independent_ of LUPrec, given length of
    2.633:

    \f "%.3f" = 2.633
    \f "%.2f" = 2.63
    \f "%.1f" = 2.6
    \f "%.0f" = 3

    Use the above format string in the field expression rather than the
    predefined ones. A quick way to do this is to select the object in the field
    dialog and then it's Length property, copy the resulting expression to a
    text editor, and replace the format string (the string after the \f. Copy
    the edited field expression into the MText editor, or other text-based
    editing interface.

    Note that the above format uses decimal units only.

    --
    R. Robert Bell


    Hi Randy,

    Just before placing the field make sure you have (setvar "luprec" 2) and
    that will doit... also the previous fields with a different precision will
    be updated if you use the regen command.

    I have not done it with code or playing to much with field objects...

    hth
     
    R. Robert Bell, Jun 9, 2004
    #2
  3. Yeah, the only downside is you are stuck with decimal units.

    --
    R. Robert Bell


    Great info Roberto!,

    now one can copy the field with a desired presicion [since those made with
    this are not updated with regen even if someone changes the luprec sysvar]
    to another object, from the mtedit command, much easier... i guess.

    le
     
    R. Robert Bell, Jun 9, 2004
    #3
  4. randy benson

    randy benson Guest

    Excellent! Thanks much. Is this documented anywhere?
     
    randy benson, Jun 10, 2004
    #4
  5. Not to my knowledge.
     
    R. Robert Bell, Jun 11, 2004
    #5
  6. randy benson

    krispy Guest

    instead of "%.0f" use "%pr0" which sets the precision regardless of units.
    For example:
    \f "%lu1%ct4%pr0 SQ. FT."
    sets linear units to scientific (lu1)
    converts the area from square inches to square feet (ct4)
    and set precision to 0 decimal places (pr0)
     
    krispy, Nov 2, 2004
    #6
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.