Patran二次開(kāi)發(fā)步驟.doc
《Patran二次開(kāi)發(fā)步驟.doc》由會(huì)員分享,可在線閱讀,更多相關(guān)《Patran二次開(kāi)發(fā)步驟.doc(4頁(yè)珍藏版)》請(qǐng)?jiān)谘b配圖網(wǎng)上搜索。
1. ******在Patran下掛下拉菜單****** 通常我們不修改init.pcl文件,啟動(dòng)init.pcl時(shí)而會(huì)執(zhí)行附帶的啟動(dòng)文件p3prolog.pcl和p3epilog.pcl。如果這些文件存在,就會(huì)在init.pcl啟動(dòng)前后裝載p3prolog.pcl(啟動(dòng)前)和p3epilog.pcl(啟動(dòng)后),所以這兩個(gè)文件是我們插入自定義命令的好地方。 !!PATH !!LIBRARY !!INPUT 在Patran安裝目錄下修改p3prolog.pcl,加入如下命令,例如: !!input mymenu.pcl #裝載菜單文件 ui_exec_function("mymenu","init") #當(dāng)且僅初始化一次 !!input plateform.pcl #裝載對(duì)話框文件 2. ******** 下拉菜單程序編寫********* CLASS exercise FUNCTION init() /*初始化菜單*/ WIDGET menubar,menu,item1,item2,item3 /*定義控件變量*/ menu = uil_primary.get_menubar_id() /*獲取主菜單ID*/ menubar=ui_menu_create(menu,"exercise_menu","有限元分析") /*添加菜單*/ item1=ui_item_create(menubar,"ex_1","計(jì)算",FALSE) /*添加子菜單*/ item2=ui_item_create(menubar,"ex_2","導(dǎo)入文件",FALSE) /*添加子菜單*/ item3=ui_item_create(menubar,"ex_3","結(jié)束",FALSE) /*添加子菜單*/ END FUNCTION FUNCTION exercise_menu(item_name) /*菜單各項(xiàng)的響應(yīng)函數(shù)*/ STRING item_name[] SWITCH(item_name) CASE("EX_1") write("Plate with a hole creating function") ui_exec_function("plateform","init") plateform.display() CASE("EX_2") write("cross pipes creating function") CASE("EX_3") write("slot modeling function") END SWITCH END FUNCTION END CLASS 3. *******彈出對(duì)話框程序編寫******* #include "appforms.p" CLASS plateForm /*定義控件變量*/ CLASSWIDE WIDGET form_id,dataBox1,dataBox2,dataBox3,@ apply_button,cancel_button,delete_button /*初始化對(duì)話框,必要的函數(shù)*/ FUNCTION init() real x_loc,y_loc /*創(chuàng)建對(duì)話框窗體ui_form_create(callback,x,y,position,width,height,label,[unused])*/ form_id=ui_form_create("",FORM_X_LOC,FORM_Y_LOC,"UL",FORM_WID_SML,FORM_HGT_FULL,"PLATE WITH A HOLE","") /*創(chuàng)建圖標(biāo)*/ x_loc=FRAME_WID_SINGLE/2.-200*PIXEL_WID/2.+FORM_L_MARGIN y_loc=FRAME_T_MARGIN+INTER_WIDGET_SPACE /* ui_labelicon_create(parent,callback,x,y,label)*/ ui_labelicon_create(form_id,"",x_loc,y_loc,"platehole.icon") y_loc+=200.*PIXEL_HGT+DBOX_HGT_NO_LABOVE+INTER_WIDGET_SPACE /*創(chuàng)建輸入文本框ui_databox_create(parent,callback,x,y,label_length,box_length,width,height,label,value,label_above,datatype,num_vars)*/ dataBox1=ui_databox_create(form_id,"",FRAME_L_MARGIN,y_loc,SINGLE_SPACE*5.0,DBOX_WID_SINGLE*0.6,"r=",2.,FALSE,"REAL",1) y_loc+=DBOX_HGT_NO_LABOVE+INTER_WIDGET_SPACE dataBox2=ui_databox_create(form_id,"",FRAME_L_MARGIN,y_loc,SINGLE_SPACE*5.0,DBOX_WID_SINGLE*0.6,"w=",5.,FALSE,"REAL",1) y_loc+=DBOX_HGT_NO_LABOVE+INTER_WIDGET_SPACE dataBox3=ui_databox_create(form_id,"",FRAME_L_MARGIN,y_loc,SINGLE_SPACE*5.0,DBOX_WID_SINGLE*0.6,"h=",5.,FALSE,"REAL",1) y_loc+=DBOX_HGT_NO_LABOVE+INTER_WIDGET_SPACE*2 /*創(chuàng)建“應(yīng)用”按鈕ui_button_create(parent, callback, x, y, width, height, label, [unused], highlight)*/ apply_button=ui_button_create(form_id,"apply_cb",BUTTON_HALF_X_LOC1,y_loc,BUTTON_WID_HALF,0,"應(yīng)用",TRUE,TRUE) /*創(chuàng)建“取消”按鈕*/ cancel_button=ui_button_create(form_id,"cancel_cb",BUTTON_HALF_X_LOC2,y_loc,BUTTON_WID_HALF,0,"取消",TRUE,FALSE) y_loc+=DBOX_HGT_NO_LABOVE+INTER_WIDGET_SPACE /*創(chuàng)建“刪除”按鈕*/ delete_button=ui_button_create(form_id,"delete_cb",BUTTON_HALF_X_LOC1,y_loc,BUTTON_WID_HALF,0,"Delete",TRUE,FALSE) y_loc+=BUTTON_DEFAULT_HGT+FORM_B_MARGIN+INTER_WIDGET_SPACE ui_wid_set(form_id,"HEIGHT",y_loc) END FUNCTION /*窗體顯示,必要的函數(shù)*/ FUNCTION display() ui_form_display("plateForm") END FUNCTION /*“應(yīng)用”按鈕響應(yīng)處理函數(shù)*/ FUNCTION apply_cb() real r,w,h ui_wid_get(databox1,"VALUE",r) ui_wid_get(databox2,"VALUE",w) ui_wid_get(databox3,"VALUE",h) ui_form_hide("plateform") ui_writec("r =%f,w=%f,h=%f",r,w,h) END FUNCTION FUNCTION cancel_cb() ui_form_hide("plateform") END FUNCTION FUNCTION delete_cb() ui_form_delete("plateform") END FUNCTION END CLASS 4. C++文件編譯處理 例如: d:\msc\patran2001r2\bin\cpp -id:/msc/patran2001r2/customization c:/uillist.pcl c:/uillist.cpp 5. 編程格式介紹 轉(zhuǎn)行繼續(xù)符:@ 分號(hào)分隔符:同C++:“;” 注釋多行:/*……*/ 注釋單行:“?!被蛘摺?” 計(jì)算表達(dá)式說(shuō)明:用“`”(數(shù)字1鍵左邊的那個(gè)鍵)例如:Angle:`360/5`,或者用WRITE(10+20) 變量和常量 Integer(整型),Real(實(shí)數(shù)),Logical(TRUE和FALSE),String,Widget(控件,有個(gè)常量WIDGET_NULL) 變量的生命周期 Global 全局 Local 在函數(shù)內(nèi),本地 Static 靜態(tài),patran退出就消失 ClassWide 對(duì)一組函數(shù)可見(jiàn),patran退出就消失 6. 指令文件管理 !! input file.pcl #編譯連接file.pcl,并將函數(shù)調(diào)入patran !!compile file.pcl into xxx.plb #編譯file.pcl,并存入plb庫(kù)中 !!library xxx.plb #將plb文件調(diào)入patran !!path Directory #指定打開(kāi)文件的目錄 !!Trace option pcl #執(zhí)行確認(rèn) !!Debug option #保存注釋 !!options option #pcl環(huán)境設(shè)置 !!size code newsize #為編譯代碼區(qū)設(shè)置大小 !!clear global name #刪除全局變量定義 !!clear function name #刪除函數(shù)定義- 1.請(qǐng)仔細(xì)閱讀文檔,確保文檔完整性,對(duì)于不預(yù)覽、不比對(duì)內(nèi)容而直接下載帶來(lái)的問(wèn)題本站不予受理。
- 2.下載的文檔,不會(huì)出現(xiàn)我們的網(wǎng)址水印。
- 3、該文檔所得收入(下載+內(nèi)容+預(yù)覽)歸上傳者、原創(chuàng)作者;如果您是本文檔原作者,請(qǐng)點(diǎn)此認(rèn)領(lǐng)!既往收益都?xì)w您。
下載文檔到電腦,查找使用更方便
9.9 積分
下載 |
- 配套講稿:
如PPT文件的首頁(yè)顯示word圖標(biāo),表示該P(yáng)PT已包含配套word講稿。雙擊word圖標(biāo)可打開(kāi)word文檔。
- 特殊限制:
部分文檔作品中含有的國(guó)旗、國(guó)徽等圖片,僅作為作品整體效果示例展示,禁止商用。設(shè)計(jì)者僅對(duì)作品中獨(dú)創(chuàng)性部分享有著作權(quán)。
- 關(guān) 鍵 詞:
- Patran 二次開(kāi)發(fā) 步驟
鏈接地址:http://m.italysoccerbets.com/p-6576480.html