借鉴一位学生的程序,设置带轮颜色以及完成质量属性测量
UF_CURVE_line_t line1, line2, line3, line4, line5, line6, line7, line8, line9, line10, line11, line12, line13, line14, line15, line16, line17, line18, line19, line20;
line1.start_point[0] = 7.5; //定义旋转线的起点
line1.start_point[1] = 0;
line1.start_point[2] = 15.0;
line1.end_point[0] = 16.0; //定义旋转线的终点
line1.end_point[1] = 0.0;
line1.end_point[2] = 15.0;
line2.start_point[0] = 16.0;
line2.start_point[1] = 0.0;
line2.start_point[2] = 15.0;
line2.end_point[0] = 16.0;
line2.end_point[1] = 0.0;
line2.end_point[2] = 3.0;
line3.start_point[0] = 16.0;
line3.start_point[1] = 0.0;
line3.start_point[2] = 3.0;
line3.end_point[0] = 45.0;
line3.end_point[1] = 0.0;
line3.end_point[2] = 3.0;
line4.start_point[0] = 45.0;
line4.start_point[1] = 0.0;
line4.start_point[2] = 3.0;
line4.end_point[0] = 45.0;
line4.end_point[1] = 0.0;
line4.end_point[2] = 11.0;
line5.start_point[0] = 45.0;
line5.start_point[1] = 0.0;
line5.start_point[2] = 11.0;
line5.end_point[0] = 55.0;
line5.end_point[1] = 0.0;
line5.end_point[2] = 11.0;
line6.start_point[0] = 55.0;
line6.start_point[1] = 0.0;
line6.start_point[2] = 11.0;
line6.end_point[0] = 55.0;
line6.end_point[1] = 0.0;
line6.end_point[2] = 6.22;
line7.start_point[0] = 55.0;
line7.start_point[1] = 0.0;
line7.start_point[2] = 6.22;
line7.end_point[0] = 50.0;
line7.end_point[1] = 0.0;
line7.end_point[2] = 4.498;
line8.start_point[0] = 50.0;
line8.start_point[1] = 0.0;
line8.start_point[2] = 4.498;
line8.end_point[0] = 50.0;
line8.end_point[1] = 0.0;
line8.end_point[2] = 1.498;
line9.start_point[0] = 50.0;
line9.start_point[1] = 0.0;
line9.start_point[2] = 1.498;
line9.end_point[0] = 55.0;
line9.end_point[1] = 0.0;
line9.end_point[2] = 1.5;
line10.start_point[0] = 55.0;
line10.start_point[1] = 0.0;
line10.start_point[2] = 1.5;
line10.end_point[0] = 55.0;
line10.end_point[1] = 0.0;
line10.end_point[2] = -1.5;
line11.start_point[0] = 55.0;
line11.start_point[1] = 0.0;
line11.start_point[2] = -1.5;
line11.end_point[0] = 50.0;
line11.end_point[1] = 0.0;
line11.end_point[2] = -1.498;
line12.start_point[0] = 50.0;
line12.start_point[1] = 0.0;
line12.start_point[2] = -1.498;
line12.end_point[0] = 50.0;
line12.end_point[1] = 0.0;
line12.end_point[2] = -4.498;
line13.start_point[0] = 50.0;
line13.start_point[1] = 0.0;
line13.start_point[2] = -4.498;
line13.end_point[0] = 55.0;
line13.end_point[1] = 0.0;
line13.end_point[2] = -6.22;
line14.start_point[0] = 55.0;
line14.start_point[1] = 0.0;
line14.start_point[2] = -6.22;
line14.end_point[0] = 55.0;
line14.end_point[1] = 0.0;
line14.end_point[2] = -11.0;
line15.start_point[0] = 55.0;
line15.start_point[1] = 0.0;
line15.start_point[2] = -11;
line15.end_point[0] = 45.0;
line15.end_point[1] = 0.0;
line15.end_point[2] = -11.0;
line16.start_point[0] = 45.0;
line16.start_point[1] = 0.0;
line16.start_point[2] = -11;
line16.end_point[0] = 45.0;
line16.end_point[1] = 0.0;
line16.end_point[2] = -3.0;
line17.start_point[0] = 45.0;
line17.start_point[1] = 0.0;
line17.start_point[2] = -3;
line17.end_point[0] = 16.0;
line17.end_point[1] = 0.0;
line17.end_point[2] = -3.0;
line18.start_point[0] = 16.0;
line18.start_point[1] = 0.0;
line18.start_point[2] = -3;
line18.end_point[0] = 16.0;
line18.end_point[1] = 0.0;
line18.end_point[2] = -15.0;
line19.start_point[0] = 16.0;
line19.start_point[1] = 0.0;
line19.start_point[2] = -15;
line19.end_point[0] = 7.5;
line19.end_point[1] = 0.0;
line19.end_point[2] = -15.0;
line20.start_point[0] = 7.5;
line20.start_point[1] = 0.0;
line20.start_point[2] = -15;
line20.end_point[0] = 7.5;
line20.end_point[1] = 0.0;
line20.end_point[2] = 15;
tag_t L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13, L14, L15, L16, L17, L18, L19, L20; //定义线的指针//
UF_CURVE_create_line(&line1, &L1); //创建线的数据和指针关系//
UF_CURVE_create_line(&line2, &L2);
UF_CURVE_create_line(&line3, &L3);
UF_CURVE_create_line(&line4, &L4);
UF_CURVE_create_line(&line5, &L5);
UF_CURVE_create_line(&line6, &L6);
UF_CURVE_create_line(&line7, &L7);
UF_CURVE_create_line(&line8, &L8);
UF_CURVE_create_line(&line9, &L9);
UF_CURVE_create_line(&line10, &L10);
UF_CURVE_create_line(&line11, &L11);
UF_CURVE_create_line(&line12, &L12);
UF_CURVE_create_line(&line13, &L13);
UF_CURVE_create_line(&line14, &L14);
UF_CURVE_create_line(&line15, &L15);
UF_CURVE_create_line(&line16, &L16);
UF_CURVE_create_line(&line17, &L17);
UF_CURVE_create_line(&line18, &L18);
UF_CURVE_create_line(&line19, &L19);
UF_CURVE_create_line(&line20, &L20);
int obj_count; //定义计数器
UF_FEATURE_SIGN mode_sign = UF_NULLSIGN; //布尔操作无操作
tag_t generators[20], * objects; //生成数量
char* body_limit[2] = { "0.0", "360.0" };//旋转角度
char* offsets[2] = { "0.0", "0.0" };
double origin[3] = { 0.0, 0.0, 0.0 };//拉伸方向
double direction[3] = { 0.0, 0.0, 1.0 };
UF_MODL_SWEEP_TRIM_object_p_t trim_data = NULL;
generators[0] = L1; //把线放入生成集合
generators[1] = L2;
generators[2] = L3;
generators[3] = L4;
generators[4] = L5;
generators[5] = L6;
generators[6] = L7;
generators[7] = L8;
generators[8] = L9;
generators[9] = L10;
generators[10] = L11;
generators[11] = L12;
generators[12] = L13;
generators[13] = L14;
generators[14] = L15;
generators[15] = L16;
generators[16] = L17;
generators[17] = L18;
generators[18] = L19;
generators[19] = L20;
UF_MODL_create_revolution(generators, 20, trim_data, body_limit, offsets, origin, false, true, origin, direction, mode_sign, &objects, &obj_count); //创建旋转特征
UF_FEATURE_SIGN sign1 = UF_NEGATIVE;
double cylinder_orig1[3] = { 0.0,30.0,-6 };
char* height1 = "12";
char* diam1 = "24";
double direction1[3] = { 0.0,0.0,1.0 };
tag_t cyl_obj_id1;
UF_MODL_create_cyl1(sign1, cylinder_orig1, height1, diam1, direction1, &cyl_obj_id1);//创建圆柱特征1
double origin1[3] = { 0.0, 0.0, 0.0 };//定义环形阵列轴的原点
double direction2[3] = { 0.0, 0.0, 1.0 };//定义环形阵列轴的方向
tag_t feat_obj;
uf_list_p_t feat_list;
UF_MODL_create_list(&feat_list);
UF_MODL_put_list_item(feat_list, cyl_obj_id1);
UF_MODL_create_circular_iset(0, origin1, direction2, "6", "60", feat_list, &feat_obj);//创建环形阵列
UF_FEATURE_SIGN sign3 = UF_NEGATIVE;
double block_orig[3] = { 0.0,-2.0,-15 };
char* block_len[3] = { "9.6","4","30" };
tag_t blk_obj;
UF_MODL_create_block1(sign3, block_orig, block_len, &blk_obj);
tag_t revbody;
UF_MODL_ask_feat_body(objects[0], &revbody);
**//设置体的颜色**
UF_OBJ_set_color(revbody, 150);
**//测量质量属性**
int num_objs = 1;
int type = 1;
int unit = 3;
double density = 1.0;
int accuracy = 1;
//帮助文件中,accuracy = 1时,acc_value[0]值 在0到1之间定义,acc_value[1-10]失去效用
double acc_val[11] = { 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 };
double mass_props[47];
double statistics[13];
UF_MODL_ask_mass_props_3d(&revbody, num_objs, type, unit, density, accuracy, acc_val, mass_props, statistics);测量体的质量特性
char Widthchar13[256];
sprintf(Widthchar13, "%f", mass_props[1]);//输出体积
uc1601(Widthchar13, 1);
**注:测量对象质量属性和修改对象颜色,直观理解为修改体的各种属性,因此首先应得到需要修改的体的对象标识符。**