Automatic dimensioning of dimension tolerance in AutoCAD

Automatic dimensioning of dimension tolerance in AutoCAD

The dimension tolerance labeling in AutoCAD is very troublesome. This article gives a short AutoLISP program, which implements the automatic standard of the tolerance value. It can be completed by two mouse selections. It is very convenient and fast to use.

When AutoCAD is used in mechanical design, there are two methods for tolerance marking; one is to complete the DIM parameter setting, but the parameter setting is cumbersome and the speed is also slow, each different tolerance value must be set once, at R12 0 The nominal size in the middle and the tolerance value have the same number of decimal points, making the nominal size cumbersome (R13 0 has improved this); the second is to write directly with the TEXT command, but the speed is also slow, and the position of the word is not easy to write accurately. It is often necessary to move once with the MOVE instruction. Both of the above methods need to prepare a tolerance value table when drawing, and check the table before marking, so it takes a lot of time to mark the dimensional tolerance.
The author used AutoLisp to write a dimensional tolerance automatic labeling program, which has a good effect and fast speed. It can be completed in only two operations when it is called: the first operation selects the tolerance level; the second operation selects the marked size to complete the dimensional tolerance automatic labeling . The program consists of four parts: automatically check the table after entering the tolerance level; select the marked dimensions and process accordingly; classify the size and check the upper and lower deviation values; write the tolerance value. If the instruction is added to the menu, it will be more convenient to operate, that is, to make the tolerance grade symbols (such as H7, b6, r6, JS7, etc.) into a slide and call it on the menu.
1. Enter the tolerance level and lookup table. After selecting the tolerance standard item on the menu, the corresponding slide appears on the screen (as shown in the figure). After selecting the item of the corresponding tolerance level, two command inputs are completed: First, the tolerance is given Grade (actually, the corresponding line number n value of the grade is given in the tolerance value table); the second is to start the tolerance standard Lisp program. After the Lisp program starts, open the tolerance value table (Tole.TXT) and use the repeat function to continuously read a row of data in the tolerance value table until the nth line corresponding to the marked tolerance level.
If the marked tolerance is H8, the corresponding line on the menu is:
[DAN (LH8)] ^ C ^ P (setg n 3) tolerance
If the marked tolerance is JS6, the corresponding line on the menu is:
[DAN (JS6)] ^ C ^ P (setg n 10) tolerance
Tolerance label slide (note DAN is the slide library name DAN.SLB, LH8, JS6 are the slide name LH8.SLD and JS6.SLP, tolerance is the tolerance standard Lisp program instruction name)
If you don't want to make a slideshow, key in the value of the Lisp variable n before starting Lisp. To make labeling more convenient, the current layer is automatically switched to the dimension layer (DIM layer).
2. Select the marked size and process it. Select the marked size in the graphics according to the Lisp prompt. Through corresponding processing, the size, font height, position, angle, etc. of the size are obtained for use. The functions used are entget and assoc. When obtaining the dimension to be marked, the Substr function is used to hide the R, r, Φ in front of the circle dimension to facilitate the subsequent determination of the size of the value. At the same time, it also judges whether the size has a decimal point, which can make the position of the tolerance value more accurate when writing, because the decimal point occupies less than one word width.
Third, the size classification and obtain the corresponding upper and lower limit deviation values ​​The data row obtained in the first step of the table lookup contains all the upper and lower limit values ​​in the tolerance level (one column in the table of GB1801-79 combined with the marked dimension value obtained in the second step , This step can find the upper and lower limit deviation value of the marked size, use the Cond function to determine the position of the deviation value, and then use the Substr function to read it out, if the marked size is 40, the upper deviation value is the 75th character 6 characters from the beginning, the lower deviation value is 6 characters from the 82nd character, and the Tole.TXT data table should be neatly arranged.
4. Tolerance value writing Use the TEXT instruction to write the tolerance value. The writing position is calculated based on the number of nominal dimensions and whether there is a decimal point. The angle word height also changes with the nominal dimension. Special treatment for JS level tolerance (n = 10, 11, 12 *).
In order to make Lisp versatile, absolute tolerances (such as +0.01 0, +0.02 0, 0 +0.01, * 0.01, etc.) are also considered, because these tolerances are not commonly used and are written directly into the Lisp program. In the program, n starts from 40, and there is no 40th and subsequent rows in the data table.
The Lisp program is not large, but the letter covers all types of tolerance labeling in the mechanical design, such as relative tolerance (GB), absolute tolerance, general size, radius size. In order to make the label beautiful, the decimal point is also considered, while the While function can be used to continuously label the dimensions of the same tolerance level.
Fifth, several explanations 1 Because the nominal size of the dimensioning needs to be obtained, DIMASO should be set to DFF before the dimensioning, otherwise the dimension value cannot be obtained.
2 The program is based on the deviation of the upper and lower limits of the character position, so the tolerance value table (tole.TXT) should be neat and can only be written with pure text editing software (such as EDIT).
3 Slide layout can be arranged according to the frequency of use. I use AutoCAD to design the mold, so the first 20 slides have been sorted as above, and the reader can make adjustments according to the actual situation.
4 This program is passed on AutoCAD R11.0 R12.0, R13.0. The source program and tolerance value table are as follows:
(defun c: tolerance ()
(setq txt (open "tole.txt" "r"))
(repeat n (setq tols $ (read-line txt)))
(close txt)
(setvar "cmdecho" 0) (command "layer" "s" "dim" "")
(while T
(setq obj (entget (car (entsel))))
(setq posi (assoc 10 obj))
(setq txth (cdr (assoc 40 obj)))
(setq toleh (* 0.6 txth))
(setq angr (cdr (assoc 50 obj)))
(setq angd (* (/ angr pi) 180))
(setq dim $ (cdr (assoc 1 obj)))
(setq ln (strlen dim $))
(if (= (substr dim $ 1 1) "R") (setq dim $ (substr dim $ 2 (-ln 1))))
(if (= (substr dim $ 1 1) "r") (setq dim $ (substr dim $ 2 (-ln 1))))
if (= (substr dim $ 1 1) "%") (setq dim $ (substr dim $ 4 (-ln 3)) ln (-ln 2)))
(setq dimt (atof dim $))
(setq lupr (getvar "luprec"))
(setvar "luprec" 0)
(if (= (strlen dim $) (strlen (rtos (atoi dim $)))) (setq ln (+ ln 0.7)))
(setvar "luprec" lupr)
(cond ((and (<= dimt 3) (> dimt 0)) (setq st1 5 st2 12))
((and (<= dimt 6) (> dimt 3)) (setq st1 19 st2 26))
((and (<= dimt 10) (> dimt 6)) (setq st1 33 st2 40))
((and (<= dimt 18) (> dimt 10)) (setq st1 47 st2 54))
((and (<= dimt 30) (> dimt 18)) (setq st1 61 st2 68))
((and (<= dimt 50) (> dimt 30)) (setq st1 75 st2 82))
((and (<= dimt 80) (> dimt 50)) (setq st1 89 st2 96))
((and (<= dimt 120) (> dimt 80)) (setq st1 103 st2 110))
((and (<= dimt 180) (> dimt 120)) (setq st1 117 st2 124))
((and (<= dimt 250) (> dimt 180)) (setq st1 131 st2 138))
((and (<= dimt 315) (> dimt 250)) (setq st1 145 st2 152))
((and (<= dimt 400) (> dimt 315)) (setq st1 159 st2 166))
((and (<= dimt 500) (> dimt 400)) (setq st1 173 st2 180))
((and (<= dimt 630) (> dimt 500)) (setq st1 187 st2 194))
)
(setq tole1 $ (substr tols $ st1 6) tole2 $ (substr tols $ st2 6))
(setq x1 (+ (cadr posi) (* (cos angr) (* (-ln 1.2) txth))))
(setq y1 (+ (caddr posi) (* (sin angr) (* (-ln 1.2) txth))))
(setq x2 (+ x1 (* (cos (+ angr 1.5708)) (* 0.85 txth))))
(setq y2 (+ y1 (* (sin (+ angr 1.5708)) (* 0.85 txth))))
(setq xy1 (list x1 y1))
(setq xy2 (list x2 y2))
(if (or (= n 10) (= n 11) (= n 12) (= n 13) (= n 27) (= n 28))
(progn (setq tole $ (strcat "%% p" tole1 $)) (command "text" xy1 txth angd tole $))
(progn (if (= n 40) (setq tole1 $ "+0.01" tole2 $ "0"))
(if (= n 41) (setq tole1 $ "+0.02" tole2 $ "0"))
(if (= n 42) (setq tole1 $ "+0.05" tole2 $ "0"))
(if (= n 43) (setq tole1 $ "+0.10" tole2 $ "0"))
(if (= n 48) (setq tole1 $ "0" tole2 $ "-0.10"))
(if (= n 47) (setq tole1 $ "0" tole2 $ "-0.05"))
(if (= n 46) (setq tole1 $ "0" tole2 $ "-0.02"))
(if (= n 45) (setq tole1 $ "0" tole2 $ "-0.01"))
(command "text" xy2 toleh angd tole1 $ "text" xy1 toleh angd tole2 $))
)
)
) (princ)
H6 | +0.006 0 +0.008 0 +0.009 0 +0.011 0 +0.013 0 +0.016 0…
H7 | +0.010 0 +0.012 0 +0.015 0 + 0.018 0 +0.021 0 +0.025 0…
H8 | +0.014 0 +0.018 0 +0.022 0 + 0.027 0 +0.033 0 +0.039 0…
H9 | +0.025 0 +0.030 0 +0.036 0 + 0.043 0 +0.052 0 +0.062 0…
G7 | +0.012 +0.002 +0.016 +0.004 +0.020 +0.005 + 0.024 + 0.006 +0.028 +0.007 +0.034 +0.009…
K7 | 0 -0.010 +0.003 -0.009 +0.005 -0.010 +0.006 -0.012 +0.006 -0.015 +0.007 -0.018…
N7 | -0.004 -0.014 -0.004 -0.016 -0.004 -0.019 -0.005-0.023 -0.007 -0.028 -0.008 -0.033…
S7 | -0.014 -0.024 -0.015 -0.027 -0.017 -0.032 -0.021 -0.039 -0.027 -0.048 -0.034 -0.059…
U7 | -0.018 -0.028 -0.019 -0.031 -0.022 -0.037 -0.026-0.044 -0.033 -0.054 -0.051 -0.076…
JS6 | 0.003 0.004 0.005 0.006 0.007 0.008…
JS7 | 0.005 0.006 0.007 0.009 0.010 0.012…
JS8 | 0.007 0.009 0.011 0.013 0.016 0.019…
JS9 | 0.012 0.015 0.018 0.021 0.026 0.031…
h6 | 0 -0.006 0 -0.008 0 -0.009 0 -0.011 0 -0.013 0 -0.016…
h7 | 0 -0.010 0 -0.012 0 -0.015 0 -0.018 0 -0.021 0 -0.025…
h8 | 0 -0.014 0 -0.018 0 -0.022 0 -0.027 0 -0.033 0 -0.039…
h9 | 0 -0.025 0 -0.030 0 -0.036 0 -0.043 0 -0.052 0 -0.062…
m6 | +0.008 +0.002 +0.012 +0.004 +0.015 +0.006 +0.018 +0.007 +0.021 +0.008 +0.025 +0.009…
m7 | +0.012 +0.002 +0.016 +0.004 +0.021 +0.006 +0.025 +0.007 +0.029 +0.008 +0.034 +0.009…
g6 | -0.002 -0.008 -0.004 -0.012 -0.005 -0.014 -0.006 -0.017 -0.007 -0.020 -0.009 -0.025…
k6 | +0.006 0 +0.009 +0.001 +0.010 +0.001 +0.012 +0.001 +0.015 +0.002 +0.018 +0.002…
n6 | +0.010 +0.004 +0.016 +0.008 +0.019 +0.010 +0.023 +0.012 +0.028 +0.015 +0.033 +0.017…
s6 | +0.020 +0.014 +0.027 +0.019 +0.032 +0.023 +0.039 +0.028 +0.048 +0.035 +0.059 +0.043…
u6 | +0.024 +0.018 +0.031 +0.023 +0.037 +0.028 +0.044 +0.033 +0.054 +0.041 +0.076 +0.060…
f7 | -0.006 -0.016 -0.010 -0.022 -0.013 -0.028 -0.016 -0.034 -0.020 -0.041 -0.025 -0.050…
f8 | -0.006 -0.020 -0.010 -0.028 -0.013 -0.035 -0.016 -0.043 -0.020 -0.053 -0.025 -0.064…
Tolerance value table tole.txt

BAM Power Transmission Capacitors

BAM Power Transmission Capacitors

Shunt Capacitor,High Voltage Capacitor,Parallel Capacitor,Parallel Capacitor

YANGZHOU POSITIONING TECH CO., LTD , https://www.yzpstcc.com