前言
一個程序適用N種產(chǎn)品,該如何進行編程?
在測量應用中,對于相似產(chǎn)品,如:環(huán)規(guī),想要提高測量效率,并且減少產(chǎn)品程序的數(shù)量,測量員可以對產(chǎn)品的相同點進行一定分析,發(fā)現(xiàn)其中部分數(shù)據(jù)可實現(xiàn)參數(shù)化,通過RationalDMIS軟件的高級語言功能實現(xiàn)產(chǎn)品的快速測量,并適用于多種規(guī)格的產(chǎn)品。
1、產(chǎn)品分析
對于有著眾多規(guī)格的環(huán)規(guī)而言,如果每一個規(guī)格的大小都進行編程,是一個非常繁瑣且不便的工程,對于測量員使用對應程序也是極其不便的,影響測量效率。我們對環(huán)規(guī)這類產(chǎn)品進行分析,特點如下圖:
環(huán)規(guī)的類型內外為TYPE,總高度定義為H,頂部向下偏移量定義為UP,底部向上偏移量定義為DP,環(huán)規(guī)直徑定義為DM,測量截面數(shù)量m,每個截面測量點數(shù)為n。
2、程序的設計
2.1 程序運行后,通過人為輸入,可以實現(xiàn)不同規(guī)格產(chǎn)品的自動測量
2.2 流程圖
2.3 RationalDMIS 程序編寫
(1)通過DMIS提示,設置一個運行時輸入?yún)?shù)的提示窗口
代碼如下:
(2) 對參數(shù)進行判斷,如判斷環(huán)規(guī)類型、輸入內容為字母、0 等情況
(3)手動建立坐標系
(4)設置安全平面宏
(請將安全平面宏程序按以下內容修改)
(5)自動精建坐標系
(6)評價與分析
通過前面輸入的層數(shù)與點數(shù)參數(shù),進行圓柱測量,并進行評價
(7)生產(chǎn)檢測報告
(8)總結
通過RationalDMIS軟件,只需簡單3步,即可完成:
1、條件判斷,輸入管控參數(shù),判斷規(guī)格類型;
2、利用賦值,將管控參數(shù)賦給變量;
3、通過變量,規(guī)劃測量軌跡,實現(xiàn)了不同規(guī)格的產(chǎn)品的檢測;
最終實現(xiàn)一個程序,完成N個不同規(guī)格產(chǎn)品的自定、高效測量。
(9)完整代碼如下
$$/* Header DMISMN/'Created by [思瑞測量技術(深圳)有限公司(非銷售版)-101522-10825] on 星期四, 五月 26, 2022', 4.0 UNITS/MM, ANGDEC, MMPS WKPLAN/XYPLAN PRCOMP/ON TECOMP/OFF FLY/1.000000 MODE/PROG, MAN SNSET/APPRCH, 1.000000 SNSET/RETRCT, 1.000000 SNSET/DEPTH, 0.000000 SNSET/SEARCH, 10.000000 SNSET/CLRSRF, 10.000000 RECALL/D(MCS) SNSLCT/S(ROOTSN2) GEOALG/BF, LSTSQR GEOALG/ANGLB, DEFALT GEOALG/CIRCLE, MAXINS GEOALG/ARC, LSTSQR GEOALG/PLANE, LSTSQR $$ $$ $$*/ MODE/MAN DECL/COMMON, INTGR, RINGconfig,TYPE,RINGH,RINGDM,RINGUP,RINGDP,RINGPOINTS,RINGCOUNTS RINGconfig = PROMPT/TEXT,'請選擇環(huán)規(guī)類型:',LIST,TYPE,'內','外',TEXT,'高度 H:',EDIT,RINGH,TEXT,'直徑 DM:',EDIT,RINGDM,TEXT,'上偏移量 UP:',EDIT,RINGUP,TEXT,'下偏移量 DP:',EDIT,RINGDP,TEXT,'每層測點數(shù) N:',EDIT,RINGPOINTS,TEXT,'層數(shù) M:',EDIT,RINGCOUNTS if/(TYPE.EQ.1) KNPTN1=ASSIGN/1 ELSE KNPTN1=ASSIGN/-1 ENDIF $$檢查參數(shù) IF/(RINGH.EQ.0) RINGH = PROMPT/'請輸入正確的環(huán)規(guī)高度 H', 100, 1 ENDIF IF/(RINGDM.EQ.0) RINGDM = PROMPT/'請輸入正確的環(huán)規(guī)直徑 DM', 9999, 1 ENDIF IF/(RINGUP.EQ.0) RINGUP = PROMPT/'請輸入正確的偏移量 UP', RINGH, 1 ENDIF IF/(RINGDP.EQ.0) RINGDP = PROMPT/'請輸入正確的偏移量 DP', RINGH, 1 ENDIF IF/(RINGPOINTS.EQ.0) RINGPOINTS = PROMPT/'請輸入正確的每層測點數(shù) N', 9999, 3 ENDIF IF/(RINGCOUNTS.EQ.0) RINGCOUNTS = PROMPT/'請輸入正確的測量層數(shù) M', 9999, 2 ENDIF F(PLN1)=FEAT/PLANE,POL,0,0,0.000000,0.000000,0.000000,1.000000 FA(PLN1)=FEAT/PLANE,POL,0,0,0.000000,0.000000,0.000000,1.000000 $$Measurement points are created through nominal points MEAS/PLANE, F(PLN1), 3 PTMEAS/POL, 16.022606, 89.412167, 0.000000, 0.000000, 0.000000, 1.000000 PTMEAS/POL, 16.618454, 203.430682, 0.000000, 0.000000, 0.000000, 1.000000 PTMEAS/POL, 16.155284, 335.311794, 0.000000, 0.000000, 0.000000, 1.000000 ENDMES D(CRD1) = DATSET/FA(PLN1), ZDIR D(CRD1) = TRANS/ZORIG, FA(PLN1) F(CIR1)=FEAT/CIRCLE,INNER,CART,0.000000,0.000001,-2,0.000000,0.000000,1.000000, RINGDM FA(CIR1)=FEAT/CIRCLE,INNER,CART,0.000000,0.000001,-2,0.000000,0.000000,1.000000, RINGDM $$ Measurement points are created through nominal points MEAS/CIRCLE, F(CIR2), 4 PTMEAS/CART, 0, KNPTN1*RINGDM/2, -2 , 0, -1*KNPTN1, 0 PTMEAS/CART, KNPTN1*RINGDM/2, 0, -2, -1*KNPTN1, 0, 0 PTMEAS/CART, 0, -1*KNPTN1*RINGDM/2, -2, 0,1*KNPTN1, 0 PTMEAS/CART, -1*KNPTN1*RINGDM/2, 0, -2, 1*KNPTN1,0, 0 ENDMES D(CRD2) = DATSET/FA(PLN1), ZDIR, FA(CIR1), XORIG D(CRD2) = TRANS/ZORIG, FA(PLN1), YORIG, FA(CIR1), XORIG, -0 MODE/PROG,MAN $$ MACRO: EASI_CLEARPLN_GOTO $$ FUNCTION: CLEARANCE SURFACE IMPLEMENTATION $$ Move machine CLEAR SURFACE DIST above the current clear surface $$plane and then move machine parallel to the clear surface 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 $$ $$ 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 $$ 調用參數(shù) ISOM 為安全平面參考元素類型理論0(OR實際1) $$ 調用參數(shù)目標位置測點TRAX 、TRAY、 TRAZ,TRAI,TRAJ,TRAK坐標及矢量 M(EASI_CLEARPLN_GOTO) = MACRO/ISNOM, TARX, TARY, TARZ, TARI, TARJ, TARK DECL/LOCAL, REAL, CCX, CCY, CCZ, CCI, CCJ, CCK DECL/LOCAL, REAL, CURX, CURY, CURZ, TD, CLRDIST, SDIAM,BJDIST DECL/LOCAL, CHAR, 255, CLRLABEL, FLABEL, MMODE, SNAME $$獲取當前運行模式及安全平面參考元素名Label MMODE = VALUE/MODE CLRLABEL = VALUE/SNSET, CLRSRF $$判斷Label是否存在(關閉情況為空,非關閉則會獲取到字符串,字符串長度大于0) 同時判斷條件 當前模式是否為自動,否則跳過 IF/ ( (LEN(CLRLABEL) .GT. 0) .AND. (MMODE .EQ. 'PROG,MAN') ) $$獲取安全距離 CLRDIST = VALUE/SNSET, CLRSRF, DIST BJDIST= VALUE/SNSET,APPRCH TARX=ASSIGN/TARX+BJDIST*TARI TARY=ASSIGN/TARY+BJDIST*TARJ TARZ=ASSIGN/TARZ+BJDIST*TARK $$給FLABEL賦值,默認FA FLABEL = ASSIGN/'FA' $$根據(jù)ISOM情況來更改FA或F IF/ ISNOM .EQ. 0 FLABEL = ASSIGN/'F' ENDIF $$賦值CCX,CCY,CCZ,CCI,CCJ,CCK為安全平面參考元素中心坐標的XYZIJK CCX = OBTAIN/FLABEL(@CLRLABEL), 3 CCY = OBTAIN/FLABEL(@CLRLABEL), 4 CCZ = OBTAIN/FLABEL(@CLRLABEL), 5 CCI = OBTAIN/FLABEL(@CLRLABEL), 6 CCJ = OBTAIN/FLABEL(@CLRLABEL), 7 CCK = OBTAIN/FLABEL(@CLRLABEL), 8 $$獲取探頭名稱 SNAME = VALUE/SNSLCT $$獲取探頭直徑 SDIAM = OBTAIN/SS(SNAME), 8 $$延安全平面矢量增加一個探頭半徑 CCX = ASSIGN/CCX + CCI * SDIAM/2 CCY = ASSIGN/CCY + CCJ * SDIAM/2 CCZ = ASSIGN/CCZ + CCK * SDIAM/2 $$獲取當前探針X,Y,Z坐標 CURX = VALUE/GOTOM, XAXIS CURY = VALUE/GOTOM, YAXIS CURZ = VALUE/GOTOM, ZAXIS $$計算當前坐標到安全平面的垂直距離 TD = ASSIGN/(CURX - CCX) * CCI + (CURY - CCY) * CCJ + (CURZ - CCZ) * CCK $$清除原有判斷,任意位置先垂直移動到安全高度 $$IF/ TD .LT. CLRDIST TD = ASSIGN/(CLRDIST - TD) GOTO/CURX+CCI*TD, CURY+CCJ*TD, CURZ+CCK*TD $$ENDIF $$計算目標坐標到安全平面的垂直距離 TD = ASSIGN/(TARX - CCX) * CCI + (TARY - CCY) * CCJ + (TARZ - CCZ) * CCK IF/ TD .LT. CLRDIST TD = ASSIGN/(CLRDIST - TD) GOTO/TARX+CCI*TD, TARY+CCJ*TD, TARZ+CCK*TD $$建議增加大于的情況 ENDIF ENDIF ENDMAC SNSET/APPRCH, 1.0000 SNSET/RETRCT, 1.0000 SNSET/DEPTH, 0.0000 SNSET/SEARCH, 10.0000 SNSET/CLRSRF, FA(PLN1), 10.0000 F(PLN2)=FEAT/PLANE,POL,0,0,0.000000,0.000000,0.000000,1.000000 $$ Measurement points are created through nominal points CALL/M(EASI_CLEARPLN_GOTO), 1,0, KNPTN1*RINGDM/2, 0 , 0, 0, 1 MEAS/PLANE, F(PLN2), 3 PTMEAS/POL, KNPTN1*1+RINGDM/2, 90, 0.000000, 0.000000, 0.000000, 1.000000 PTMEAS/POL, KNPTN1*1+RINGDM/2, 210, 0.000000, 0.000000, 0.000000, 1.000000 PTMEAS/POL, KNPTN1*1+RINGDM/2, 330, 0.000000, 0.000000, 0.000000, 1.000000 ENDMES D(CRD3) = DATSET/FA(PLN2), ZDIR D(CRD3) = TRANS/ZORIG, FA(PLN2) F(CIR2)=FEAT/CIRCLE,INNER,CART,0.000000,0.00000,-2,0.000000,0.000000,1.000000, RINGDM $$ Measurement points are created through nominal points CALL/M(EASI_CLEARPLN_GOTO), 1,0, RINGDM/2, -2 , 0, -1*KNPTN1, 0 MEAS/CIRCLE, F(CIR2), 4 PTMEAS/CART, 0, RINGDM/2, -2 , 0, -1*KNPTN1, 0 IF/(TYPE.EQ.2) CALL/M(EASI_CLEARPLN_GOTO), 1,RINGDM/2, 0, -2, -1*KNPTN1, 0, 0 ENDIF PTMEAS/CART, RINGDM/2, 0, -2, -1*KNPTN1, 0, 0 IF/(TYPE.EQ.2) CALL/M(EASI_CLEARPLN_GOTO), 1,0, -1*RINGDM/2, -2, 0,1*KNPTN1, 0 ENDIF PTMEAS/CART, 0, -1*RINGDM/2, -2, 0,1*KNPTN1, 0 IF/(TYPE.EQ.2) CALL/M(EASI_CLEARPLN_GOTO), 1,-1*RINGDM/2, 0, -2, 1*KNPTN1,0, 0 ENDIF PTMEAS/CART, -1*RINGDM/2, 0, -2, 1*KNPTN1,0, 0 ENDMES D(CRD4) = DATSET/FA(PLN2), ZDIR, FA(CIR2), XORIG D(CRD4) = TRANS/ZORIG, FA(PLN2), YORIG, FA(CIR2), XORIG, -0 $$ Set.Term.Delete IF/(TYPE.EQ.1) KNPTC1=ASSIGN/'內' ELSE KNPTC1=ASSIGN/'外' ENDIF TEXT/OUTFIL,CONCAT('環(huán)規(guī)類型:',KNPTC1) TEXT/OUTFIL,CONCAT('環(huán)規(guī)直徑:',STR(RINGDM)) TEXT/OUTFIL,CONCAT('環(huán)規(guī)高度:',STR(RINGH)) TEXT/OUTFIL,CONCAT('測量上偏移量:',STR(RINGUP)) TEXT/OUTFIL,CONCAT('測量下偏移量:',STR(RINGDP)) TEXT/OUTFIL,CONCAT('測量層數(shù)',STR(RINGCOUNTS)) TEXT/OUTFIL,CONCAT('每層測量點數(shù):',STR(RINGPOINTS)) DECL/COMMON,INTGR,ALLPOINTS ALLPOINTS=ASSIGN/RINGCOUNTS*RINGPOINTS DECL/REAL,PRR,PA,PH,PX,PY,PI,PJ,PDA,PDB IF/(TYPE.EQ.1) F(CYL1) = FEAT/CYLNDR,INNER,CART, 0,0,-1*RINGH/2, 0,0,1, RINGDM, RINGH CALL/M(EASI_CLEARPLN_GOTO),1,RINGDM/2,0,0, -1,0,0 MEAS/CYLNDR, F(CYL1),ALLPOINTS DO/PDA,1,RINGCOUNTS,1 DO/PDB,1,RINGPOINTS,1 PRR=ASSIGN/RINGDM/2 PA=ASSIGN/(360/RINGPOINTS)*(PDB-1) PH=ASSIGN/-1*RINGUP-(RINGH-RINGUP-RINGDP)/RINGCOUNTS*(PDA-1) PI=ASSIGN/COS(DTOR(PA))*KNPTN1*-1 PJ=ASSIGN/SIN(DTOR(PA))*KNPTN1*-1 PX=ASSIGN/RINGDM/2*PI PY=ASSIGN/RINGDM/2*PJ PTMEAS/POL,PRR,PA,PH,PI,PJ,0 ENDDO ENDDO ENDMES ELSE F(CYL1) = FEAT/CYLNDR,OUTER,CART, 0,0,-1*RINGH/2, 0,0,1, RINGDM, RINGH MEAS/CYLNDR, F(CYL1),ALLPOINTS DO/PDA,1,RINGCOUNTS,1 DO/PDB,1,RINGPOINTS,1 PRR=ASSIGN/RINGDM/2 PA=ASSIGN/(360/RINGPOINTS)*(PDB-1) PH=ASSIGN/-1*RINGUP-(RINGH-RINGUP-RINGDP)/RINGCOUNTS*(PDA-1) PI=ASSIGN/COS(DTOR(PA))*KNPTN1*-1 PJ=ASSIGN/SIN(DTOR(PA))*KNPTN1*-1 PX=ASSIGN/RINGDM/2*PI PY=ASSIGN/RINGDM/2*PJ CALL/M(EASI_CLEARPLN_GOTO),1,PX,PY,PH,PI,PJ,0 PTMEAS/POL,PRR,PA,PH,PI,PJ,0 ENDDO ENDDO ENDMES ENDIF T(TDM1)=TOL/DIAM,-0.500000,0.500000 OUTPUT/FA(CYL1),TA(TDM2) T(TCLD1)=TOL/CYLCTY,0.200000 OUTPUT/FA(CYL1),TA(TCLD1)
參考文獻:《2015 PC-DMIS比武大賽論文集》