最佳拟合法和3最佳拟合法拟合坐标系: 这种方法适用于零件有特征可以测量或构造,零件的评价方法要在原始数模坐标系下,或数模坐标系比较复杂,直接用3-2-1法拟合难度大。 由于零件本身是存在有制造误差的,在实际拟合过程中这些误差是平均分配在每一个元素的坐标拟合中,所以这些元素在与数模拟合过程中的误差是平均分配的。所以拟合后会发现这些参与拟合的元素实测值与理论值都有偏差,这是正常的。最佳拟合法一般会平分这些误差,常规3-2-1法操作如下: 由于坐标系原点不在两个圆孔的任何一个,两点偏移队列坐标系一般误差计算结果在第二元素的单个方向,可以从第二元素的下拉框里面选择方向,指定方向的参数会包括所有误差,第一第二元素的另外三个坐标会没有误差;这个和实际不多相符,常规方法需要两孔连线,两孔中分点为坐标系原点,旋转角度,平移!DMISMN/'Created by [山涧果子] on 星期四, 三月 15, 2018', 4.0UNITS/MM, ANGDECWKPLAN/XYPLANPRCOMP/ONTECOMP/ONFLY/1.0MODE/PROG, MANSNSET/APPRCH, 3.000000SNSET/RETRCT, 3.000000SNSET/DEPTH, 0.000000SNSET/SEARCH, 10.000000SNSET/CLRSRF, 50.000000RECALL/D(MCS)SNSLCT/S(20-30X2)GEOALG/CIRCLE, LSTSQRGEOALG/ARC, LSTSQRGEOALG/PLANE, LSTSQR$$$$MODE/MANF(PLN1) = FEAT/PLANE,CART, 486.0224, -642.3089, -625.3113, -0.000189,$0.000549, 1.000000$$ Measurement points are created through actual pointsMEAS/PLANE, F(PLN1), 4 PTMEAS/CART, 638.799166, -742.685150, -625.227220, -0.000189, 0.000549,$1.000000 PTMEAS/CART, 567.211586, -592.458027, -625.323311, -0.000189, 0.000549,$1.000000 PTMEAS/CART, 429.261550, -559.235412, -625.367682, -0.000189, 0.000549,$1.000000 PTMEAS/CART, 308.817401, -674.856913, -625.326961, -0.000189, 0.000549,$1.000000ENDMESD(CRD1) = DATSET/FA(PLN1), ZDIRD(CRD1) = TRANS/ZORIG, FA(PLN1)WKPLAN/XYPLANF(CIR1) = FEAT/CIRCLE,OUTER,CART, 331.4403, -606.3965, 2.8957, -0.000000,$0.000000, 1.000000, 18.3865$$ Measurement points are created through actual pointsMEAS/CIRCLE, F(CIR1), 4 PTMEAS/CART, 340.561970, -605.251761, 2.895749, 0.992217, 0.124517, 0.000000 PTMEAS/CART, 330.257044, -597.279694, 2.895749, -0.128706, 0.991683,$0.000000 PTMEAS/CART, 322.384588, -604.812029, 2.895749, -0.985036, 0.172350,$0.000000 PTMEAS/CART, 330.368842, -615.527082, 2.895749, -0.116545, -0.993185,$0.000000ENDMESF(CIR2) = FEAT/CIRCLE,OUTER,CART, 621.1683, -762.5868, 2.0847, -0.000000,$0.000000, 1.000000, 14.8570$$ Measurement points are created through actual pointsMEAS/CIRCLE, F(CIR2), 4 PTMEAS/CART, 620.597379, -769.993280, 2.084635, -0.076855, -0.997042,$0.000000 PTMEAS/CART, 619.163963, -769.739741, 2.084635, -0.269817, -0.962912,$0.000000 PTMEAS/CART, 621.989434, -755.203817, 2.084635, 0.110540, 0.993872, 0.000000 PTMEAS/CART, 623.369025, -755.491769, 2.084635, 0.296256, 0.955108, 0.000000ENDMESF(PROJPT1) = FEAT/POINT,CART, 331.4403, -606.3965, -0.0000, -0.000000,$-0.000000, 1.000000CONST/POINT,F(PROJPT1),PROJPT,FA(CIR1),FA(PLN1)F(PROJPT2) = FEAT/POINT,CART, 621.1683, -762.5868, -0.0000, 0.000000,$0.000000, 1.000000CONST/POINT,F(PROJPT2),PROJPT,FA(CIR2),FA(PLN1)$$ CREATED BY : External-Array Software, Inc$$ DATE : Jan 19, 2009$$ DISLAIMER: $$ This Macro has been tested internally but not been tested with$$ other DMIS compatible software. This Macro is provided as sample$$ and can be modifed for your own use. External-Array doesn't not $$ guarantee the quality of this Macro.$$ FUNCION: Create a nominal line using two actual features$$ DI, DJ, DK are the normal vector of the plane that the line lies onM(EASI_2PT_TO_LINE) = Macro/'FEAT1', 'FEAT2', 'FEATLINE', DI, DJ, DKDECL/LOCAL,DOUBLE,DVALUE[6] DECL/LOCAL,INTGR, INDEX1, INDEX2 CALL/M(EASI_GETX_INDEX), FEAT1, INDEX1 CALL/M(EASI_GETX_INDEX), FEAT2, INDEX2 DVALUE[1] = OBTAIN/FA(@FEAT1),INDEX1DVALUE[2] = OBTAIN/FA(@FEAT1),INDEX1+1DVALUE[3] = OBTAIN/FA(@FEAT1),INDEX1+2 DVALUE[4] = OBTAIN/FA(@FEAT2),INDEX2DVALUE[5] = OBTAIN/FA(@FEAT2),INDEX2+1DVALUE[6] = OBTAIN/FA(@FEAT2),INDEX2+2 F(@FEATLINE) = FEAT/LINE,BND,CART,DVALUE[1],DVALUE[2],DVALUE[3],$ DVALUE[4],DVALUE[5],DVALUE[6],$ DI, DJ, DKENDMACCALL/M(EASI_2PT_TO_LINE),(PROJPT1),(PROJPT2),(BFLN1), 0.000189, -0.000549,$1.000000CONST/LINE,F(BFLN1),BF,FA(PROJPT1),FA(PROJPT2)F(MIDPT1) = FEAT/POINT,CART, 476.3043, -684.4917, -0.0000, 0.000189,$-0.000549, 1.000000CONST/POINT, F(MIDPT1), MIDPT, FA(PROJPT1), FA(PROJPT2)D(CRD2) = DATSET/FA(PLN1), ZDIR, ZORIG, FA(BFLN1), XDIR, FA(MIDPT1), XORIGD(CRD2) = TRANS/ZORIG, -0, YORIG, FA(MIDPT1), XORIG, -0D(CRD3) = ROTATE/ZAXIS, RTOD(ATAN2(119.9+35,140.5+150))D(CRD4) = TRANS/XORIG, -(140.5+150)/2, YORIG, (119.9+35)/2D(CRD5) = TRANS/XORIG, 140.5, YORIG, -119.9$$TEXT/OPER, '请将测头移动到安全位置,DCC测量开始!!'$$MODE/PROG,MAN$$ This sample DMIS Macro is provided by External-Array Software, Inc.$$ It should be modified for your own use. There is no guarantee for$$ the quality of this Macro. November, 2003$$ FUNCION: Move machine CLEAR DIST above the current clear surface $$ plane and then move machine parallel to the clear surface$$ plane to the project point of POINT(TARX, TARY, TARZ) on $$ the clear surface plane but CLEAR DIST above the plane$$ ALL Macro parameters are in PCS and Current UNITS$$ Last update: 3-1-04 Add mode checking. only works in PROG MODE$$ Last update: 8-24-04 Clear position is based on the surface of$$ ruby ball instead of the center of it.M(EASI_CLEARPLN_GOTO) = MACRO/ISNOM, TARX, TARY, TARZDECL/LOCAL, REAL, CCX, CCY, CCZ, CCI, CCJ, CCKDECL/LOCAL, REAL, CURX, CURY, CURZ, TD, CLRDIST, SDIAMDECL/LOCAL, CHAR, 255, CLRLABEL, FLABEL, MMODE, SNAMEMMODE = VALUE/MODECLRLABEL = VALUE/SNSET, CLRSRFIF/ ( (LEN(CLRLABEL) .GT. 0) .AND. (MMODE .EQ. 'PROG,MAN') )CLRDIST = VALUE/SNSET, CLRSRF, DISTFLABEL = ASSIGN/'FA'IF/ ISNOM .EQ. 0FLABEL = ASSIGN/'F'ENDIFCCX = OBTAIN/FLABEL(@CLRLABEL), 3CCY = OBTAIN/FLABEL(@CLRLABEL), 4CCZ = OBTAIN/FLABEL(@CLRLABEL), 5CCI = OBTAIN/FLABEL(@CLRLABEL), 6CCJ = OBTAIN/FLABEL(@CLRLABEL), 7CCK = OBTAIN/FLABEL(@CLRLABEL), 8SNAME = VALUE/SNSLCTSDIAM = OBTAIN/SS(SNAME), 8CCX = ASSIGN/CCX + CCI * SDIAM/2CCY = ASSIGN/CCY + CCJ * SDIAM/2CCZ = ASSIGN/CCZ + CCK * SDIAM/2CURX = VALUE/GOTO, XAXISCURY = VALUE/GOTO, YAXISCURZ = VALUE/GOTO, ZAXISTD = ASSIGN/(CURX - CCX) * CCI + (CURY - CCY) * CCJ + (CURZ - CCZ) * CCKIF/ TD .LT. CLRDISTTD = ASSIGN/(CLRDIST - TD)GOTO/CURX+CCI*TD, CURY+CCJ*TD, CURZ+CCK*TDENDIFTD = ASSIGN/(TARX - CCX) * CCI + (TARY - CCY) * CCJ + (TARZ - CCZ) * CCKIF/ TD .LT. CLRDISTTD = ASSIGN/(CLRDIST - TD)GOTO/TARX+CCI*TD, TARY+CCJ*TD, TARZ+CCK*TDENDIFENDIFENDMACSNSET/APPRCH, 3.0000SNSET/RETRCT, 3.0000SNSET/DEPTH, 0.0000SNSET/SEARCH, 10.0000SNSET/CLRSRF, 50.0000GOTO/52.281195, 52.781717, 180.296564GOTO/-140.542113, 30.928417, 60.122964F(PLN2) = FEAT/PLANE,CART, 26.5108, 76.9185, 0.0005, -0.000013, -0.000055,$1.000000$$ Measurement points are created through actual pointsMEAS/PLANE, F(PLN2), 4 PTMEAS/CART, -162.140109, 50.907571, -0.003525, -0.000013, -0.000055,$1.000000 GOTO/CART, -162.127170, 50.871843, 56.515012 GOTO/CART, -15.336534, 161.474131, 56.546023 PTMEAS/CART, -17.823063, 165.565714, 0.004738, -0.000013, -0.000055,$1.000000 GOTO/CART, -17.816652, 165.546735, 31.656004 GOTO/CART, 118.131993, 103.794164, 31.590550 PTMEAS/CART, 117.664092, 103.810998, 0.003141, -0.000013, -0.000055,$1.000000 GOTO/CART, 117.673443, 103.792854, 33.509655 GOTO/CART, 167.877916, -12.339184, 33.434820 PTMEAS/CART, 168.342415, -12.609932, -0.002611, -0.000013, -0.000055,$1.000000 GOTO/CART, 168.377198, -12.696555, 138.458991 GOTO/CART, -136.195883, 118.859236, 138.596584ENDMESGOTO/-140.500000, 119.900000, 150.000000F(CIR3) = FEAT/CIRCLE,OUTER,CART, -140.5000, 119.9000, 2.8000, 0.000000,$0.000000, 1.000000, 18.4000$$ Measurement points are created through nominal pointsMEAS/CIRCLE, F(CIR3), 4 GOTO/CART, -127.615068, 122.732841, 53.792667 GOTO/CART, -127.615068, 122.732841, 52.800000 PTMEAS/CART, -131.514601, 121.875502, 2.800000, 0.976681, 0.214696,$-0.000000 GOTO/CART, -127.511793, 117.586354, 2.800000 GOTO/CART, -129.385856, 112.792098, 2.800000 GOTO/CART, -132.951946, 109.079956, 2.800000 PTMEAS/CART, -138.524498, 110.914601, 2.800000, 0.214696, -0.976681,$-0.000000 GOTO/CART, -142.813646, 106.911793, 2.800000 GOTO/CART, -147.607902, 108.785856, 2.800000 GOTO/CART, -151.320044, 112.351946, 2.800000 PTMEAS/CART, -149.485399, 117.924498, 2.800000, -0.976681, -0.214696,$0.000000 GOTO/CART, -153.488207, 122.213646, 2.800000 GOTO/CART, -151.614144, 127.007902, 2.800000 GOTO/CART, -148.048054, 130.720044, 2.800000 PTMEAS/CART, -142.475502, 128.885399, 2.800000, -0.214696, 0.976681,$0.000000 GOTO/CART, -143.332841, 132.784932, 52.800000ENDMESGOTO/150.000000, -35.000000, 150.000000GOTO/156.436269, -17.252947, 9.635601F(CIR4) = FEAT/CIRCLE,OUTER,CART, 150, -35, 2.4339, 0.000000,$0.000000, 1.000000, 14.9$$ Measurement points are created through actual pointsMEAS/CIRCLE, F(CIR4), 4 PTMEAS/CART, 151.645854, -27.759575, 2.433926, 0.226903, 0.973917, 0.000000 PTMEAS/CART, 150.454534, -27.582380, 2.433926, 0.066366, 0.997795, 0.000000 GOTO/CART, 142.957924, -21.486019, 2.442799 GOTO/CART, 133.999321, -33.143763, 2.437123 GOTO/CART, 135.953164, -43.287164, 2.431184 GOTO/CART, 145.178435, -45.801646, 2.428035 PTMEAS/CART, 148.307722, -42.220885, 2.433926, -0.222931, -0.974834,$0.000000 PTMEAS/CART, 149.402427, -42.386504, 2.433926, -0.075412, -0.997152,$0.000000 GOTO/CART, 149.347831, -49.365732, 2.425780 GOTO/CART, 149.376228, -49.456664, 108.899701 GOTO/CART, 149.374722, -49.455172, 108.901202ENDMESF(PROJPT3) = FEAT/POINT,CART, -140.5000, 119.9002, 0.0006, -0.000013,$-0.000055, 1.000000CONST/POINT,F(PROJPT3),PROJPT,FA(CIR3),FA(PLN2)F(PROJPT4) = FEAT/POINT,CART, 150.0000, -34.9999, -0.0041, -0.000013,$-0.000055, 1.000000CONST/POINT,F(PROJPT4),PROJPT,FA(CIR4),FA(PLN2)CALL/M(EASI_2PT_TO_LINE),(PROJPT3),(PROJPT4),(BFLN2), 0.000192, -0.000549,$1.000000CONST/LINE,F(BFLN2),BF,FA(PROJPT3),FA(PROJPT4)F(MIDPT2) = FEAT/POINT,CART, 4.7500, 42.4501, -0.0017, 0.000192, -0.000549,$1.000000CONST/POINT, F(MIDPT2), MIDPT, FA(PROJPT3), FA(PROJPT4)D(CRD6) = DATSET/FA(PLN2), ZDIR, ZORIG, FA(BFLN2), XDIR, FA(MIDPT2), XORIGD(CRD6) = TRANS/ZORIG, -0, YORIG, FA(MIDPT2), XORIG, -0D(CRD7) = ROTATE/ZAXIS, RTOD(ATAN2(119.9+35,140.5+150))D(CRD8) = TRANS/XORIG, -(140.5+150)/2, YORIG, (119.9+35)/2D(CRD9) = TRANS/XORIG, 140.5, YORIG, -119.9RECALL/D(CRD9)MODE/PROG,MANGOTO/-140.500000, 119.900000, 150.000000F(J-1) = FEAT/CIRCLE,OUTER,CART, -140.5000, 119.9000, 2.8000, -0.000000,$-0.000000, 1.000000, 18.4000$$ Measurement points are created through nominal pointsMEAS/CIRCLE, F(J-1), 4 GOTO/CART, -128.329960, 124.992799, 53.792667 GOTO/CART, -128.329960, 124.992799, 52.800000 PTMEAS/CART, -132.013136, 123.451499, 2.800000, 0.922499, 0.386000,$-0.000000 GOTO/CART, -127.307420, 119.947860, 2.800000 GOTO/CART, -128.293330, 114.895635, 2.800000 GOTO/CART, -131.137595, 110.605279, 2.800000 PTMEAS/CART, -136.948501, 111.413136, 2.800000, 0.386000, -0.922499,$0.000000 GOTO/CART, -140.452140, 106.707420, 2.800000 GOTO/CART, -145.504365, 107.693330, 2.800000 GOTO/CART, -149.794721, 110.537595, 2.800000 PTMEAS/CART, -148.986864, 116.348501, 2.800000, -0.922499, -0.386000,$0.000000 GOTO/CART, -153.692580, 119.852140, 2.800000 GOTO/CART, -152.706670, 124.904365, 2.800000 GOTO/CART, -149.862405, 129.194721, 2.800000 PTMEAS/CART, -144.051499, 128.386864, 2.800000, -0.386000, 0.922499,$-0.000000 GOTO/CART, -145.592799, 132.070040, 52.800000ENDMESGOTO/-140.500000, 119.900000, 150.000000GOTO/150.000000, -35.000000, 150.000000GOTO/154.826612, -16.147063, 8.730493F(J-2) = FEAT/CIRCLE,OUTER,CART, 150, -35, 2.2195, -0.000000,$-0.000000, 1.000000, 14.8541$$ Measurement points are created through actual pointsMEAS/CIRCLE, F(J-2), 4 PTMEAS/CART, 152.027880, -27.844046, 2.219498, 0.277537, 0.960715, 0.000000 PTMEAS/CART, 150.592037, -27.578655, 2.219498, 0.084211, 0.996448, 0.000000 GOTO/CART, 144.281290, -23.599383, 2.225922 GOTO/CART, 137.560233, -23.634701, 2.225784 GOTO/CART, 137.677814, -46.663385, 2.214399 GOTO/CART, 147.998456, -46.621060, 2.212302 PTMEAS/CART, 147.966814, -42.132080, 2.219498, -0.269257, -0.963068,$0.000000 PTMEAS/CART, 149.522122, -42.393062, 2.219498, -0.059846, -0.998208,$0.000000 GOTO/CART, 148.776049, -48.817064, 2.212059 GOTO/CART, 148.817950, -53.735968, 128.112775ENDMESGOTO/150, -35, 150.000000GOTO/-82.000000, 157.000000, 150.000000F(J-3) = FEAT/CIRCLE,INNER,CART, -82.0000, 157.0000, -1.3000, -0.000000,$-0.000000, 1.000000, 15.0000$$ Measurement points are created through nominal pointsMEAS/CIRCLE, F(J-3), 4 GOTO/CART, -78.497078, 156.824166, 49.692667 GOTO/CART, -78.497078, 156.824166, 48.700000 PTMEAS/CART, -74.509431, 156.624000, -1.300000, -0.998744, 0.050102,$0.000000 GOTO/CART, -78.831011, 155.497040, -1.300000 GOTO/CART, -79.647393, 154.398726, -1.300000 GOTO/CART, -80.821939, 153.696433, -1.300000 PTMEAS/CART, -82.376000, 149.509431, -1.300000, 0.050102, 0.998744,$-0.000000 GOTO/CART, -83.502960, 153.831011, -1.300000 GOTO/CART, -84.601274, 154.647393, -1.300000 GOTO/CART, -85.303567, 155.821939, -1.300000 PTMEAS/CART, -89.490569, 157.376000, -1.300000, 0.998744, -0.050102,$-0.000000 GOTO/CART, -85.168989, 158.502960, -1.300000 GOTO/CART, -84.352607, 159.601274, -1.300000 GOTO/CART, -83.178061, 160.303567, -1.300000 PTMEAS/CART, -81.624000, 164.490569, -1.300000, -0.050102, -0.998744,$0.000000 GOTO/CART, -81.824166, 160.502922, 48.700000ENDMESGOTO/175.200000, 32.600000, 150.000000F(J-4) = FEAT/CIRCLE,INNER,CART, 175.2000, 32.6000, -1.3500, -0.000000,$-0.000000, 1.000000, 18.4000$$ Measurement points are created through nominal pointsMEAS/CIRCLE, F(J-4), 4 GOTO/CART, 180.347235, 31.811146, 49.642667 GOTO/CART, 180.347235, 31.811146, 48.650000 PTMEAS/CART, 184.293822, 31.206301, -1.350000, -0.988458, 0.151494, 0.000000 GOTO/CART, 179.653543, 29.901433, -1.350000 GOTO/CART, 178.281841, 28.402552, -1.350000 GOTO/CART, 176.440955, 27.542694, -1.350000 PTMEAS/CART, 173.806301, 23.506178, -1.350000, 0.151494, 0.988458, -0.000000 GOTO/CART, 172.501433, 28.146457, -1.350000 GOTO/CART, 171.002552, 29.518159, -1.350000 GOTO/CART, 170.142694, 31.359045, -1.350000 PTMEAS/CART, 166.106178, 33.993699, -1.350000, 0.988458, -0.151494,$-0.000000 GOTO/CART, 170.746457, 35.298567, -1.350000 GOTO/CART, 172.118159, 36.797448, -1.350000 GOTO/CART, 173.959045, 37.657306, -1.350000 PTMEAS/CART, 176.593699, 41.693822, -1.350000, -0.151494, -0.988458,$0.000000 GOTO/CART, 175.988854, 37.747235, 48.650000ENDMESGOTO/23.354863, 52.163612, 223.054633T(TCORTOL1) = TOL/CORTOL,XAXIS, -0.0300, 0.0300T(TCORTOL2) = TOL/CORTOL,YAXIS, -0.0300, 0.0300OUTPUT/FA(J-1),TA(TCORTOL1),TA(TCORTOL2)OUTPUT/FA(J-2),TA(TCORTOL1),TA(TCORTOL2)OUTPUT/FA(J-3),TA(TCORTOL1),TA(TCORTOL2)OUTPUT/FA(J-4),TA(TCORTOL1),TA(TCORTOL2)来源:山涧果子