购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008 QQ号:85585969
函数结构:UF_ASSEM_create_explosion( tag_t display_part_tag, const char* explosion_name, tag_p_t explosion_tag) 函数说明:
会在指定的显示部的 *** ;在组件大会最初在他们真正的装配位置,并且 *** 最初没有在任何意见中。
函数参数:
第1个参数为输入:
display_part_tag代表参数变量,tag_t 为输入参数类型,在其中创建 *** 的显示部的标签
第2个参数为输入:
输入const char* 字符类型的参数,参数的变量格式为explosion_name,一种 *** 名称;这必须是一个有效的NX名称值,以及不被使用通过在显示部的现有 *** 。
第3个参数为输出:
explosion_tag代表参数变量,tag_p_t 为输出参数类型,创建 *** 的标签(或空Tag的onerror)
UF_ASSEM_create_explosion函数实例代码演示:
该示例创建一个 *** 和 *** 都配合的在工作中组件组件。
[quote]
#include <uf_defs.h>
#include <uf.h>
#include <uf_layout.h>
#include <uf_obj.h>
#include <uf_assem.h>
static int explode_work_subassembly( char* explosion_name,
double standard_offset );
static int explode_assy_below_component(tag_t display_part_tag,
tag_t explosion_tag,
tag_t component_tag,
double standard_offset);
/*ARGSUSED*/
extern void ufusr(char* param, int* retcod, int param_len)
{
int error = 0;
UF_initialize();
error = explode_work_subassembly("MY_EXPLOSION", 1.0);
UF_terminate();
*retcod = error;
}
static int explode_work_subassembly( char* explosion_name,
double standard_offset )
{
tag_t work_occ_tag;
tag_t display_part_tag;
int error;
tag_t explosion_tag;
display_part_tag = UF_PART_ask_display_part();
/* Get the component tag for the work part. */
work_occ_tag = UF_ASSEM_ask_work_occurrence();
/* If not working in context, there is no work component. */
if (work_occ_tag == NULL_TAG)
{
work_occ_tag = UF_ASSEM_ask_root_part_occ(display_part_tag);
}
error = UF_ASSEM_create_explosion ( display_part_tag,
explosion_name,
&explosion_tag );
if (error != 0) return error;
error = explode_assy_below_component( display_part_tag,
explosion_tag,
work_occ_tag,
standard_offset );
return error;
}
static int explode_assy_below_component(tag_t display_part_tag,
tag_t explosion_tag,
tag_t component_tag,
double standard_offset)
{
int i, child_count;
tag_p_t child_tags;
int error;
child_count =
UF_ASSEM_ask_part_occ_children(component_tag, &child_tags);
for(i = 0; i < child_count; i++)
{
double mc_transform[4][4] =
{{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}};
double vector[3];
error = UF_ASSEM_ask_explosion_vector(child_tags[i], vector);
if (error == 0)
{
/* The output vector is guaranteed to be normalised
(adds up to 1.0)
*/
mc_transform[0][3] = standard_offset * vector[0];
mc_transform[1][3] = standard_offset * vector[1];
mc_transform[2][3] = standard_offset * vector[2];
error = UF_ASSEM_explode_component(explosion_tag,
child_tags[i],
mc_transform);
if (error != 0) return error;
}
error = explode_assy_below_component(display_part_tag,
explosion_tag,
child_tags[i],
standard_offset);
if (error != 0) return error;
}
if (child_count > 0) UF_free(child_tags);
return 0;
}
[/quote]