点击查看详细介绍

UGopen/Ufun C API 草图操作函数代码说明

haolin2008 9年前 5687 42

购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008  QQ号:85585969  


#include <uf_sket.h>
#include <uf_curve.h>
#include <uf_part.h>

char name[30] = "Sketch_001";//草图名称
tag_t sketch_id;
UF_SKET_initialize_sketch ( name, &sketch_id );//初始化草图

int option = 2;//草图位置由坐标系确定
double matrix[9];
tag_t object[2];
int reference[2];
int plane_dir = 1;
matrix[0] = 1;//X轴
matrix[1] = 0;
matrix[2] = 0;
matrix[3] = 0;//Y轴
matrix[4] = 1;
matrix[5] = 0;
matrix[6] = 0;//用来确定草图的坐标系的原点
matrix[7] = 0;
matrix[8] = 0;
//创建新的草图
UF_SKET_create_sketch ( name, option, matrix, object, reference, plane_dir, &sketch_id );

tag_t line_tag1;
UF_CURVE_line_s line_coords1;
line_coords1.start_point[0] = 0.0;
line_coords1.start_point[1] = 0.0;
line_coords1.start_point[2] = 0.0;
line_coords1.end_point[0] = 10.0;
line_coords1.end_point[1] = 10.0;
line_coords1.end_point[2] = 0.0;
UF_CURVE_create_line ( &line_coords1, &line_tag1 );//生成直线1

tag_t line_tag2;
UF_CURVE_line_s line_coords2;
line_coords2.start_point[0] = 15.0;
line_coords2.start_point[1] = 0.0;
line_coords2.start_point[2] = 0.0;
line_coords2.end_point[0] = 25.0;
line_coords2.end_point[1] = 10.0;
line_coords2.end_point[2] = 0.0;
UF_CURVE_create_line ( &line_coords2, &line_tag2 );//生成直线2

●●●请先 登陆注册 后查看●●●

//平行尺寸类型
dim_type = UF_SKET_parallel_dim;

dim_objs[0].object_tag = line_tag1;
dim_objs[0].object_assoc_type = UF_SKET_end_point;
dim_objs[0].object_assoc_mod_&#118alue = UF_SKET_first_end_point;
dim_objs[1].object_tag = line_tag2;
dim_objs[1].object_assoc_type = UF_SKET_end_point;
dim_objs[1].object_assoc_mod_&#118alue = UF_SKET_first_end_point;
dim_origin[0] = -20.0;
dim_origin[1] = 0.0;
dim_origin[2] = 0.0;
//创建尺寸约束
UF_SKET_create_dimensional_constraint ( sketch_id, dim_type, num_dim_obj, dim_objs, dim_origin, &con_tag );

//平行约束类型
UF_SKET_con_type_t con_type = UF_SKET_parallel;
UF_SKET_con_geom_s con_geoms[2];
int num_con_geoms = 2;
tag_t geom_con_tag;
con_geoms[0].geom_tag = line_tag1;
con_geoms[1].geom_tag = line_tag2;
//创建几何约束
UF_SKET_create_geometric_constraint ( sketch_id, con_type, num_con_geoms, con_geoms, &geom_con_tag );

int num_exps;
tag_t *expression_tags;
//查询草图中的表达式
UF_SKET_ask_exps_of_sketch ( sketch_id, &num_exps, &expression_tags );

int num_cons;
tag_t *con_tags;
//查询草图中的几何约束
UF_SKET_ask_geo_cons_of_sketch ( sketch_id, &num_cons, &con_tags );

//更新草图
UF_SKET_update_sketch ( sketch_id );

//关闭草图
UF_SKET_terminate_sketch();

UF_free( expression_tags );
UF_free( con_tags );



2

最新回复 (42)
  • wxwxwxwx 9年前
    1

    谢谢分享。。。。。。。。。。

  • yccong 9年前
    2

    学习中,谢谢楼主分享。。。

  • l6029901 9年前
    3

    回复:楼主
    学习学习学习

  • c1_wangyf 9年前
    4

    学习中,谢谢楼主分享。。。

  • 风中劲草 8年前
    5

    谢谢分享。。。。。。。。。。

  • wucrew 8年前
    6

    谢谢分享,学习,辛苦了

  • q1355188058 8年前
    7

    谢谢,学习了.................................

  • aba_sim 8年前
    8

    谢谢,学习了

  • 穿着隐身的 8年前
    9

    oooooooooooooo

  • bbs1860 8年前
    10

    学习中,谢谢楼主分享。。。

  • loxa 8年前
    11

    感謝大無私分享6666666666666

  • wangaibohit VIP会员 8年前
    12

    谢谢分享,好好学习一下

  • l965940541 7年前
    13

    谢谢,学习了.................................

  • littleseven 7年前
    14

    谢谢回复:楼主

  • yunxuange168 7年前
    15

    谢谢分享,学习,辛苦了

请登录后发表新帖