经常遇到需要求一个工件中计算过的公差的合格率/超差率,以下是用DMIS程序实现的方法:
赋值,循环语句,元素标签名自动递增。
以圆直径合格率为例,其余点轮廓,坐标轴向合格率类似!
利用软件“变量区”自带的取公差总数,超差数完成超差率的计算!
(1)$$ 得到所有计算的公差的个数
KNPTN1 = VALUE/TOL, ALL
(2)$$ 得到超差的公差的个数
KNPTN2 = VALUE/TOL, OUTOL
$$ 计算超差百分比并输出到报告中
KNPTR1 = ASSIGN/KNPTN2/KNPTN1*100
WRITE/DID(DEFAULTSCREEN),KNPTR1:4:2, '%'
需要注意的是程序中必须有计算公差的语句,否则Value取得值是0,那么是没法计算出结果的;
DMISMN/'Created by [山涧果子] on 星期五, 七月 13, 2018', 4.0
UNITS/MM, ANGDEC
WKPLAN/XYPLAN
PRCOMP/ON
TECOMP/ON
FLY/1.0
MODE/PROG, MAN
SNSET/APPRCH, 2.000000
SNSET/RETRCT, 2.000000
SNSET/DEPTH, 0.000000
SNSET/SEARCH, 10.000000
SNSET/CLRSRF, 0.000000
RECALL/D(MCS)
SNSLCT/S(20-30X2)
GEOALG/CIRCLE, LSTSQR
GEOALG/ARC, LSTSQR
GEOALG/PLANE, LSTSQR
$$
$$
MODE/AUTO,PROG,MAN
F(CIR1) = FEAT/CIRCLE,INNER,CART, 8.0000, 55.0000, 35.0000, 0.000000,$
0.000000, 1.000000, 10.0000
$$ Empty Meas Block
MEAS/CIRCLE, F(CIR1), 4
ENDMES
F(CIR2) = FEAT/CIRCLE,INNER,CART, 24.0000, 27.2872, 35.0000, 0.000000,$
0.000000, 1.000000, 10.0000
$$ Empty Meas Block
MEAS/CIRCLE, F(CIR2), 4
ENDMES
F(CIR3) = FEAT/CIRCLE,INNER,CART, 56.0000, 27.2872, 35.0000, 0.000000,$
0.000000, 1.000000, 10.0000
$$ Empty Meas Block
MEAS/CIRCLE, F(CIR3), 4
ENDMES
F(CIR4) = FEAT/CIRCLE,INNER,CART, 72.0000, 55.0000, 35.0000, 0.000000,$
0.000000, 1.000000, 10.0000
$$ Empty Meas Block
MEAS/CIRCLE, F(CIR4), 4
ENDMES
F(CIR5) = FEAT/CIRCLE,INNER,CART, 56.0000, 82.7128, 35.0000, 0.000000,$
0.000000, 1.000000, 10.0000
$$ Empty Meas Block
MEAS/CIRCLE, F(CIR5), 4
ENDMES
F(CIR6) = FEAT/CIRCLE,INNER,CART, 24.0000, 82.7128, 35.0000, 0.000000,$
0.000000, 1.000000, 10.0000
$$ Empty Meas Block
MEAS/CIRCLE, F(CIR6), 4
ENDMES
F(CIR7) = FEAT/CIRCLE,INNER,CART, 40.0000, 55.0000, 35.0000, 0.000000,$
0.000000, 1.000000, 45.0000
$$ Empty Meas Block
MEAS/CIRCLE, F(CIR7), 4
ENDMES
F(CIR8) = FEAT/CIRCLE,OUTER,CART, 40.0000, 55.0000, 30.0000, 0.000000,$
0.000000, 1.000000, 30.0000
$$ Empty Meas Block
MEAS/CIRCLE, F(CIR8), 4
ENDMES
F(CIR9) = FEAT/CIRCLE,INNER,CART, 40.0000, 55.0000, 30.0000, 0.000000,$
0.000000, 1.000000, 20.0000
$$ Empty Meas Block
MEAS/CIRCLE, F(CIR9), 4
ENDMES
F(CIR10) = FEAT/CIRCLE,INNER,CART, 50.0000, 7.9081, 27.9289, 0.000000,$
-0.707107, 0.707107, 15.0000
$$ Empty Meas Block
MEAS/CIRCLE, F(CIR10), 4
ENDMES
T(TDIAM1) = TOL/DIAM, 0.0000, 0.0210
DECL/COMMON,INTGR,I
DECL/COMMON,INTGR,J
DECL/COMMON,DOUBLE,V1
DECL/COMMON,CHAR,255,C1
DECL/COMMON,CHAR,255,C2
DO/I,1,10,1
C1 = ASSIGN/CONCAT('CIR',STR(I))
OUTPUT/FA(@C1), TA(TDIAM1)
V1 = OBTAIN/TA(TDIAM1),2
IF/(V1.GT.0).AND.(V1.LT.0.021)
J = ASSIGN/J+1
ENDIF
ENDDO
DECL/COMMON,DOUBLE,V2
V2 = ASSIGN/J/10*100
C2 = ASSIGN/CONCAT('直径合格率为:',STR(V2),'%')
TEXT/OUTFIL, C2
$$
TEXT/OPER, '利用软件“变量区”自带的取公差总数,超差数完成超差率的计算!'
TEXT/OUTFIL, '利用软件“变量区”自带的取公差总数,超差数完成超差率的计算!'
DECL/COMMON, INTGR, K1
DECL/COMMON, INTGR, K2
DECL/COMMON, INTGR, K3
DECL/COMMON,CHAR,255,C3
K1 = VALUE/TOL,ALL
K2 = VALUE/TOL,OUTOL
K3 = ASSIGN/K2/K1*100
C3 = ASSIGN/CONCAT('RationalDMIS圆直径超差率为:',STR(K3),'%'.)
TEXT/OUTFIL, C3