UG软件二次开发基础.ppt_第1页
UG软件二次开发基础.ppt_第2页
UG软件二次开发基础.ppt_第3页
UG软件二次开发基础.ppt_第4页
UG软件二次开发基础.ppt_第5页
已阅读5页,还剩32页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

UG软件二次开发基础(四),2,函数的含义?,可以通过查询UG/OpenAPI的函数时获得。,3,UF_MODL_create_block1Createsablock.TheCornerPointindicatestheoriginoftheblocktobecreated.TheX,YandZlengthscontrolthesizeoftheedgelengths.Thesignparametercontrolsthebooleanoperationperformed.Theoutputofthisfunctionistheobjectidentifierassociatedtotheblock.,TheoriginpointiswithrespecttotheAbsoluteCSYS.However,thedirectionoftheedgelengthsarewithrespecttotheWCS.,4,5,externintUF_MODL_create_block1(UF_FEATURE_SIGNsign,doublecorner_pt3,char*edge_len3,tag_t*blk_obj_id);,6,注意!,在UG/OPENAPI的功能函数中用到的描述实体的几何特性值的变量是字符型(char)的数据,而不是我们通常习惯使用的实型数据(double)。如:本例中block的长、宽、高的表示即用char*block_len3=1,2,3来说明。,7,应用举例,线性阵列(lineinstance)和环形阵列(Circularinstance),8,线性阵列,线性阵列指一个特征在一个实体上按给定距离和方向进行行和列复制多个,最后结果象一个矩阵一样排列。,9,环形阵列,环形阵列指一个特征在一个实体上按给定半径和角度复制多个,最后结果成环形排列。,10,任务,在block(长方体)或cylinder(圆柱体)上进行槽或孔的线性阵列。,11,需要的功能函数,UF_MODL_create_block1生成实体blockUF_MODL_create_cyl1生成实体cylinderUF_MODL_create_list生成实体链表(被阵列的实体必须进入链表)UF_MODL_put_list_item把实体ID号加入链表尾UF_MODL_create_linear_iset完成线性阵列,12,功能函数说明,UF_MODL_create_cyl1Createsacylinder.Theoriginindicateswherethecenterofthebottomfaceislocatedforthecylinder.Thedirectionvectorcontrolstheaxisonwhichthecylinderiscreated.Thediameterandheightcontrolthesizeofthecylinder.Thesignparametercontrolsthebooleanoperationperformed.Theoutputofthisfunctionistheobjectidentifierassociatedtothecylinder.,13,14,功能函数说明,externintUF_MODL_create_cyl1(UF_FEATURE_SIGNsign,doubleorigin3,char*height,char*diam,doubledirection3,tag_t*cyl_obj_id);,15,功能函数说明,UF_MODL_create_listCreatesalinkedlistofobjects.Alistofobjectsmaycontainidentifiersforbodies,features,facesandedges.Youusethisroutinetocreatealistforthosemodelingroutinesthatrequirealistasaninput;pleasedonotusethisforaskroutinesthatreturnlists.,16,功能函数说明,externintUF_MODL_create_list(uf_list_p_t*list);uf_list_p_t*listOutputListofobjectidentifiers,17,功能函数说明,UF_MODL_put_list_itemAddstheinputobjectidentifiertotheendofthelistthatyouinput.NOTE:Duplicatetagsaddedtothelistareignored.,18,功能函数说明,externintUF_MODL_put_list_item(uf_list_p_tlist,tag_tobj_id);uf_list_p_tlistInputListofobjectidentifiers.tag_tobj_idInputObjectidentifiertoputintolist,19,功能函数说明,UF_MODL_create_linear_isetCreatesalinearinstancesetfeatureusingtheexistingworkcoordinatesystem.ThevaluesneededarethenumberintheXCdirection,spacingfortheXCdirection,numberintheYCdirection,spacingintheYCdirection,andalistoffeaturestoinstance.Theoutputofthisfunctionistheobjectidentifierassociatedtothelinearinstanceset.Themethodoptionscorrespondtowhatisavailableinteractively.SeetheModelingUserManualfordetails.,20,功能函数说明,externintUF_MODL_create_linear_iset(intmethod,char*number_in_x,char*distance_x,char*number_in_y,char*distance_y,uf_list_p_tfeature_list,tag_t*feature_obj_id);,21,intmethodInputMethod:0=General1=Simple2=Identical,22,实例,编制孔在block上进行实体线性阵列的程序代码(假设建立的工程名称为blk),23,步骤,生成一个长方体block,它的尺寸、位置可任意给定生成一个圆柱体cylinder,让它与已生成的block进行布尔减运算(booleansubtract),得到一个有孔的复合体。实现在复合体中圆柱孔在长方体中的线性阵列(lineinstance),阵列方向、距离、位置可以任意给定。,24,建立框架,程序的宏声明程序及与UG的入口函数、卸除函数均可从UG的例程中拷贝获得。,25,实现,建立新工程,例如Blk并设置工程环境。利用VC中的FileNew建立一个新的.CPP文件。输入程序代码编译、联编后,生成动态链接库blk.dll。,26,staticvoiddo_ugopen_api(floatabc,floatorig1,floatorig2)intmethod=0;/Method:0=General,1=Simple,2=Identical;doubleblock_orig3=orig10,orig11,orig12;doublecyl_orig3=orig20,orig21,orig22;char*block_len3;charbb420;char*cyl_height;char*cyl_diam;charcc320;doubledirection3=0,0,1;char*number_in_x;char*distance_x;char*number_in_y;char*distance_y;chardd520;tag_tblk_obj;tag_tcyl_obj_id;uf_list_p_tfeature_list;tag_tfeature_obj_id;,变量申明,float_to_char(abc0,bb0);block_len0=bb0;float_to_char(abc1,bb1);block_len1=bb1;float_to_char(abc2,bb2);block_len2=bb2;UF_CALL(UF_MODL_create_block1(sign,block_orig,block_len,28,float_to_char(abc5,dd0);number_in_x=dd0;float_to_char(abc6,dd1);distance_x=dd1;float_to_char(abc7,dd2);number_in_y=dd2;float_to_char(abc8,dd3);distance_y=dd3;UF_CALL(UF_MODL_create_list(,29,voidmain()floatabc9=5.0,4.0,3.0,4.0,0.5,3.0,1.5,2.0,1.5;/长方体和圆柱体的尺寸参数blXblYblZcylHcylD阵列参数XXLYYLfloatorig13=0.0,0.0,0.0;/长方体的原点floatorig23=1.0,1.0,0.0;/圆柱体的原点do_ugopen_api(abc,orig1,orig2);,30,运行结果,31,作业一、完成球体打孔,尺寸:sphere(直径)=(100)cylinder(直径,高度)=(30,200)三个通孔通过球心并互相垂直。,32,作业二、完成六角头螺帽的造型,尺寸:prism(内接圆直径,高度)=(30,10)六条边cone(下底径,上底径,高度)=(64.64,30,10)造型方法:prism和cone同心,实体生成后进行求交运算。,33,作业三、完成环形阵列,尺寸:cylinder(直径,高度)=(100,10)内孔:cylinder(直径,高度)=(10,10)cone(下底径,上底径,高度)=(10,6,4)孔深:8mm

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论