购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008 QQ号:85585969
函数结构:UF_DRF_edit_dim_assoc( tag_t dimension_tag, double old_leader_position [ 3 ], double new_leader_position [ 3 ], int new_assoc_type, UF_DRF_object_p_t new_assoc_object) 函数说明:
编辑选定维度的关联性。这适用于通过reassociating维度来更改保留维度向上最新几何形状。
函数参数:
第1个参数为输入:
dimension_tag代表参数变量,tag_t 为输入参数类型,维其关联的标签正在被编辑。
第2个参数为输入:
输入double 双精度类型的参数,参数的变量格式为old_leader_position [ 3 ],相关联的对象上的位置进行更换(箭头位置)。 - 绘制坐标,如果在图纸 - 模型空间,如果在模型坐标
第3个参数为输入:
输入double 双精度类型的参数,参数的变量格式为new_leader_position [ 3 ],新的关联对象的位置附加到。
第4个参数为输入:
输入int 整数型的参数,参数的变量格式为new_assoc_type,新的关联性水平,垂直,平行,垂直,圆柱形和折叠半径类型:1 =端点2=圆弧的中心点3 =反正切点9 =中心线的横向和纵向坐标,纵产地尺寸:0 =无1 =终点2=圆弧的中心点3 =反正切点9 =中线角度尺寸:1 =维到线路2=维度延伸线5=层面中心线弧长,半径,直径,孔,同心圆尺寸:不 应用
第5个参数为输入:
new_assoc_object代表参数变量,UF_DRF_object_p_t 为输入参数类型,新的对象(见uf_drf_types.h)的数据关联到。需要注意的是所使用的唯一字段object_tag和object_view_tag。有效object_tag类型:点,线,弧,二次曲线,三次样条,B曲线,图案和实线。
UF_DRF_edit_dim_assoc函数实例代码演示:
在下面的示例代码显示了如何选择尺寸要被编辑和将对象关联到,然后再生并显示编辑后的尺寸。
[quote]
#include <stdio.h>
#include <uf.h>
#include <uf_draw.h>
#include <uf_drf.h>
#include <uf_obj.h>
#include <uf_object_types.h>
#include <uf_part.h>
#include <uf_ui.h>
#include <uf_vec.h>
#include <uf_view.h>
static void map_model2dwg
(
double pos[3],
tag_t member_view
)
{
int dcode;
int units;
int n;
double dwg_ref[2];
double dsize[2];
double factor = 1;
double mdl_ref[3];
double mx[9];
double scale;
double tmp_pos[3];
char cur_dwg[MAX_ENTITY_NAME_SIZE] = { "" };
char member_view_name[MAX_ENTITY_NAME_SIZE];
tag_t dsp_prt_tag;
/* find the view reference point and scale */
uc5027(member_view, member_view_name, &n);
uc6442(member_view_name, mdl_ref, &scale);
/* find the drawing reference point */
uc6483(cur_dwg, member_view_name, dwg_ref);
/* find the view rotation matrix */
uc6433(member_view_name, mx);
/* subtract the view reference point */
UF_VEC3_sub(pos, mdl_ref, pos);
/* map through the view rotation matrix */
tmp_pos[0] = pos[0] * mx[0] + pos[1] * mx[1] + pos[2] * mx[2];
tmp_pos[1] = pos[0] * mx[3] + pos[1] * mx[4] + pos[2] * mx[5];
tmp_pos[2] = pos[0] * mx[6] + pos[1] * mx[7] + pos[2] * mx[8];
/* scale by the view's drawing scale */
UF_VEC3_scale(scale, tmp_pos, pos);
/* find drawing units (1 = inches, 2 = mm) */
uc6479(cur_dwg, &units, &dcode, dsize);
if (units == 2) factor = 25.4;
/* find part units (1 = mm, 2 = inches) */
dsp_prt_tag = UF_PART_ask_display_part();
UF_PART_ask_units(dsp_prt_tag, &units);
if (units == 1) factor = factor / 25.4;
/* convert to drawing units */
UF_VEC3_scale(factor, pos, pos);
/* add the drawing reference point */
UF_VEC2_add(pos, dwg_ref, pos);
/* convert back to part units */
UF_VEC3_scale(1.0/factor, pos, pos);
/* set Z to 0.0 */
pos[2] = 0.0;
}
static tag_t select_an_object
(
int selection_type,
double cursor_position[3],
tag_t *view_tag
)
{
int return_code;
char *text;
tag_t object_tag;
UF_UI_selection_options_t opts;
UF_UI_mask_t mask[7];
if (selection_type == 1)
{
opts.num_mask_triples = 1;
opts.mask_triples = &mask[0];
opts.mask_triples->object_type = UF_dimension_type;
opts.mask_triples->object_subtype = UF_all_subtype;
opts.mask_triples->solid_type = 0;
text = "Select a dimension at arrow to be reassociated";
}
else
{
opts.num_mask_triples = 7;
opts.mask_triples = mask;
opts.mask_triples[0].object_type = UF_line_type;
opts.mask_triples[0].object_subtype = 0;
opts.mask_triples[0].solid_type = 0;
opts.mask_triples[1].object_type = UF_circle_type;
opts.mask_triples[1].object_subtype = 0;
opts.mask_triples[1].solid_type = 0;
opts.mask_triples[2].object_type = UF_conic_type;
opts.mask_triples[2].object_subtype = UF_all_subtype;
opts.mask_triples[2].solid_type = 0;
opts.mask_triples[3].object_type = UF_spline_type;
opts.mask_triples[3].object_subtype = 0;
opts.mask_triples[3].solid_type = 0;
opts.mask_triples[4].object_type = UF_point_type;
opts.mask_triples[4].object_subtype = 0;
opts.mask_triples[4].solid_type = 0;
opts.mask_triples[5].object_type = UF_solid_type;
opts.mask_triples[5].object_subtype =
UF_solid_edge_subtype;
opts.mask_triples[5].solid_type =
UF_UI_SEL_FEATURE_ANY_EDGE;
opts.mask_triples[6].object_type =
UF_solid_silhouette_type;
opts.mask_triples[6].object_subtype = 0;
opts.mask_triples[6].solid_type = 0;
text = "Select the edge to associate";
}
opts.scope = UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY;
UF_UI_select_single(text, &opts,
&return_code, &object_tag, cursor_position,
view_tag);
if (return_code == 5)
return object_tag;
else
return NULL_TAG;
}
void ufusr(char *param, int *retcode, int param_len)
{
int ifail;
int any_view = 0;
int new_assoc_type = 1;
double old_leader_position[3];
double new_leader_position[3];
char error_message[133] = "";
tag_t view_tag;
tag_t dimension_tag;
UF_DRF_object_t new_assoc_object;
if (!UF_initialize())
{
/* set the cursor to select in any view */
UF_UI_set_cursor_view(any_view);
/* select the dimension to edit */
dimension_tag = select_an_object(1, old_leader_position,
&view_tag);
if (dimension_tag)
{
/* initialize the new object structure */
UF_DRF_init_object_structure(&new_assoc_object);
/* select the new object to associate the dimension to
*/
new_assoc_object.object_tag
= select_an_object(2, new_leader_position, &view_tag);
/* map the leader position to the drawing */
map_model2dwg(new_leader_position, view_tag);
if (new_assoc_object.object_tag)
{
new_assoc_object.object_view_tag = view_tag;
new_assoc_object.object_assoc_type =
UF_DRF_end_point;
new_assoc_object.object_assoc_modifier =
UF_DRF_first_end_point;
new_assoc_object.object2_tag = NULL_TAG;
/* edit the dimension associativity */
ifail = UF_DRF_edit_dim_assoc(dimension_tag,
old_leader_position,
new_leader_position,
new_assoc_type,
&new_assoc_object);
/* unhighlight the new object */
UF_DISP_set_highlight(new_assoc_object.object_tag,
FALSE);
}
/* unhighlight the dimension */
UF_DISP_set_highlight(dimension_tag, FALSE);
}
printf("UF_DRF_edit_dim_assoc sample ");
if(ifail)
{
ifail = UF_get_fail_message( ifail, error_message );
printf( "fails.\nError is: %s\n", error_message );
}
else
printf( "is successful.\n" );
UF_terminate();
}
}
[/quote]