Drafting cost estimates, bill of quantities (BOQ) tables, or structural schedules in AutoCAD often requires formatting large numbers with thousands separators (turning 1234567 into 1,234,567). Manually editing dozens of text entities just to insert commas is tedious. On the flip side, when you need to extract raw numbers into Excel for formulas, existing commas can mess up your data parsing.
The VCC.lsp (Value Comma Change) routine provides a quick two-way fix. It lets you batch insert or strip out thousands separators across selected text objects in seconds—without breaking decimal values or layer formatting.
Why Use VCC.lsp for Numeric Formatting?
Two-Way Batch Processing: Choose whether to append thousands commas for clean presentation or remove them for raw data extraction.
Decimal Protection: The script accurately identifies decimal points and only applies comma formatting to the whole number portion, keeping your precision data intact.
Universal Text Support: Works smoothly on both standard single-line
TEXTand multilineMTEXTentities in a single selection.
Step-by-Step Instructions
Load
VCC.lspinto your AutoCAD session using theAPPLOADcommand.Type
VCCin the command line and hit Enter.Select all the
TEXTorMTEXTobjects you want to modify, then press Enter.Choose your formatting mode from the prompt
[Add(A)/Remove(R)]:Press Enter (or type A) to insert thousands separators.
Type R to remove existing commas from numbers.
All selected numerical values will update instantly across your sheet.
AutoLISP Code (VCC.lsp)
Copy the code below and save it as VCC.lsp inside your AutoCAD support folder:
(vl-load-com)
(defun c:VCC ( / *error* acadObj doc oldOsme ss mode i sn elist is-m obj txt res dec len)
(setq acadObj (vlax-get-acad-object)
doc (vla-get-activedocument acadObj)
)
(defun *error* (msg)
(if oldOsme (setvar "OSMODE" oldOsme))
(vla-EndUndoMark doc)
(princ "\nCAD Lisp [www.daolpro.com]")
(princ)
)
(vla-StartUndoMark doc)
(setq oldOsme (getvar "OSMODE"))
(if (setq ss (ssget '((0 . "TEXT,MTEXT"))))
(progn
(initget "Add Remove")
(if (not (setq mode (getkword "\nChoose option [Add(A)/Remove(R)] (Add): ")))
(setq mode "Add")
)
(setq i 0)
(repeat (sslength ss)
(setq sn (ssname ss i) elist (entget sn) is-m (= (cdr (assoc 0 elist)) "MTEXT"))
(if is-m
(setq obj (vlax-ename->vla-object sn) txt (vla-get-textstring obj))
(setq txt (cdr (assoc 1 elist)))
)
(while (vl-string-search "," txt)
(setq txt (vl-string-subst "" "," txt))
)
(cond
((= mode "Remove")
(if is-m (vla-put-textstring obj txt) (entmod (subst (cons 1 txt) (assoc 1 elist) elist)))
)
((= mode "Add")
(if (not (vl-catch-all-error-p (vl-catch-all-apply 'distof (list txt))))
(progn
(setq res "" dec "")
(if (vl-string-search "." txt)
(setq dec (substr txt (1+ (vl-string-search "." txt)))
txt (substr txt 1 (vl-string-search "." txt)))
)
(setq len (strlen txt))
(while (> len 3)
(setq res (strcat "," (substr txt (- len 2) 3) res)
txt (substr txt 1 (- len 3))
len (strlen txt))
)
(setq res (strcat txt res))
(if (/= dec "") (setq res (strcat res "." dec)))
(if is-m (vla-put-textstring obj res) (entmod (subst (cons 1 res) (assoc 1 elist) elist)))
)
)
)
)
(setq i (1+ i))
)
)
(prompt "\nNo TEXT or MTEXT entities selected.")
)
(if oldOsme (setvar "OSMODE" oldOsme))
(vla-EndUndoMark doc)
(princ "\nCAD Lisp [www.daolpro.com]")
(princ)
)
Quick Drafting Tip
When exporting drawing tables to external Excel sheets, run VCC in Remove mode beforehand to ensure numbers copy over as raw numerical data without triggering text format warnings in spreadsheet applications.

Post a Comment