(defun c:DPre (/ SelectDim dimPrecision L_Decimal)
(setq SelectDim (entsel "\nSelect a Dimension to Change Precision: "))
(initget "1 2 3 4 5")
(setq dimPrecision (getkword "\nSpecify the Number of Decimal Place <1>, 2, 3, 4 or 5: "))
(if (not dimPrecision) (setq dimPrecision "1"))
(setq L_Decimal (expt 10.0 (- 0 (atof dimPrecision))))
(command "._DIMOVERRIDE" "dimrnd" L_Decimal "dimdec" (atoi dimPrecision) "" SelectDim "")
(princ)
)
Sorry for the error.
It is fixed. please see the code updated in my 1st post.
BTW what version are you using?
I am afraid that "AIDIMPREC" doesn't always return an actual value for the dimension.
It is controlled by "dimdec".
For example, if you set "dimdec" to "0" to the current dimstyle, then create a dimension for a 50mm line then you set "AIDIMPREC" to 5.
The dimension shows you "50.00000" which is right.
If you stretch the dimension to 100.12345mm, it won't return "100.12345" but gives you "10.00000".
HTH
(defun DimUnits ( mode / modeValue dim cun )
(setq modeValue (atoi mode))
(if (or (> modeValue 1) (< modeValue -1))
(princ "\n Invalid argument")
(progn
(setq dim (vlax-ename->vla-object (car (entsel "\n Select dimension: "))))
(setq cun (vla-get-PrimaryUnitsPrecision dim))
(vla-put-PrimaryUnitsPrecision dim (+ cun modeValue))
)
)
(princ)
)
(defun c:DRND0 () (SAA_DIM_ROUND nil nil "4")) ;round dimensions to 1"
(defun c:DRND () (SAA_DIM_ROUND nil "1" "4")) ;round dimensions to 1"
(defun c:DRNDFT () (SAA_DIM_ROUND nil "12" "4")) ;round dimensions to 12"
(defun c:DRND1 () (SAA_DIM_ROUND nil "1" "4")) ;round dimensions to 1"
(defun c:DRND12 () (SAA_DIM_ROUND nil "12" "4")) ;round dimensions to 12"
(defun c:DRND06 () (SAA_DIM_ROUND nil "6" "4")) ;round dimensions to 6"
(defun c:DRND2 () (SAA_DIM_ROUND nil "1/2" "4")) ;round dimensions to 1/2"
(defun c:DRND3 () (SAA_DIM_ROUND nil "1/4" "4")) ;round dimensions to 1/4"
(defun c:DRND4 () (SAA_DIM_ROUND nil "1/8" "4")) ;round dimensions to 1/8"
(defun c:DRND5 () (SAA_DIM_ROUND nil "1/16" "4")) ;round dimensions to 1/16"
(defun c:DRND6 () (SAA_DIM_ROUND nil "1/32" "5")) ;round dimensions to 1/32"
(defun c:DRND7 () (SAA_DIM_ROUND nil "1/64" "6")) ;round dimensions to 1/64"
(defun c:DRND8 () (SAA_DIM_ROUND nil "1/128" "7")) ;round dimensions to 1/128"
(defun c:DRND9 () (SAA_DIM_ROUND nil "1/256" "8")) ;round dimensions to 1/256"
(defun SAA_DIM_ROUND ( ss1 rnd ddec) ;round dimensions to passed in value
(setvar "cmdecho" 0)
(if (not rnd) (setq rnd (rtos (getvar "dimrnd")))) ;no value defaults to current setting
(if (not ss1)
(progn
(princ (strcat "\nSelect dimensions to round-off to " rnd"\": "))
(setq ss1 (ssget ":L" '((0 . "DIMENSION")))) ;no value defaults to current setting
)
)
(if ss1 (progn
(command "_.dim1" "override" "DIMRND" rnd "DIMDEC" ddec "DIMALTRND" rnd "DIMALTD" ddec "" ss1 "")
(setvar "cmdecho" 1)
))
(princ)
)
Try this:Quote(defun c:DPre (/ SelectDim dimPrecision L_Decimal)
(setq SelectDim (entsel "\nSelect a Dimension to Change Precision: "))
(initget "1 2 3 4 5")
(setq dimPrecision (getkword "\nSpecify the Number of Decimal Place <1>, 2, 3, 4 or 5: "))
(if (not dimPrecision) (setq dimPrecision "1"))
(setq L_Decimal (expt 10.0 (- 0 (atof dimPrecision))))
(command "._DIMOVERRIDE" "dimrnd" L_Decimal "dimdec" (atoi dimPrecision) "" SelectDim "")
(princ)
)
HTH
BTW what version are you using?
I am afraid that "AIDIMPREC" doesn't always return an actual value for the dimension.
It is controlled by "dimdec".
For example, if you set "dimdec" to "0" to the current dimstyle, then create a dimension for a 50mm line then you set "AIDIMPREC" to 5.
The dimension shows you "50.00000" which is right.
If you stretch the dimension to 100.12345mm, it won't return "100.12345" but gives you "10.00000".
HTH