|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码
& f% t" P9 p8 g7 t5 Q4 I0 |* `- E" g/ W* D( B
- <p>static void do_UGopenapi()
4 K" p" k5 ^% {% T - {. q4 X, q: f& y* d4 k1 t
- /*
) g. o3 A: n0 Z: f) o - Create Curve
% D2 X1 f1 g" n - */
! X; Q3 D9 B, h ~ - // create line2 x; k9 F. D P2 H
- UF_CURVE_line_t line_coords;$ ` r& v% Q, B6 j
- tag_t line;
! y/ W$ W+ u D. D - line_coords.start_point[0]=0;; \1 S1 \ y5 M, U+ x
- line_coords.start_point[1]=0;
8 K- s: I& G0 v9 z7 o - line_coords.start_point[2]=0;2 f; M' F9 ]3 k( ^: n0 {. N
- line_coords.end_point[0]=100;
0 J$ B* k" d. z, G - line_coords.end_point[1]=100; w# A+ Y. T6 x4 Q+ O! {2 G, H; F
- line_coords.end_point[2]=100;0 z! \6 E# |' z" v+ Q
- UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc% F3 U$ }+ G% w/ @/ w; P3 m8 l
- UF_CURVE_arc_t arc_coords;1 \6 z" l8 g: U$ b
- tag_t arc,marix,wcs;7 V3 g4 e" F$ ?# w0 @. K0 ?
- UF_CSYS_ask_wcs(&wcs);
' s2 u; q, o3 H, j, c* i - UF_CSYS_ask_matrix_of_object(wcs,&marix);* S3 z7 q3 b+ `- @4 m8 ]3 Z- }$ z
- arc_coords.arc_center[0]=0;* }+ G- {+ J3 Z
- arc_coords.arc_center[1]=0;, \. X8 W3 p; n c: s
- arc_coords.arc_center[2]=0;! E( s7 l/ t1 X- R- {$ N. x
- arc_coords.start_angle=90*DEGRA;
9 ~% c- `, a. Q5 R* k - arc_coords.end_angle=270*DEGRA;
# T. g3 K U' r2 O, N - arc_coords.radius=100;0 |7 V3 H: O+ {9 R2 W& x
- arc_coords.matrix_tag=marix;& M) h/ H) T$ e+ w- j: S! u
- UF_CURVE_create_arc(&arc_coords,&arc);
* X0 U6 f+ e, d1 O - // create point
, w5 r' R$ L# Y: k" D - double point_coords[3]={100,100,100};
' J9 ^! b, y- ^* t4 o; ]6 g - tag_t point;
; @. d: i( M) r; W) k, k9 V0 h9 C - UF_CURVE_create_point(point_coords,&point);
$ M4 o6 Z3 G( a: X. C - 9 I J0 q5 \( ]. [3 t4 m' K
- // create Plane8 w, T4 y% o5 K; y W
- double origin_point[3]={100,100,100};, q( N: i$ Z! Y! n' x, c& f
- double plane_normal[3]={1,0,0};6 b0 D: H. g9 |1 p# Y! p
- tag_t plane_tag;
- X! c7 m# m) k7 W6 X. F4 k H - UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*
) J* @( O N3 `! _$ ]6 G - Get the curve information
% p$ r# {1 ~ i2 |+ G - */
* `7 D* G& ^. u! l - UF_UI_open_listing_window();
4 j% a* a* X% n - char msg[132];
, ^( A+ e+ x* ~4 ` - // get line information
; B m& q. ^, k0 Y - UF_CURVE_line_t line_info;- J; q W0 V5 V: R
- UF_CURVE_ask_line_data(line,&line_info);
- n: H" g; V' e& N; p' C - sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],
$ U' E9 s( M. F& | - line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],9 \5 b+ w/ h0 C. ?
- line_info.end_point[2]);' R2 H9 `0 e5 ?& R9 N
- UF_UI_write_listing_window(msg);
- e0 m7 N9 O- R0 K5 l: T - //get the point information
2 H7 S/ K. n+ t7 ]0 ? y3 T - double point_info[3];! b& h7 M* Z8 b0 `# d- m& Q0 d
- UF_CURVE_ask_point_data(point,point_info);
" N c! ?, {) `4 Z) O( J - sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);: `% H- S; T3 H w- g& S* b9 T
- UF_UI_write_listing_window(msg);</p><p> //get the arc information
) y' M4 x5 j0 ?$ W - UF_CURVE_arc_t arc_info;! X2 i" Q% h d/ |
- UF_CURVE_ask_arc_data(arc,&arc_info);
1 d8 h6 U" K0 X) }4 q) u - sprintf(msg,"\nArc Center coords:\n\t%lf,%lf,%lf;\nArc start Angle:\n\t%lf;\nArc End Angle:\n\t%lf;\nArc Radius:\n\t%lf;",* ~( Q4 | Q$ E/ {- d
- arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],# j0 r1 `' M* m7 \* M, _4 w/ [
- arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius
; v5 q) ?: F) w' A1 N! J' }/ s - );) J# `1 j3 C/ y9 D6 z \, K
- UF_UI_write_listing_window(msg);% c# F6 B5 l' A! |+ I9 i1 v# \) f
- // calculate the arc length2 X, P% o; f. ]$ [$ g$ S( m; T
- double arc_length;1 R1 v; _! x/ a/ L9 ? S9 y0 D
- UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);
l* E& ]9 s! `+ c Y# W% D - sprintf(msg,"\nArc Length:\n\t%lf",arc_length);+ N0 x% G! _) M7 ~4 e- m, Y1 L4 C$ ~
- UF_UI_write_listing_window(msg);6 h4 t& z' M$ ^5 M
- }
/ \' w: T2 a$ t - </p><p> </p>
复制代码
( c3 ^6 q5 L$ I& ? |
|