NX二次开发-创建直线(起点-向量方向-长度)UF_CURVE_create_line

 1     NX9+VS2012
 2 
 3     #include <uf.h>
 4     #include <uf_curve.h>
 5     #include <uf_csys.h>
 6     #include <uf_mtx.h>
 7 
 8 
 9     UF_initialize();
10 
11     //创建向量方向
12     double Vec[3] = { 10.0, 23.5, 75.8 };
13 
14     //3*3矩阵,输入Z向量,得到矩阵
15     double Mtx[9];
16     UF_MTX3_initialize_z(Vec, Mtx);
17 
18     //创建矩阵
19     tag_t MatrixTag = NULL_TAG;
20     UF_CSYS_create_matrix(Mtx, &MatrixTag);
21 
22     //创建临时坐标系
23     double P1[3] = { 0.0, 0.0, 0.0 };//直线起点
24     tag_t CsysTag = NULL_TAG;
25     UF_CSYS_create_temp_csys(P1, MatrixTag, &CsysTag);
26 
27     //设置WCS
28     UF_CSYS_set_wcs(CsysTag);
29 
30     //创建直线终点
31     double P2[3] = { P1[0], P1[1], P1[2] + 100 };
32 
33     //从当前工作坐标系转换到绝对坐标系
34     int InputCsys = UF_CSYS_ROOT_WCS_COORDS;
35     int OutputCsys = UF_CSYS_ROOT_COORDS;
36     double OutputPoint[3];
37     UF_CSYS_map_point(InputCsys, P2, OutputCsys, OutputPoint);
38 
39     //创建直线
40     UF_CURVE_line_t LineCoods;
41     LineCoods.start_point[0] = P1[0];
42     LineCoods.start_point[1] = P1[1];
43     LineCoods.start_point[2] = P1[2];
44     LineCoods.end_point[0] = OutputPoint[0];
45     LineCoods.end_point[1] = OutputPoint[1];
46     LineCoods.end_point[2] = OutputPoint[2];
47     tag_t LineTag = NULL_TAG;
48     UF_CURVE_create_line(&LineCoods, &LineTag);
49 
50     UF_terminate();

原文地址:https://www.cnblogs.com/nxopen2018/p/10957300.html