学UG二次开发就上UG网:
镜像特征UF函数:UF_MODL_create_mirror_body(先在UG中创建一个特征,然后对这个特征创建镜像);镜像零件在UG模具设计的二次开发中,应用非常的广泛,比如创建边锁、回位弹簧等等;
镜像C++源码
UG二次开发镜像特征C++源码:
- #define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))
- static int report(char *file, int line, char *call, int irc)
- {
- if (irc)
- {
- char messg[133];
- printf("%s, line %d: %s\n", file, line, call);
- (UF_get_fail_message(irc, messg)) ?
- printf(" returned a %d\n", irc) :
- printf(" returned error %d: %s\n", irc, messg);
- }
- return(irc);
- }
- static void do_ugopen_api(void)
- {
- int units = UF_PART_ENGLISH;
- int arc_mode = 1;
- int align = 1, end_point = 0, body_type = 0;
- char *part_name = "mirror";
- double tol[3] = { 0.1, 0.1, 0.1 };
- double pt1[3], pt2[3], pt3[3];
- double value[6];
- double ctr_point[3] = { 50.0, 5.0, 0.0 };
- double direction[3] = { 0.0, 0.0, -1.0 };
- UF_STRING_t guide, spine;
- tag_t part_tag, arc1_tag, arc2_tag, sheet_tag, mirror_tag, dplane;
- tag_t thicken_tag, body_tag;
- /* create new part */
- UF_CALL(UF_PART_new(part_name, units, &part_tag));
- /* create the first arc */
- pt1[0] = 0.0; pt1[1] = 0.0; pt1[2] = 0.0;
- pt2[0] = 50.0; pt2[1] = 10.0; pt2[2] = 0.0;
- pt3[0] = 100.0; pt3[1] = 0.0; pt3[2] = 0.0;
- FTN(uf5063) (&arc_mode, pt1, pt2, pt3, &arc1_tag);
- /* create the second arc */
- pt1[0] = 0.0; pt1[1] = 0.0; pt1[2] = 100.0;
- pt2[0] = 50.0; pt2[1] = 10.0; pt2[2] = 100.0;
- pt3[0] = 100.0; pt3[1] = 0.0; pt3[2] = 100.0;
- FTN(uf5063) (&arc_mode, pt1, pt2, pt3, &arc2_tag);
- /* create the ruled sheet body */
- UF_MODL_create_string_list(2, 2, &guide);
- guide.num = 2;
- guide.string[0] = 1;
- guide.dir[0] = 1;
- guide.id[0] = arc1_tag;
- guide.string[1] = 1;
- guide.dir[1] = 1;
- guide.id[1] = arc2_tag;
- spine.num = 0;
- UF_CALL(UF_MODL_create_ruled(&guide,
- &spine,
- &align,
- value,
- &end_point,
- &body_type,
- UF_NULLSIGN,
- tol,
- &sheet_tag));
- UF_MODL_free_string_list(&guide);
- /* create the thickened sheet solid */
- UF_CALL(UF_MODL_create_thicken_sheet(sheet_tag,
- "1.0",
- "0.0",
- UF_NULLSIGN,
- &thicken_tag));
- /* Create Datum Plane */
- UF_CALL(UF_MODL_create_fixed_dplane(ctr_point, direction, &dplane));
- /* Get body tag of thickened sheet body */
- UF_CALL(UF_MODL_ask_feat_body(thicken_tag, &body_tag));
- /* Create a mirrored body */
- UF_CALL(UF_MODL_create_mirror_body(body_tag, dplane, &mirror_tag));
- }
- 调用子程序:
- /* TODO: Add your application code here */
- /*中磊国际模具培训-镜像实例*/
- {
- if (!UF_CALL(UF_initialize()))
- {
- do_ugopen_api();
- UF_CALL(UF_terminate());
- }
- }
复制代码
|