Short description
Purpose: Increment or decrement numeric values inside TEXT, MTEXT, ATTDEF, and ATTRIB strings using a dialog-driven plus/minus value and target position Scope: Works on selected text-based entities, parsing each string to find embedded numbers, then modifies one or more of those numbers according to user settings Persistence: Stores last used increment value and location in the Windows registry under HKCUSoftwarePlusMinusNumericValue for reuse across sessions
Command:
Command: PlusMinusNumericValue (sometimes documented as INV3) How to run: Type PlusMinusNumericValue in the command line and press Enter Dialog: “Plus / Minus” dialog with two edit boxes: • Plus or Minus value — amount to add or subtract (supports integer or real) • Location [1..n] — which numeric block(s) to change: number index, “All”, or left empty for default 1 Selection: After dialog, selects TEXT, MTEXT, ATTRIB, ATTDEF entities with ssget filter
Description:
The routine opens a compact dialog where you enter a numeric increment/decrement value and specify which numeric segment(s) in the text to modify (by position, All, or via a later List prompt). It then scans the selected annotation objects, breaks each string into alternating numeric and non-numeric chunks, and applies the requested numeric adjustment to the chosen chunk(s) only, leaving surrounding text intact. For attributes, you can choose whether to modify the Tag or the Text string; for MTEXT, it respects basic control codes so numbers are not broken by formatting sequences. All changes are grouped in a single UNDO mark and the last-used dialog values are remembered via registry for the next run.
Helper function: (if any)
• _endUndo — Ends the active UNDO mark safely when the command completes or errors • _unloadDCL — Unloads the temporary DCL dialog resource if it is loaded • Custom *error* — Restores the previous *error*, prints messages for real errors, unloads the DCL, ends UNDO, and exits cleanly • PlusMinusNumericValue-Get / -Set — Read and write registry values under HKEY_CURRENT_USERSoftwarePlusMinusNumericValue for AddValue and LocValue • PlusMinusNumericValue-WriteDCL — Creates a temporary DCL file in the temp folder defining the “Plus / Minus” dialog with value and location fields and OK/Cancel buttons • PlusMinusNumericValue-ShowDCL — Loads the DCL, initializes tiles from registry or global defaults, handles OK/Cancel actions, updates registry and globals, and returns (value location) or nil • isPositionNumber — Tests whether a character at a given position is part of a number (digit, decimal point, optional leading minus when allowed) • parseString — Splits a string into a list of numeric and non-numeric substrings, with special handling for MTEXT control codes so they are kept as single tokens • adjustString — Core numeric modifier: chooses which numeric segments to change (by index, All, or interactive List), modifies them as integer or real, and rebuilds the final string while returning updated location default • myItoa — Helper inside adjustString that adjusts integer-like numbers while preserving leading zeros and sign where appropriate
Functionalities:
• Dialog-driven numeric change — User sets plus/minus value and which numeric position(s) to affect before any entity is touched • Integer and real support — Detects whether the input increment contains a decimal point and handles values as REAL when needed, preserving or extending decimal places • Location modes — Supports changing a specific numeric block by index, all numeric blocks at once, or using interactive List mode to review positions before deciding • MTEXT-aware parsing — Respects MTEXT control sequences (like C, H, etc.), treating them as units so formatting is preserved around changed numbers • Attribute mode choice — For ATTDEF objects, prompts once whether to modify Tag or Text, then applies this choice to all attribute definitions in the selection • Per-entity processing — Reads each entity’s current string, runs parseString and adjustString, and writes back the new string using the proper VLA setter (TagString or TextString) • Undo-safe update — Starts an UNDO mark before making changes and ends it afterwards, so the user can revert the entire batch in a single undo operation • Persistent defaults — Saves the last used numeric increment and location string to the registry and global variables, so the dialog auto-fills them next time • Negative number support — Optional global flag GlbVarInvAllowNeg allows proper recognition and editing of signed numbers
Result:
• Updated text content — All selected TEXT, MTEXT, ATTRIB, and ATTDEF objects have their targeted numeric portions incremented or decremented by the specified amount • Preserved formatting — Non-numeric characters, prefixes, suffixes, and MTEXT control codes remain unchanged, so labels and expressions keep their layout • Consistent precision — Decimal numbers are adjusted with respect to their existing precision (and the increment) with trailing zeros padded when required • Batch-friendly — Multiple selected entities are processed in one run with a single UNDO group, allowing quick sweeping renumbering or value adjustments • User convenience — Last used settings are remembered, making repeated plus/minus operations fast with minimal extra input
Images, animations etc.
Log in to download.
Log in
Log in
XAML code:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:src="clr-namespace:Autodesk.Windows;assembly=AdWindows">
<src:RibbonToolTip x:Key="PlusMinusNumericValue">
<src:RibbonToolTip.ExpandedContent>
<StackPanel>
<TextBlock Background="AntiqueWhite" TextAlignment="Left">
<Bold>Function Syntax: PlusMinusNumericValue</Bold>
<LineBreak/>
<Bold>Version: 1 Date: 05.10.2025</Bold>
<LineBreak/>
<LineBreak/>
<Hyperlink>AI+https://www.theswamp.org/index.php?topic=51264.0</Hyperlink>
<LineBreak/>
<Bold>Description</Bold><LineBreak/>
This AutoLISP program defines the command <Run Foreground="Red">INV3</Run>, which scans selected drawing objects for numeric substrings inside their displayed text and then modifies those numbers according to a chosen arithmetic mode. It uses a runtime-built <Run Foreground="DarkRed">DCL dialog</Run> for user input and stores defaults persistently in the Windows registry under <Run Foreground="DarkRed">HKCU\Software\INV3</Run>.<LineBreak/>
<LineBreak/>
<Bold>Primary user workflow</Bold><LineBreak/>
- The user runs <Run Foreground="Red">INV3</Run>.<LineBreak/>
- A dialog opens (DCL file written at runtime to the temp folder) to configure value, mode, rounding, and target object types.<LineBreak/>
- The user selects objects in the drawing (selection is filtered by the chosen object types).<LineBreak/>
- The routine parses each eligible object text, identifies numeric parts (supports dot and comma decimals), and applies the selected transformation.<LineBreak/>
- If <Run Foreground="DarkRed">Dry run</Run> is enabled, the routine reports what would change without modifying the drawing.<LineBreak/>
- The routine prints progress every 25 processed objects and finishes with a changed and skipped summary.<LineBreak/>
<LineBreak/>
<Bold>Core functionalities</Bold><LineBreak/>
• <Run Foreground="DarkRed">Arithmetic transformations on embedded numbers</Run> using one of the following modes:<LineBreak/>
- <Run Foreground="Red">Add or Subtract</Run>: adds a positive or negative increment value to the target numbers.<LineBreak/>
- <Run Foreground="Red">Multiply</Run>: multiplies target numbers by the entered value.<LineBreak/>
- <Run Foreground="Red">Divide</Run>: divides target numbers by the entered value, with divide-by-zero protection (leaves value unchanged when divisor is zero).<LineBreak/>
- <Run Foreground="Red">Set</Run>: replaces target numbers with the entered value.<LineBreak/>
- <Run Foreground="Red">Round</Run>: rounds target numbers to a specified number of places.<LineBreak/>
• <Run Foreground="DarkRed">Numeric substring detection</Run> inside mixed text strings, with support for:<LineBreak/>
- <Run Foreground="Red">Dot</Run> decimals and <Run Foreground="Red">comma</Run> decimals, preserving the original decimal separator style in output when applicable.<LineBreak/>
- Optional leading minus sign if <Run Foreground="DarkRed">Allow negatives</Run> is enabled.<LineBreak/>
• <Run Foreground="DarkRed">Targeting specific numeric occurrences</Run> within a string via a location field:<LineBreak/>
- Single position (example 1).<LineBreak/>
- Comma-separated indices (example 1,3,5).<LineBreak/>
- <Run Foreground="Red">All</Run> to apply to every numeric segment in each string.<LineBreak/>
- <Run Foreground="Red">List</Run> to indicate list-based behavior (internally treated as nil index list in this implementation).<LineBreak/>
• <Run Foreground="DarkRed">Formatting controls</Run>:<LineBreak/>
- <Run Foreground="DarkRed">Keep zero padding</Run> for integer-like values to preserve digit width in certain cases (example 001 becomes 002 when incrementing).<LineBreak/>
- Rounding precision control for computed results, with an attempt to retain or expand decimal places based on the original number and the input value.<LineBreak/>
• <Run Foreground="DarkRed">Object-type coverage</Run> (user-selectable toggles in the dialog):<LineBreak/>
- <Run Foreground="Red">TEXT</Run> and <Run Foreground="Red">MTEXT</Run> via TextString manipulation.<LineBreak/>
- <Run Foreground="Red">ATTRIB</Run> and <Run Foreground="Red">ATTDEF</Run> including <Run Foreground="DarkRed">MTEXT-style attributes</Run> where applicable.<LineBreak/>
- <Run Foreground="Red">INSERT</Run> block references: edits each attribute reference attached to the block reference.<LineBreak/>
- <Run Foreground="Red">LEADER</Run> (through its Annotation object where available).<LineBreak/>
- <Run Foreground="Red">MULTILEADER</Run> (prefers TextString, falls back to MText TextString).<LineBreak/>
- <Run Foreground="Red">DIMENSION</Run> through TextOverride, and optionally measured dimensions if enabled.<LineBreak/>
• <Run Foreground="DarkRed">Optional dimension measurement editing</Run>: when enabled, the routine can compute the measured value and treat it as editable even if the dimension does not have an override string.<LineBreak/>
• <Run Foreground="DarkRed">Selection management</Run>: provides <Run Foreground="Red">Select All types</Run> and <Run Foreground="Red">Select None</Run> toggles in the dialog for quick setup.<LineBreak/>
• <Run Foreground="DarkRed">Undo safety</Run>: wraps operations in an AutoCAD undo mark using <Run Foreground="Red">vla-StartUndoMark</Run> and <Run Foreground="Red">vla-EndUndoMark</Run> so changes are reversible as a single action group.<LineBreak/>
• <Run Foreground="DarkRed">Persistence of user defaults</Run> using Windows registry reads and writes:<LineBreak/>
- Stored under <Run Foreground="DarkRed">HKEY_CURRENT_USER\Software\INV3</Run> for values such as AddValue, LocValue, ModeIdx, RoundPlcs, KeepPad, AllowNeg, DryRun, ApplyAll, and object-type toggles.<LineBreak/>
<LineBreak/>
<Bold>DCL user interface behavior</Bold><LineBreak/>
- The DCL file is generated at runtime as <Run Foreground="DarkRed">inv3_dlg.dcl</Run> under the AutoCAD temp prefix path, then loaded via <Run Foreground="Red">load_dialog</Run>.<LineBreak/>
- The dialog provides three main configuration groups:<LineBreak/>
- <Run Foreground="DarkRed">Input</Run>: value field, mode selector, round places field, keep padding toggle, allow negatives toggle, dry run toggle.<LineBreak/>
- <Run Foreground="DarkRed">Target</Run>: location selector and apply-to-all toggle.<LineBreak/>
- <Run Foreground="DarkRed">Object types</Run>: toggles for each supported entity type, plus select all and select none helpers and the measured dimension option.<LineBreak/>
- The <Run Foreground="DarkRed">Round places</Run> edit box is enabled only when mode equals <Run Foreground="Red">Round</Run> (mode index 4 in the popup list).<LineBreak/>
- The OK action validates that a numeric value is present and attempts to accept comma decimals by translating comma to dot for parsing.<LineBreak/>
<LineBreak/>
<Bold>Processing logic summary</Bold><LineBreak/>
- The routine builds a selection filter string from the selected type toggles and uses <Run Foreground="Red">ssget</Run> with a filter on DXF group 0 to collect only the intended object types.<LineBreak/>
- For each selected object, it extracts the relevant text source (TextString, TagString, TextOverride, leader annotation text, multileader text, or block attribute TextString).<LineBreak/>
- It splits the string into alternating numeric and non-numeric segments using <Run Foreground="Red">parseString</Run>, which also attempts to skip certain basic MTEXT control codes when scanning.<LineBreak/>
- It applies the arithmetic operation to only the selected numeric positions using <Run Foreground="Red">adjustString2</Run> and then writes the updated text back to the object, unless <Run Foreground="DarkRed">Dry run</Run> is enabled.<LineBreak/>
- It counts changed and skipped items and prints a final summary, including periodic progress output every 25 objects processed.<LineBreak/>
<LineBreak/>
<Bold>Important commands and key internal functions</Bold><LineBreak/>
- Entry point command: <Run Foreground="Red">c:INV3</Run>.<LineBreak/>
- DCL creation and execution: <Run Foreground="Red">inv3-WriteDCL</Run>, <Run Foreground="Red">inv3-ShowDCL</Run>.<LineBreak/>
- Persistence storage: <Run Foreground="Red">vl-registry-read</Run> and <Run Foreground="Red">vl-registry-write</Run> under <Run Foreground="DarkRed">HKCU\Software\INV3</Run>.<LineBreak/>
- Number parsing and rounding: <Run Foreground="Red">inv3-to-real</Run>, <Run Foreground="Red">inv3-round</Run>.<LineBreak/>
- Numeric detection and string segmentation: <Run Foreground="Red">isPositionNumber</Run>, <Run Foreground="Red">parseString</Run>.<LineBreak/>
- Numeric replacement across selected indices: <Run Foreground="Red">adjustString2</Run>.<LineBreak/>
- Object filter builder for ssget: <Run Foreground="Red">inv3-build-typefilter</Run>.<LineBreak/>
<LineBreak/>
<Bold>Notable behaviors and edge cases</Bold><LineBreak/>
- <Run Foreground="DarkRed">Divide by zero</Run>: in divide mode, if the divisor is zero, the routine leaves the original number unchanged to avoid runtime errors.<LineBreak/>
- <Run Foreground="DarkRed">Comma decimals</Run>: the routine accepts comma input and preserves comma formatting if the original numeric substring used a comma separator.<LineBreak/>
- <Run Foreground="DarkRed">Multiple numeric parts per string</Run>: location targeting applies per string, not across the whole drawing; position 1 means the first numeric segment in that specific text string.<LineBreak/>
- <Run Foreground="DarkRed">Apply to all numeric parts</Run>: when enabled, the location value is forced to All, and all numeric segments are modified in each target string.<LineBreak/>
- <Run Foreground="DarkRed">ATTDEF field choice</Run>: there is an interactive option to modify Tag or Text for attribute definitions, with fallback to the other field when no numeric content is found in the chosen one.<LineBreak/>
- <Run Foreground="DarkRed">Measured dimensions</Run>: the routine can compute measurement strings for dimensions without overrides when the option is enabled, but it ultimately writes via TextOverride when available, which changes the dimension into an overridden display value.<LineBreak/>
- <Run Foreground="DarkRed">Selection scope</Run>: the routine uses <Run Foreground="Red">ssget ":L"</Run>, which typically targets the last selection set behavior; users should ensure they select the intended objects immediately when prompted.<LineBreak/>
- <Run Foreground="DarkRed">No CMDECHO usage</Run>: the routine avoids modifying CMDECHO and instead uses ActiveX for most edits, reducing command-line noise and side effects.<LineBreak/>
</TextBlock>
<Grid>
<Image Source="PlusMinusNumericValue_000.jpg" Stretch="Uniform"/>
</Grid>
<Grid>
<Image Source="IncreaseNumericValue.png" Stretch="Uniform"/>
</Grid>
<Grid>
<MediaElement
Source="2016-09-28_13-33-00.gif"
Stretch="Uniform"
Visibility="Visible"/>
</Grid>
</StackPanel>
</src:RibbonToolTip.ExpandedContent>
</src:RibbonToolTip>
</ResourceDictionary>
Additional info:
Learn more:
Open Website
Share this page:
Subscribe
Login
0 Comments
Oldest
Tags: 🏷️ Autocad Lisps, 🏷️ Text_menu
