学NX二次开发就上UG网:
旋转UF函数:UF_MODL_create_revolution(通过对一组线或一条线绕轴旋转成一个实体特征);
UG二次开发
UG二次开发创建旋转特征C++源码:
- #include <malloc.h>
- #include <UF_ui.h>
- #include <uf_curve.h>
- #include <uf_part.h>
- #include <uf_csys.h>
- #include <stdio.h>
- #include <uf.h>
- #include <uf_part.h>
- #include <uf_curve.h>
- #include <uf_csys.h>
- #include <uf_defs.h>
- #include <uf_obj.h>
- #include <uf_layer.h>
- /* TODO: Add your application code here */
- /*中磊国际模具培训-创建旋转命令*/
-
- int obj_count;
- UF_FEATURE_SIGN mode_sign = UF_NULLSIGN;
- tag_t generators[4], line1, line2, line3, line4, *objects;
- char *body_limit[2] = { "0.0", "360.0" };
- char *offsets[2] = { "0.0", "0.0" };
- double origin[3] = { -2.0, 0.0, 0.0 };
- double direction[3] = { 0.0, 1.0, 0.0 };
- UF_MODL_SWEEP_TRIM_object_p_t trim_data = NULL;
- UF_CURVE_line_t sline1, sline2, sline3, sline4;
- /* line#1 */
- sline1.start_point[0] = 0.0;
- sline1.start_point[1] = 0.0;
- sline1.start_point[2] = 0.0;
- sline1.end_point[0] = 0.0;
- sline1.end_point[1] = 1.0;
- sline1.end_point[2] = 0.0;
- UF_CALL(UF_CURVE_create_line(&sline1, &line1));
- /* line#2 */
- sline2.start_point[0] = 0.0;
- sline2.start_point[1] = 1.0;
- sline2.start_point[2] = 0.0;
- sline2.end_point[0] = 2.5;
- sline2.end_point[1] = 3.5;
- sline2.end_point[2] = 0.0;
- UF_CALL(UF_CURVE_create_line(&sline2, &line2));
- /* line#3 */
- sline3.start_point[0] = 2.5;
- sline3.start_point[1] = 3.5;
- sline3.start_point[2] = 0.0;
- sline3.end_point[0] = 1.0;
- sline3.end_point[1] = 0.0;
- sline3.end_point[2] = 0.0;
- UF_CALL(UF_CURVE_create_line(&sline3, &line3));
- /* line#4 */
- sline4.start_point[0] = 1.0;
- sline4.start_point[1] = 0.0;
- sline4.start_point[2] = 0.0;
- sline4.end_point[0] = 0.0;
- sline4.end_point[1] = 0.0;
- sline4.end_point[2] = 0.0;
- UF_CALL(UF_CURVE_create_line(&sline4, &line4));
- generators[0] = line1;
- generators[1] = line2;
- generators[2] = line3;
- generators[3] = line4;
- UF_MODL_create_revolution(generators, 4, trim_data,
- body_limit, offsets, origin, false,
- true, origin, direction, mode_sign,
- &objects, &obj_count);
复制代码
|