%  platform  category

Adding, multiplying and rounding numbers inside DWG drawing texts - NumInText.

You can use the add-on application NumInText to perform operations on numbers written inside AutoCAD drawing objects - texts and block attributes. It works both on purely numerical texts and on numbers contained in longer texts and MTexts. You can round the numbers (also in non-standard steps like 0.5), add (or subtract) constant values to them, multiply (or divide) them by a constant value, left- or right-fill them to a fixed number of digits, cut off higher orders, add prefix or suffix, or delete the numbers. The application can also handle numbers combined with MText control codes.

You can download the add-on application CADstudio NumInText from www.cadstudio.cz/download, load it with APPLOAD and launch it by typing the command NumInText. After you select the texts to process, the application prompts for the requested operation or setup. In the setup options you can set the processing of "comma" (not only "dot") as the decimal separator, whether to ignore integer numbers (process just real numbers), use trailing zeroes (full decimal places), whether to keep the original number of decimal places (or round them) inside the arithmetic operations, whether to avoid MText control codes, or whether to process just filtered numbers inside a given range of values (e.g. -9.9 to +9.9) or just attributes matching a given tag mask (the attribute can be picked).

You can paste the report of all performed replacements with Ctrl+V to AutoCAD or any other application.

You can use the following operations to process the matching numbers:

• Add - add (or subtract, negative value) the given value to the numbers in drawing texts
• Multiply - multiply (or divide, the 1/x value) the numbers in drawing texts by the given value - e.g. with a conversion rate of length units (mm/inch)
• Round - you can enter the number of requested decimal places to round real numbers in the selected texts (0=integer, a negative number means higher orders - '-2'=100). The options Stepped, Up and Down allow to round the number in arbitrary steps (e.g. 0.25, 0.5 or 100) - you can round arithmetically, always up or always down.
• FixLength - fill the number from the left side with leading zeroes to the specified total number of digits, if you specify the number of digits as negative, the zeroes are added from the right side (trailing decimal zeroes)
• LeftCut - cuts of higher orders from the number, e.g. by entering "100", the thousands and higher orders will be cut off
• Pfix - adds a specified prefix and/or suffix to the numbers - e.g. physical units
• Separator - you can replace the decimal separator with e.g. a comma "," or space " ", you can also use a special "station" formatting ("KM 12+345 6")
• Delete - erase the numbers in drawing texts or replace them with the specified string, either with a single string for the whole number, or with a character replacing each digit individually

You can use these LISP variables to preset some application parameters (from Setup):

```(setq _numintextDoComma T) ; respect decimal comma
(setq _numintextDoInts T) ; process also integers
(setq _numintextDecimals 2) ; default number of decimal places
(setq _numintextNoKeepDP T) ; do not keep the original number of dec.places for math ops
(setq _numintextRoundMode "Stepped") ; rounding mode
(setq _numintextRoundTo 0.5) ; round step in stepped modes
(setq _numintextRoundToDP -2) ; round decimals in stepped modes
(setq _numintextSafeMText T) ; avoid changing MText codes
(setq _numintextNoTrail0 T) ; do not add trailing "0" (full dec.places)
(setq _numintextPrefix "") ; prefix
(setq _numintextPostfix "") ; suffix
(setq _numintextDPsep "") ; or "STATION"
(setq _numintextNoClipboard T) ; do not use Clipboard for reports
```

Most of the NumInText functions are available in the freeware (trial) version, some functions require an activation code which can be purchased on CAD eShop. See the CADSTUDIOREG command.

 See also: Tip 11492: Adding selected numbers in drawing texts - counting numbers (GrSelNum). Tip 11389: Readability of annotations, white halo on AutoCAD texts. Tip 10628: Ugly (jaggy) TrueType texts in DWG drawing. Tip 10514: PDF published from AutoCAD 2016 has rectangles displayed around texts. Tip 10497: Multileader with automatic text mask.