ok, I have found this lisp below, I would like to modify it so that I can specify the decimal places.
Any idea what to change?
I assume it's this bit, but I dont understand enough of it to be able to modify it.
; @GetPrecision (local defun)
;
; determine a number's precision
;
(defun @GetPrecision ( Number / i )
(if (eq Number (fix Number))
0
(cond
( (progn (setq i 16) (numberp Number))
(while
(eq Number
(read (rtos Number 2 (setq i (1- i))))
)
)
(1+ i)
here is the full lisp
;////////////////////////////////////////////////////////////////////////////
;
; IncAtts.lsp * Version 1.0 * 2002/10/03
;
; Increment (or Decrement) attribute values.
;
; Copyright © 2002 Michael Puckett . All Rights Reserved
;
;////////////////////////////////////////////////////////////////////////////
;
; You are granted a temporary license to use the utility(s) defined
; within this source code without fee subject to the following terms:
;
; Michael Puckett, hereafter referred to as "THE AUTHOR", has
; provided this utility(s) as is, complete with all faults,
; imperfections and errors. THE AUTHOR specifically and explicitly
; disclaims any implied warranty of merchantability or fitness for
; any particular use. THE AUTHOR does not warrant that the operation
; of the utility(s) will be uninterrupted or error free. the user of
; this utility(s) assumes all responsibility for any problems that may
; result, either directly or indirectly, from the use of this utility(s).
;
; THE AUTHOR reserves the right to revoke the temporary license at
; any time for any reason.
;
; If you do not fully and completely agree with all these terms and
; conditions you must not use this utility(s) and must remove the
; source code from your computer and all storage media immediately.
;
;////////////////////////////////////////////////////////////////////////////
(defun c:IncAtts
( /
;
; local defuns
;
@Begin @End @Trim @Children @StrToNum
@GetUnits @GetPrecision @IncrAtts
;
; local vars
;
i ss TagSpec ByValue
)
;
; @Begin (local defun)
;
; initialize vars, enable undo
; sequence if possible
;
(defun @Begin ()
(setvar "cmdecho" 0)
(while (eq 8 (logand 8 (getvar "undoctl")))
(command ".undo" "_end")
)
(if (zerop (logand 2 (getvar "undoctl")))
(if (eq 1 (logand 1 (getvar "undoctl")))
(command ".undo" "_begin")
)
)
)
;
; @End (local defun)
;
; deinitialize vars, terminate undo
; sequence if possible
;
(defun @End ()
(if (eq 8 (logand 8 (getvar "undoctl")))
(command ".undo" "_end")
)
(setvar "cmdecho" 1)
(princ)
)
;
; @Trim (local defun)
;
; Remove leading / Trailing white space.
;
(defun @Trim ( Text / i)
(cond
((zerop (setq i (strlen Text))) Text)
((< (ascii Text) 33) (@Trim (substr Text 2)))
((< (ascii (substr Text i)) 33) (@Trim (substr Text 1 (1- i))))
(t Text)
)
)
;
; @Children (local defun)
;
; Return list of entities that are a child
; of the parent entity supplied, eg: a block
; with attributes or a polyline with vertices
;
(defun @Children ( Ename / Data Result )
(if (assoc 66 (entget Ename))
(reverse
(while
(/= "SEQEND"
(cdr
(assoc 0
(setq Data
(entget
(setq Ename
(entnext Ename)
)
)
)
)
)
)
(setq Result
(cons (cdr (assoc -1 Data))
Result
)
)
)
)
)
)
;
; @StrToNum (local defun)
;
; Convert a string to value if possible,
; returning the best converted value.
;
(defun @StrToNum ( Str / Num )
(if
(setq Num
(cond
( (eq 'str (type (setq Str (@Trim Str))))
(cond
((distof Str 2))
((distof Str 3))
((distof Str 5))
((distof Str 1))
)
)
)
)
(if (wcmatch Str "*`.*")
Num
(fix Num)
)
)
)
;
; @GetUnits (local defun)
;
; determine string's engineering units if applicable
;
(defun @GetUnits ( Str )
(if (eq 'str (type (setq Str (@Trim Str))))
(cond
((distof Str 2) 2)
((distof Str 3) 3)
((distof Str 5) 5)
((distof Str 1) 1)
)
)
)
;
; @GetPrecision (local defun)
;
; determine a number's precision
;
(defun @GetPrecision ( Number / i )
(if (eq Number (fix Number))
0
(cond
( (progn (setq i 16) (numberp Number))
(while
(eq Number
(read (rtos Number 2 (setq i (1- i))))
)
)
(1+ i)
)
)
)
)
;
; @IncrAtts (local defun)
;
; does the actual grunt work for a given
; insert's child entities (attributes)
;
(defun @IncrAttribs
( Parent TagSpec ByValue /
Modifed Data Str Value Pair
)
(foreach Child (@Children Parent)
(cond
( (and
; tag name is acceptable ...
(wcmatch
(strcase
(cdr (assoc 2 (setq Data (entget Child))))
)
TagSpec
)
; data appears numerical
(setq Value
(@StrToNum
(setq Str
(cdr
(setq Pair
(assoc 1 Data)
)
)
)
)
)
)
; modify it
(entmod
(subst
; put data back in format as original
(cons 1
(rtos
(+ Value ByValue)
(@GetUnits Str)
(@GetPrecision Value)
)
)
Pair
Data
)
)
; flag that a child
; entity was modified
(setq Modified T)
)
)
)
; refresh the parent
; entity (the insert)
(if Modified (entupd Parent))
)
;
; "main"
;
(cond
( (setq
i -1
ss (ssget '((0 . "insert")(66 . 1)))
)
(@Begin)
(setq TagSpec
(if
(eq ""
(setq TagSpec
(getstring
"\nEnter attribute tag spec <*>: "
)
)
)
"*"
(strcase TagSpec)
)
)
(initget 1)
(setq ByValue (getreal "\nEnter Incr/Decr (+/-) value: "))
(repeat (sslength ss)
(@IncrAttribs (ssname ss (setq i (1+ i))) TagSpec ByValue)
)
(@End)
)
)
(princ)
)
; < end c:IncAtts >
Thanks