Function Syntax: PlusMinusNumericValue Version: 1 Date: 05.10.2025 AI+https://www.theswamp.org/index.php?topic=51264.0 Description This AutoLISP program defines the command INV3, 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 DCL dialog for user input and stores defaults persistently in the Windows registry under HKCU\Software\INV3. Primary user workflow - The user runs INV3. - A dialog opens (DCL file written at runtime to the temp folder) to configure value, mode, rounding, and target object types. - The user selects objects in the drawing (selection is filtered by the chosen object types). - The routine parses each eligible object text, identifies numeric parts (supports dot and comma decimals), and applies the selected transformation. - If Dry run is enabled, the routine reports what would change without modifying the drawing. - The routine prints progress every 25 processed objects and finishes with a changed and skipped summary. Core functionalitiesArithmetic transformations on embedded numbers using one of the following modes: - Add or Subtract: adds a positive or negative increment value to the target numbers. - Multiply: multiplies target numbers by the entered value. - Divide: divides target numbers by the entered value, with divide-by-zero protection (leaves value unchanged when divisor is zero). - Set: replaces target numbers with the entered value. - Round: rounds target numbers to a specified number of places.Numeric substring detection inside mixed text strings, with support for: - Dot decimals and comma decimals, preserving the original decimal separator style in output when applicable. - Optional leading minus sign if Allow negatives is enabled.Targeting specific numeric occurrences within a string via a location field: - Single position (example 1). - Comma-separated indices (example 1,3,5). - All to apply to every numeric segment in each string. - List to indicate list-based behavior (internally treated as nil index list in this implementation).Formatting controls: - Keep zero padding for integer-like values to preserve digit width in certain cases (example 001 becomes 002 when incrementing). - Rounding precision control for computed results, with an attempt to retain or expand decimal places based on the original number and the input value.Object-type coverage (user-selectable toggles in the dialog): - TEXT and MTEXT via TextString manipulation. - ATTRIB and ATTDEF including MTEXT-style attributes where applicable. - INSERT block references: edits each attribute reference attached to the block reference. - LEADER (through its Annotation object where available). - MULTILEADER (prefers TextString, falls back to MText TextString). - DIMENSION through TextOverride, and optionally measured dimensions if enabled.Optional dimension measurement editing: when enabled, the routine can compute the measured value and treat it as editable even if the dimension does not have an override string.Selection management: provides Select All types and Select None toggles in the dialog for quick setup.Undo safety: wraps operations in an AutoCAD undo mark using vla-StartUndoMark and vla-EndUndoMark so changes are reversible as a single action group.Persistence of user defaults using Windows registry reads and writes: - Stored under HKEY_CURRENT_USER\Software\INV3 for values such as AddValue, LocValue, ModeIdx, RoundPlcs, KeepPad, AllowNeg, DryRun, ApplyAll, and object-type toggles. DCL user interface behavior - The DCL file is generated at runtime as inv3_dlg.dcl under the AutoCAD temp prefix path, then loaded via load_dialog. - The dialog provides three main configuration groups: - Input: value field, mode selector, round places field, keep padding toggle, allow negatives toggle, dry run toggle. - Target: location selector and apply-to-all toggle. - Object types: toggles for each supported entity type, plus select all and select none helpers and the measured dimension option. - The Round places edit box is enabled only when mode equals Round (mode index 4 in the popup list). - The OK action validates that a numeric value is present and attempts to accept comma decimals by translating comma to dot for parsing. Processing logic summary - The routine builds a selection filter string from the selected type toggles and uses ssget with a filter on DXF group 0 to collect only the intended object types. - For each selected object, it extracts the relevant text source (TextString, TagString, TextOverride, leader annotation text, multileader text, or block attribute TextString). - It splits the string into alternating numeric and non-numeric segments using parseString, which also attempts to skip certain basic MTEXT control codes when scanning. - It applies the arithmetic operation to only the selected numeric positions using adjustString2 and then writes the updated text back to the object, unless Dry run is enabled. - It counts changed and skipped items and prints a final summary, including periodic progress output every 25 objects processed. Important commands and key internal functions - Entry point command: c:INV3. - DCL creation and execution: inv3-WriteDCL, inv3-ShowDCL. - Persistence storage: vl-registry-read and vl-registry-write under HKCU\Software\INV3. - Number parsing and rounding: inv3-to-real, inv3-round. - Numeric detection and string segmentation: isPositionNumber, parseString. - Numeric replacement across selected indices: adjustString2. - Object filter builder for ssget: inv3-build-typefilter. Notable behaviors and edge cases - Divide by zero: in divide mode, if the divisor is zero, the routine leaves the original number unchanged to avoid runtime errors. - Comma decimals: the routine accepts comma input and preserves comma formatting if the original numeric substring used a comma separator. - Multiple numeric parts per string: location targeting applies per string, not across the whole drawing; position 1 means the first numeric segment in that specific text string. - Apply to all numeric parts: when enabled, the location value is forced to All, and all numeric segments are modified in each target string. - ATTDEF field choice: 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. - Measured dimensions: 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. - Selection scope: the routine uses ssget ":L", which typically targets the last selection set behavior; users should ensure they select the intended objects immediately when prompted. - No CMDECHO usage: the routine avoids modifying CMDECHO and instead uses ActiveX for most edits, reducing command-line noise and side effects.