版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、第十四章 PCL 語(yǔ)言簡(jiǎn)介14.1 PCL 概述14.1.1PCL?PCL 是一種全功能的計(jì)算機(jī)編程語(yǔ)言,是 MSC.Patrand Language 的縮寫(xiě);在安裝 MSC.Patran 時(shí),PCL 語(yǔ)言的開(kāi)發(fā)環(huán)境可以一起裝好;PCL 語(yǔ)言為你提供了大量的函數(shù)(幾萬(wàn)個(gè)),尤其適合于 CAE 應(yīng)用程序的開(kāi)發(fā);PCL 語(yǔ)言的語(yǔ)法類似 C 語(yǔ)言,對(duì)會(huì)用 C 的用戶,可以很快讀懂 PCL 程序,并開(kāi)始編制自己的簡(jiǎn)單的 PCL 程序,擴(kuò)展 MSC.Patran 的功能;14.1.2PCL 能干什么?PCL 語(yǔ)言允許你方便地編制 MSC.Patran 的應(yīng)用小程序,擴(kuò)展 MSC.Patran 的功能。在
2、使用 MSC.Patran 時(shí),PCL 可幫你輕松地完成本來(lái)是很繁人的,但重復(fù)性程度高的操作。PCL 語(yǔ)言允許你把自己的分析程序集成到MSC.Patran的環(huán)境中去,利用 MSC.Patran為你做前后置處理,就象 MSC.Nastran,ABAQUS,DYNA3D 等一樣。PCL 語(yǔ)言允許你對(duì) MSC.Patran 的模型作參數(shù)化的一的參數(shù)化模型。,針對(duì)特殊的工程問(wèn)題,建立統(tǒng)PCL 語(yǔ)言允許你方便地編制“傻瓜”形的界面,供設(shè)計(jì)工程師和新手使用。14.1.3 PCL 的函數(shù)結(jié)構(gòu)PCL 的函數(shù)結(jié)構(gòu)如下所示:FUNCTION 函數(shù)名稱(變量列表)RETURNEND FUNCTION下面是一個(gè)最簡(jiǎn)單
3、的 PCL 程序:FUNCTION simple_function()/*/This is a simple function which write : “$# My favorite number is 1”he history window.EGER numNum = 1Write_line(“My favorite number is ”, num)END FUNCTION14.1PCL 的語(yǔ)法作為一種全功能的語(yǔ)言,PCL 有類似 C 的語(yǔ)則。關(guān)于 PCL 的常數(shù),PCL 變量的定義,PCL 的數(shù)組,PCL 的分叉控制,循環(huán)控制等,這里不作詳細(xì)介紹,請(qǐng)參考MSC.PatranUsers
4、 Manual第四卷第九部分“PCL and Customization”,那里有詳細(xì)的說(shuō)明和例子。14.2PCL 的函數(shù)庫(kù)PCL 強(qiáng)大的功能是通過(guò)其豐富的函數(shù)庫(kù)來(lái)實(shí)現(xiàn)的。一般來(lái)說(shuō),PCL 的函數(shù)庫(kù)可分成三大類,下面分別介紹:14.3.1 PCL 的基本函數(shù)庫(kù)基本函數(shù)庫(kù)中的函數(shù)與一般 C 語(yǔ)言所提供的函數(shù)庫(kù)一致。其中包括:數(shù)學(xué)函數(shù),數(shù)據(jù)流、文件輸入輸出函數(shù),字符串處理函數(shù),系統(tǒng)調(diào)用函數(shù),圖形繪制函數(shù)等等。關(guān)于具體每個(gè)函數(shù)的名稱及用法,請(qǐng)查閱MSC.Patran Users Manual第四卷第九部分 2-27 頁(yè)2-174 頁(yè),或查該書(shū)最后的索引。下面給出的是一個(gè)用這些函數(shù)所編制的一個(gè)例子。F
5、UNCTION write_number( max_number, leading_text)/*Pure:This function opens an external filehe currentworking directory called records.out and writesmax_number records of a format as follows:*this this this thisthisis is is isisrecord record record recordrecordnumber number number numbernumber12345(if
6、 leading_text isthis is record number and max_number = 5)Input: max_number Ileading_text Smax_number of recordsprefix on each recordOutput: noneSide Effects:The file records.out is either created or the ver and the above described records are written to it.incrementedErrors:Return 0, no errorOtherwi
7、se it is a file utility error*/STRING leading_text, filename80, outstr720EGER max_number, sus, rec, channel/*Build a filename with verexternal file*/numberand open thesus= file_build_fname(,records,out, NV,filename)IF(sus != 0 ) THEN RETURNsussus= text_open( filename,NRW, 0,0, channel )IF(sus != 0 )
8、 THENwrite(Unable to open file/filename)RETURN sEND IFus/* Loop to max_number and write concatenated string*/FOR (rec = 1 TO max_number)outstr s us IF( sEND FOR= leading_text/ /STR_FROM_EGER( rec)= text_write_string( channel, outstr )us != 0 ) THEN RETURN sus/* Close*/the external filetext_close( ch
9、annel, )/*/l user completeui_write(Write_number completed.)ui_write( STR_FROM_filename )RETURN 0EGER(rec-1)/ recordswrittento/END FUNCTION14.3.2讀寫(xiě) MSC.Patran 數(shù)據(jù)庫(kù)的 PCL 函數(shù)庫(kù)這是 PCL 所特有的函數(shù)庫(kù),也是函數(shù)最多的一個(gè)函數(shù)庫(kù)。通過(guò)這些函數(shù),你可以讀寫(xiě) MSC.Patran 數(shù)據(jù)庫(kù)中的任何信息,也就是說(shuō),通過(guò)這些函數(shù),MSC.Patran 完全向你開(kāi)放了。關(guān)于這部分函數(shù)的名稱及用法,請(qǐng)查閱PCL Reference Manual
10、和MSC.Patran Users Manual第四卷第九部分。下面給出一個(gè)例子。FUNCTION lug_create( )/*Pure:Create a 2-dimenal mparametric cubic patches.of a lug withINPUT:GLOBALVARIABLES:radius widthlengthR WRRadius of pin holeWidth of structure around pin hole Length from support to pin center*ERROR:return != 0, error sus from applica
11、tion callSide effects:A 2D lug is created from the specified dimens*/STRING STRING STRING STRING STRING STRINGSTRINGasm_create_grid_xyz_created_idsVIRTUALasm_sp_line_arc_created_idsVIRTUALasm_create_cord_3po_created_idsVIRTUAL asm_transform_line created_idsVIRTUAL asm_create_patch_xy_created_idsVIRT
12、UAL asm_patch_2curve_created_idsVIRTUALasm_transform_patch_created_idsVIRTUALEGER sus/* Create the constructions grid*/sus = asm_const_grid_xyz( 1, radiusasm_create_grid_xyz_created_ids )0 0,Coord0, IF( sus != 0 ) THEN RETURN sus/* Create the line describing the*/inner radius of the lugsus= asm_sp_l
13、ine_arc( 1,0 0 001, asm_s us0 1, 90.,p_line_arc_created_ids0., Coord 0, 1, Pous != 0 ) THEN RETURN s)IF(ssus= asm_sp_line_arc( 2,0 0 002, asm_s us0 1, 90.,p_line_arc_created_ids0., Coord 0, 2, Pous != 0 ) THEN RETURN s)IF(ssus= asm_const_coord_3po( 1, Coord 0, 2, 0 0 0,0 0 1, 1 0 0, asm_create_cord_
14、3po_created_ids ) us != 0 ) THEN RETURN susIF(s/* Construct the outer diameter of the lug*/sus = asm_transform_line_translate( 4, , Coord 1 , 1, TRUE, FALSE, Curve 1 ,asm_transform_line created_ids )IF( sus != 0 ) THEN RETURN sus/* Construct the patches*/sus= asm_const_patch_xyz( 1, , -length 0 0, C
15、oord 0, asm_create_patch_xy_created_ids )IF(sus != 0 ) THEN RETURN sussus= asm_const_patch_2curve_v1( 2, Curve 1 , Curve 4 ,0, , TRUE, asm_patch_2curve_created_ids )IF(sus != 0 ) THEN RETURN sussus= asm_const_patch_2curve_v1( 3, Curve 2 ,Construct 2PoCurve(Evaluate Geometry(Po6 )(Eval /uate Geometry
16、(Po9 ), 0, , TRUE, asm_patch_2curve_created_ids )IF(sus != 0 ) THEN RETURN sussus= asm_const_patch_2curve_v1( 4, Curve 3 , Surface 1.3 ,0, , TRUE, asm_patch_2curve_created_ids )IF(sus != 0 ) THEN RETURN sussus= asm_transform_patch_mirror( 5, Coord 0.2 , 0., TRUE,FALSE, Surface 1:4 , asm_transform_pa
17、tch_created_ids )RETURNsusEND FUNCTION14.3.3 編制 MSC.Patran 風(fēng)格 Motif 界面的函數(shù)庫(kù)關(guān)于這部分函數(shù)的名稱及用法,也請(qǐng)查閱MSC.Patran Users Manual第四卷第九部分3-1 頁(yè)4-154 頁(yè)。有 Motif 界面的 PCL 程序結(jié)構(gòu)比本章 14.1.3 所介紹的要復(fù)雜,如下所示:CLASS claameCLASSIWIDE declarations /* Widget ids used to retrieve data */FUNCTION init()END FUNCTION/* called only once
18、: create definition ofand forms*/FUNCTION display()/* display the forms 、theEND FUNCTIONand */FUNCTION refresh()END FUNCTION/*optional,refresh the display*/* other usrovided function */END CLASS應(yīng)用例子請(qǐng)見(jiàn)本章 14.5。14.4PCL 程序的編譯和連接一般把 PCL 程序的后綴取作“.pcl”。PCL 程序在 MSC.Patran 中可通過(guò)三種方法來(lái)進(jìn)行編譯和連接,即:(1)MSC.Patran 命令
19、行;(2)p;(3)make 。14.4.1“MSC.Patran 命令行”和“p 命令”在“MSC.Patran 命令行”和“下面一起介紹:p 命令”環(huán)境下,編譯和連接令完全一樣,!input.pclMSC.Patran,編 譯 和 連 接 filename.pcl , 并 將 函 數(shù) 調(diào) 入接著直接運(yùn)行文件中的函數(shù)名即執(zhí)行了該程序。pile .pclo.plb編譯 filename.pcl,并將它存放到.plb 庫(kù)中。!library.plb將庫(kù).plb 調(diào)入 MSC.Patran。調(diào)入 MSC.Patran 后即可執(zhí)行該庫(kù)中的函數(shù)了。如果你的程序在編制 Motif 界面時(shí)首先要作如下的預(yù)
20、編譯:了宏定義,那么在用上述命令進(jìn)行編譯和連接前,%cpp I/customization function_name.pcl output_file.cpp例如,MSC.Patran 安裝在“/msc/patran75”目錄下,預(yù)編譯命令為:要編譯和連接 abc.pcl 文件,則%cpp-I/msc/patran75/customization abc.pcl abp然后再用p 命令來(lái)預(yù)編譯“abp”文件,如下所示:敲“%/msc/pat用“!input abp”,進(jìn)入環(huán)境;p”完成編譯和連接。14.4.2 Make在你創(chuàng)建或修改完程序后,只要打入“make”,MSC.Patran 便自動(dòng)完
21、成編譯并存放到庫(kù)中去。但在你第一次做“make”前,必須先編輯如下所給的 Makefile 文件。注意:下面文件中加深顯示的三處是要根據(jù)你的文件來(lái)修改的地方。Makefile 文件:# Name of thepcl libraryPclLibrary = ./exercise.plb# List of .pob filest goo the library# Each of these files should have a corresponding .pcl file PclObjects = exercise.pob platehole2.pob plateform.pob# MSC.P
22、atran 3 home directoryP3_HOME = /disk4/msc/patran75# Location of include files.IPATH = -I$(P3_HOME)/customization -I. -I./include# Script for invoking thestandalone pclcompilerpP=$(P3_HOME)/cu#COMPILEd=for compiling asingle preprosed pcl source file$(P) $(PCFLAGS) -pob $*.CPP#sible locations for fin
23、ding the executable for cppCPPLIST = /usr/lang/cpp /usr/ccs/lib/cpp /lib/cpp /usr/lib/cpp# cpp arguments for preprosing a single pcl source fileCPPARGS = $(IPATH) -C $*.pcl $*.CPP# Define thesible file suffixes.SUFFIXES: .pcl .pob .plb#SMake suret the bourne sis used toinvokemands= /bin/sh# # # # #D
24、efine a rule for converting a .pcl sourcefile to atempts to.pob object. elligentlyon the defaultThis rule is somewhat ugly because1) it it surelocate thesearch pacpp executable given nd 2) we need to makethe compilation fails!often is nott the .pob filegetsdeletedclutterifWe usecarefullysoastonotthe
25、 screen while make is running.pcl.pob: rm-f $*.ERROR CPP= ; for i in $(CPPLIST) ; do if -f $i ; then CPP=$i ; fi ; done ; echo $CPP $(CPPARGS)$CPP $(CPPARGS)echo $(COMPILE);-$(COMPILE) ; if $? -ne 0 ; then rm -rf $*.pob ; touch $*.ERROR ; else exit 0 ; fi-f $*.CPP echorm if -f $*.ERROR ; then rm -f
26、$*.ERROR ; exit 1 ; else exit 0 ; fi# Merge all .pobso the$(PclLibrary): $(PclObjects)$(P) -m $ $(PclObjects)# Finally, define a clean rule clean:rm -f $(PclObjects)14.5 一個(gè)例子下面給出一個(gè)比較有實(shí)用意義的例子,供參考。有空的話,不妨上機(jī)一試。1Exercise.pcl 文件:CLASS exerciseFUNCTION init()WIDGETbar,item1,item2,item3bar=uil_primary.get_
27、bar_id()=ui_create(bar,exercise_,Hang Qi)item1=ui_item_create(,EX_1,Plate wiHole,FALSE)item2=ui_item_create( item3=ui_item_create(END FUNCTION,EX_2,Crossing Pipes,FALSE),EX_3,Slot,FALSE)FUNCTION exercise_(item_name) STRING item_nameSWITCH (item_name)CASE(EX_1)write(Plate wi plateForm.init() plateFor
28、m.display()CASE(EX_2)Hole Creating Funtion)write(Cross Pipes Creating Function)CASE(EX_3)write(slot M END SWITCHEND FUNCTIONEND CLASSing Funtion)2Plateform.pcl 文件:#include appforms.p CLASS plateFormCLASSWIDE WIDGET form_id,dataBox1,dataBox2,dataBox3,apply_button,cancel_buttonFUNCTIONreal* Create*/in
29、it()x_loc,y_loc the formform_id=ui_form_create( /*callback */FORM_X_LOC, FORM_Y_LOC, UL,/*/*/*/*/*/*/*x yition width height labeliconname*/*/*/*/*/*/*/FORM_WID_SML,FORM_HGT_FULL,Plate wi )Hole, /* Create the icon*/x_loc=FRAME_WID_SINGLE/2.-200*PIXEL_WID/2.+FORM_L_MARGINy_loc=FORM_T_MARGIN+ui_labelic
30、on_create(ER_WIDGET_SPACE/*/*/*/*/*parant lab_namexy icon*/*/*/*/*/form_id, x_loc,y_loc,platehole.icon)y_loc +=200.*PIXEL_HGT+ DBOX_HGT_NO_LABOVE +ER_WIDGET_SPACE/* Create the input value databox*/dataBox1 = ui_databox_create(/*/*/*/*/*/*/*/*/*Parant callbackxy*/*/*/*/form_id,FRAME_L_MARGIN, y_loc,l
31、abel_length */SINGLE_SPACE*5.0,DBOX_WID_SINGLE*0.6, box_length label valuelabel_above*/*/*/*/r=2., FALSE,/* daype*/REAL,1/* num_values */)ER_WIDGET_SPACEy_loc += DBOX_HGT_NO_LABOVE +dataBox2 = ui_databox_create( form_id, ,FRAME_L_MARGIN,y_loc,/*/*/*/*/*/*/*/*/*/*/*Parant callbackxy*/*/*/*/ label_len
32、gth */SINGLE_SPACE*5.0,DBOX_WID_SINGLE*0.6,box_length label valuelabel_above*/*/*/*/*/*/w=5., FALSE, REAL,1, )daypenum_valuesy_loc += DBOX_HGT_NO_LABOVE+ER_WIDGET_SPACEdataBox3 = ui_databox_create( form_id, ,FRAME_L_MARGIN,y_loc,/*/*/*/*/*/*/*/*/*/*/*Parant callbackxy*/*/*/*/ label_length */SINGLE_S
33、PACE*5.0,DBOX_WID_SINGLE*0.6,box_length label valuelabel_above*/*/*/*/*/*/h=10., FALSE, REAL, 1, )daypenum_valuesy_loc += DBOX_HGT_NO_LABOVE+ER_WIDGET_SPACE*2./* Create the*/apply buttonapply_button=ui_button_create(/*/*/*/*/*/*/*/*parant callbackx ywidthheight label*/*/*/*/*/*/*/form_id, apply_cb,
34、BUTTON_HALF_X_LOC1, y_loc,BUTTON_WID_HALF,0.0,Apply,TRUE,label_inside*/* highlight*/TRUE)/* Create the Cancel button*/cancel_button=ui_button_create( /*/*/*/*/*/*/*/*/*parant callbackx ywidthheight label*/*/*/*/*/*/*/form_id,cancel_cb,BUTTON_HALF_X_LOC2,y_loc,BUTTON_WID_HALF,0.0,Cancel, TRUE, label_
35、inside*/highlight*/FALSE)y_loc += BUTTON_DEFAULT_HGT+FORM_B_MARGIN+ui_wid_set(form_id,HEIGHT,y_loc) END FUNCTIONER_WIDGET_SPACEFUNCTION display() ui_form_display(plateForm)END FUNCTIONFUNCTION apply_cb()real r,w,hui_wid_get( ui_wid_get(ui_wid_get(dataBox1 dataBox2dataBox3,VALUE VALUEVALUE,r wh)ui_fo
36、rm_hide(plateForm) platehole(r,w,h)END FUNCTIONFUNCTION cancel_cb() ui_form_hide(plateForm)END FUNCTIONEND CLASS3Platehole.pcl 文件:FUNCTION platehole(r,w,h) real r,w,hSTRING coord_str32,vector_str32ui_override_message(38000217,YES)STRING sgm_sp_curve_rev_created_idsVIRTUALcoord_str=/str_from_real(r)/
37、 0 0sgm_const_curve_revolve( 1, Coord 0.3, 90., 0., Coord 0, coord_str,sgm_sp_curve_rev_created_ids )$# 1 Curve Created: Curve 1STRING sgm_curve_break_par_created_idsVIRTUAL sgm_edit_curve_break_parametric( 2, 0.5, Curve 1 , TRUE, sgm_curve_break_par_created_ids )STRING asm_create_line_xyz_created_i
38、dsVIRTUAL coord_str=/str_from_real(w)/ 0 0vector_str=asm_const_line_xyz( 4, vector_str, asm_create_line_xyz_created_ids )$# 1 Line created: Line 4 vector_str=Po5 , Coord0, STRING sgm_surface_2curve_created_idsVIRTUAL sgm_const_surface_2curve( 1, Curve 2 , Curve 4 sgm_surface_2curve_created_ids )$# 1
39、 Surface Created: Surface 1sgm_const_surface_2curve( 2, Curve 3 , Curve 5 sgm_surface_2curve_created_ids )$# 1 Surface Created: Surface 2STRING sgm_sp_surface_e_created_idsVIRTUAL vector_str=sgm_const_surface_extrude( 3, vector_str, 1., 0.,00 0,Coord0,Curve 5 , sgm_sp_surface_e_created_ids )$# 1 Sur
40、face Created: Surface 3ui_exec_function( mesh_seed_display_mgr, init ) mesh_seed_create( Surface 1.1 , 3, 10, 3., 0., 0.)ga_viewport_location_set( default_viewport, -0.066622, 1.443467, 1 )ga_viewport_location_set( default_viewport, -0.066622, 1.443467, 1 )mesh_seed_create( mesh_seed_create( mesh_se
41、ed_create(mesh_seed_create(Surface Curve 2Curve 3Surface1.1 , 3, 1, 10, 1, 10,3.1 , 1,10,0.,0.,10,3.,0.,0.,0.,0., 0.0. )0. )0., 0.)EGER fem_create_mesh_surfa_num_nodes EGER fem_create_mesh_surfa_num_elemsSTRING fem_create_mesh_s_nodes_createdVIRTUALSTRING fem_create_mesh_s_elems_createdVIRTUAL fem_create_mesh_surf_2( IsoMesh, 0, Surface 1 ,1, 0.1, Quad4, 1,1, Coord 0, Coord 0, fem_create_mesh_surfa_num_nodes, fem_create_mesh_surfa_num_elems, fem_create_mesh_s_nodes_created, fem_create_mesh_s_elems_creat
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 皮膚黑色素瘤的臨床護(hù)理
- 《數(shù)字證書(shū)及公鑰》課件
- 化膿性鼻竇炎的健康宣教
- 天皰瘡的臨床護(hù)理
- 《單片機(jī)原理及應(yīng)用 》課件-第8章
- 《Java程序設(shè)計(jì)及移動(dòng)APP開(kāi)發(fā)》課件-第07章
- 手癬的臨床護(hù)理
- 變應(yīng)性接觸性皮炎的臨床護(hù)理
- 《齒輪西農(nóng)版》課件
- JJF(陜) 050-2021 光電式皮帶張力計(jì)校準(zhǔn)規(guī)范
- 信息安全意識(shí)培訓(xùn)課件
- 攀巖智慧樹(shù)知到期末考試答案章節(jié)答案2024年華中農(nóng)業(yè)大學(xué)
- MOOC 理解馬克思-南京大學(xué) 中國(guó)大學(xué)慕課答案
- 鐵路工程工程量清單計(jì)價(jià)指南(土建部分)
- 《中國(guó)古代文學(xué)史——第四編:隋唐五代文學(xué)》PPT課件(完整版)
- 中央企業(yè)開(kāi)展網(wǎng)絡(luò)安全工作策略和方式
- 《美團(tuán)外賣商家運(yùn)營(yíng)》PPT精選文檔
- 《從百草園到三味書(shū)屋》閱讀理解題
- 人教版三年級(jí)數(shù)學(xué)上冊(cè)《第5單元 知識(shí)梳理和綜合提升》作業(yè)課件PPT優(yōu)秀教學(xué)課件
- 涂色畫(huà)簡(jiǎn)筆畫(huà)已排可直接打印涂色
- 空調(diào)維修派工單(共1頁(yè))
評(píng)論
0/150
提交評(píng)論