本节主要讲述通过ufun函数直接创建块、基准平面、凸台、垫块、腔体,涉及ufun函数如下:
1、创建块 UF_MODL_create_block
2、创建基准平面 UF_MODL_create_fixed_dplane
3、创建凸台 UF_MODL_create_boss
4、创建垫块 UF_MODL_create_rect_pad5
5、创建腔体 UF_MODL_create_rect_pocket
效果图如下:
1、源码实例
#include <stdio.h>
#include <uf.h>
#include <uf_defs.h>
#include <uf_modl.h>
#include <uf_modl_primitives.h>
#include <uf_part.h>
/* ARGSUSED */
void ufusr(char *param, int *retcod, int param_len)
{
int ifail=0;
int units=1; /*1=metric, 2=english*/
char error_message[MAX_LINE_SIZE + 1];
char * prtnam = "cre_fea_by_dtm_tst";
char * blk_edg_len[3] = {"50", "60", "70"};
char * pad_size[3]={"5","6","5.5"};
char * pock_len[3]={"6.2","6.3","6.4"};
char * boss_diam="5";
char * boss_height="6";
char * boss_ang="10";
char * pad_corner="1";
char * pad_ang="10";
char * pock_corner="3";
char * pock_floor=".1";
char * pock_ang="5";
tag_t blk_tag;
tag_t targ_tag=NULL_TAG;
tag_t plane_tag;
tag_t boss_tag;
tag_t pad_tag;
tag_t pock_tag;
tag_t part_tag;
double blk_corner[3] = {0,0,0};
double planepnt[3]={0,0,0};
double planedir[3]={1,0,0};
double boss_loc[3]={0,45,65};
double boss_dir[3]={-1,0,0};
double pad_loc[3]={0,45,15};
double pad_dir[3]={-1,0,0};
double pad_x_dir[3]={0,0,-1};
double pock_loc[3]={0,45,35};
double pock_dir[3]={1,0,0};
double pock_x_dir[3]={0,0,-1};
ifail = UF_initialize();
if( !ifail )
{
/* Create new part. */
ifail = UF_PART_new( prtnam, units, &part_tag );
}
if( !ifail )
{
/* Create block. */
ifail = UF_MODL_create_block( UF_NULLSIGN, targ_tag,
blk_corner, blk_edg_len,
&blk_tag );
}
if( !ifail )
{
/* Create fixed datum plane. */
ifail = UF_MODL_create_fixed_dplane( planepnt, planedir,
&plane_tag );
}
if( !ifail )
{
/* Create Boss */
ifail = UF_MODL_create_boss( boss_loc, boss_dir, boss_diam,
boss_height, boss_ang, plane_tag,
&boss_tag );
}
if( !ifail )
{
/* Create Pad */
ifail = UF_MODL_create_rect_pad( pad_loc, pad_dir, pad_x_dir,
pad_size, pad_corner, pad_ang,
plane_tag, &pad_tag);
}
if( !ifail )
{
/* Create Pocket */
ifail = UF_MODL_create_rect_pocket( pock_loc, pock_dir,
pock_x_dir,pock_len,
pock_corner, pock_floor,
pock_ang, plane_tag, &pock_tag);
}
printf( "UF_MODL_cre_fea_by_dtm sample " );
if( ifail )
{
ifail = UF_get_fail_message( ifail, error_message );
printf( "fails.\nError is: %s\n", error_message );
}
else
printf( "is successful.\n" );
ifail = UF_terminate();
}
2、源码分析
1)创建基准平面,需要指定基准点、方向向量,输出基准平面tag
2)创建凸台,需要指定凸台的位置、方向、直径、高度、尖角的角度、约束面,输出凸台的featureid
int UF_MODL_create_boss
(double location [3],)
double direction [3],
char * diame,
char * height,
char * angle,
tag_t face,
tag_t * feature_obj_id3)创建垫块,需要指定垫块的位置、方向、x direction、尺寸、垫角半径、垫缀角、约束面,输出垫块的featureid
int UF_MODL_create_rect_pad
(double location [],
double direction [],
double x_dir [3],
char * size [3],
char * radius,
char * angle,
tag_t face,
tag_t * feature_obj_id)
4)创建腔体,需要指定腔体的位置、方向、x direction、尺寸、袋角半径、地板半径、袋锥角、约束面,输出腔体的featureid
int UF_MODL_create_rect_pocket
(double location [],)
double direction [],
double x_dir [],
char * len [3],
char * corner,
char * floor,
char * angle,
tag_t face,
tag_t * feature_obj_id