金属加工论坛
贸易平台·行业报道·技术社区
论坛名称:中国金属加工论坛    网址:http://www.mw1950.com/forum/
 提醒您:如果本页图片或flash动画无法正常显示,请点击这里访问原帖。
[转贴]pro/e二次开发使用toolkit开发trigger的程序 作者:cwlike 时间:2007-5-31 14:05:00
1


  • 使用toolkit开发trigger的程序时,往往需要能够连续通过trigger来触发dll中的函数. 我碰到的问题: 1.配置trigger: name: cimdll event: create piv time: post requireno dll:cim.dll functiondmtpivcreatepostoperation [img]http://www.lnmachine.com/bbs/images/smilies/tongue.gif[/img] 2.源代码: int pdmdllinit() { ptcerror pdm_status; file *g_pfilelog; g_pfilelog =fopen("test.dat","w"); setbuf(g_pfilelog,null); fprintf(g_pfilelog,"begin test\n"); pdm_status = pdmtriggerregister("dmtpivcreatepostoperation", pdmtpivcreatepostoperation); [img]http://www.lnmachine.com/bbs/images/smilies/titter.gif[/img] if (pdm_status != pdm_success) { printf("failed to register trigger piv create post.\n"); } return (pdm_status); } int pdmtpivcreatepostoperation(int argc, void **argv) { fprintf(g_pfilelog,"test\n"); ..... fprintf(g_pfilelog,"end test\n"); fclose(g_pfilelog); } 结果:以上代码存在的问题:如果我们在第一次checkin到c/s中后,删除test.dat文件,然后再进行checkin时,发现没有再生成test.dat,在函数pdmtpivcreatepostoperation()中所进行的对文件的操作都无效. 原因:我们使用trigger触发时,真正起作用的是函数dmtpivcreatepostoperation(),而pdmdllinit()只是在第一次checkin时起作用,所以在第一次调用pdmtpivcreatepostoperation()后,我就fclose(g_pfilelog),所以出现了上面的情况.所以注意的是:不要把一些重要的东西放在函数pdmdllinit()中.[img]http://www.lnmachine.com/bbs/images/smilies/tongue.gif[/img]

  • 所属版面:CAD交流区 本帖第1页
    共有回复: 0 共有页数: 1 显示帖数:50


    欢迎光临中国金属加工论坛 网址:http://www.mw1950.com/forum/