Author Topic: Tolerance on dimensions and dimension style  (Read 742 times)

0 Members and 1 Guest are viewing this topic.

Romero

  • Newt
  • Posts: 25
Tolerance on dimensions and dimension style
« on: April 12, 2022, 02:58:37 PM »
Hello to all the members of this forum, I have a routine to add +-2 tolerance to my dimensions. The routine works fine, as it accomplishes its purpose, which is to add the tolerance of +-2, which are set with the variables "DimTm" 2 & "DimTp" 2 respectively.

Code: [Select]
;Lisp routine to add a +-2.0 tolerance on dimensions.
(defun c:T2 (/ IR_SDTo IR_SDTm IR_SDTp IR_DObj)
  (setq IR_SDTo (getvar "DimTol"))
  (setq IR_SDTm (getvar "DimTm"))
  (setq IR_SDTp (getvar "DimTp"))
  (setvar "DimTol" 1)
  (setvar "DimTm" 2)
  (setvar "DimTp" 2)
  (princ "nSelect Dimension to add Tolerance to: ")
  (setq IR_DObj (ssget '((0 . "DIMENSION"))))
  (if IR_DObj
(command "._-DimStyle" "_A" IR_DObj "")
  )
  (setvar "DimTol" IR_SDTo)
  (setvar "DimTm" IR_SDTm)
  (setvar "DimTp" IR_SDTp)
  (princ)
)

What I can't solve is that they acquire the same dim style that they already had.
when applying the routine, the dimensions acquire the dim style that I currently have and apply it to all dimensions.
I would like to achieve this purpose, by selecting multiple dimensions and their dim style not being affected by the current dim style.

Any help is greatly appreciated.



mhupp

  • Bull Frog
  • Posts: 250
Re: Tolerance on dimensions and dimension style
« Reply #1 on: April 14, 2022, 02:21:50 PM »
This only updates the dimensions that are selected rather then updating the global variable.

Code - Auto/Visual Lisp: [Select]
  1. ;Lisp routine to add a ±2.0 tolerance on dimensions.
  2. (defun c:T2 (/ SS)
  3.   (princ "\nSelect Dimension to add Tolerance: ")
  4.   (if (setq SS (ssget '((0 . "DIMENSION"))))
  5.     (foreach Dim (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS)))
  6.       (setq D (vlax-ename->vla-object Dim))
  7.       (vla-put-tolerancedisplay D 1)      ;shows tolerance
  8.       (vla-put-toleranceprecision D 1)    ;sets the persion to 0.0
  9.       (vla-put-tolerancelowerlimit D 2)   ;sets the lower limit to 2
  10.       (vla-put-toleranceupperlimit D 2)   ;sets the upper limit to 2
  11.     )
  12.   )
  13.   (princ)
  14. )

Didn't have the \n for new line
« Last Edit: April 14, 2022, 06:45:43 PM by mhupp »