学UG二次开发就上UG网:
关联性基准平面开发思路:先创建点,生成基准平面,然后创建圆柱,创建与圆柱相切的基准平面,然后由第一个圆柱来生成第二个圆柱的基准轴,基准是使用UG绘图的基础,二次开发人员要精通基准的开发应用。
基准平面二次开发
基准平面二次开发C++源代码:
- /*中磊国际模具培训-创建关联性基准平面*/
-
- double point[3];
- double direction[3];
- tag_t dplane_tag;
- point[0] = 0.0;//参考点
- point[1] = 0.0;
- point[2] = 0.0;
- direction[0] = 1.0;//法矢方向
- direction[1] = 0.0;
- direction[2] = 0.0;
- UF_MODL_create_fixed_dplane(point, direction, &dplane_tag);//生成固定基准面
- UF_FEATURE_SIGN sign = UF_NULLSIGN;
- double origin[3];
- char *height = "50.0";
- char *diam = "10.0";
- double direction_cyl[3];
- tag_t cyl_tag1;
- origin[0] = 20.0;//圆柱基准点
- origin[1] = 0.0;
- origin[2] = 0.0;
- direction_cyl[0] = 0.0;//圆柱方向
- direction_cyl[1] = 0.0;
- direction_cyl[2] = 1.0;
- UF_MODL_create_cyl1(sign, origin, height, diam, direction_cyl, &cyl_tag1);//生成第一个圆柱
- tag_t cyl_tag2;
- height = "50.0";
- diam = "30.0";
- origin[0] = 80.0;//圆柱基准点
- origin[1] = 0.0;
- origin[2] = 0.0;
- direction_cyl[0] = 0.0;//圆柱方向
- direction_cyl[1] = 0.0;
- direction_cyl[2] = 1.0;
- UF_MODL_create_cyl1(sign, origin, height, diam, direction_cyl, &cyl_tag2);//生成第二个圆柱
- int count, norm_dir, type;
- double center[3], dir[3], box[6], radius, rad_data;
- uf_list_p_t face_list;
- tag_t face_id0, face_id1, body, face;
复制代码
- int num_refes = 2;
- tag_t object_tags[3];
- int point_select[3] = { 0, 0, 0 };
- int which_plane = 2;
- char angle_string = NULL;
- char offset_string = NULL;
- int num_dplanes;
- tag_t dplane_tag_relative[2];
- object_tags[0] = face_id0;
- object_tags[1] = face_id1;
- UF_MODL_create_relative_dplane(num_refes, object_tags, point_select, which_plane, NULL,
- &angle_string, &offset_string, &num_dplanes, dplane_tag_relative);//生成关联基准面
- int num_refs_daxis = 1;
- tag_t obj_eids[3];
- int point_select_daxis[3] = { 90, 0, 0 };
- tag_t daxis_feid;
- obj_eids[0] = face_id1;
- UF_MODL_create_relative_daxis(num_refs_daxis, obj_eids, point_select_daxis, &daxis_feid);//生成关联基准轴
复制代码
|