|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码
3 e: C& ?+ E! ?' R0 w4 \: E& t: J! a# o# l' G- r4 r& D
- <p>static void do_UGopenapi()
! p3 F/ s" T6 A8 t3 e - {
' v' I1 }3 a5 I+ M; ^. D9 d - /*
, b" H4 L+ a! n9 F" |4 M, T' n2 h. ` - Create Curve) W( b: p( J) t; g7 A
- */- \! y- D2 u4 p8 }: d4 m, e
- // create line+ z9 [* _: M/ `5 p
- UF_CURVE_line_t line_coords;8 w+ w2 h5 q" L O) g6 J
- tag_t line;
, C3 K2 ?* a* d9 M2 @ - line_coords.start_point[0]=0;* W3 t2 p: R* _$ y
- line_coords.start_point[1]=0; x1 m9 X. A/ S) N' k; P
- line_coords.start_point[2]=0;. K' B' ]: x8 w& |3 W' d
- line_coords.end_point[0]=100;( @" c2 ~ ]! S5 N
- line_coords.end_point[1]=100;+ u" ^' n3 z3 Y5 G9 x; Z& y
- line_coords.end_point[2]=100;
: _0 D; u! ^) d7 \, B - UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc: o" D1 v# Z8 G: D: i" t9 w" t
- UF_CURVE_arc_t arc_coords;
* R. N5 N, _/ h0 H; m3 ?& Y - tag_t arc,marix,wcs;
& @# L# F1 H* H2 I8 m - UF_CSYS_ask_wcs(&wcs);
% a& N5 A0 X4 ?+ I. n - UF_CSYS_ask_matrix_of_object(wcs,&marix);8 Y/ k7 ^- ?* z1 I8 W
- arc_coords.arc_center[0]=0;
# p4 s9 q2 ~, [' ?8 i - arc_coords.arc_center[1]=0;3 j/ H! \' H; g& ~5 S: {4 w( l S
- arc_coords.arc_center[2]=0;
* _ f1 F! z( Z( z0 C8 ? - arc_coords.start_angle=90*DEGRA;
8 d9 W5 \5 b# z! f j" G: `( K$ k) h - arc_coords.end_angle=270*DEGRA;
4 C' U* d4 P# `2 a$ x2 b8 \/ G - arc_coords.radius=100;
" [# `1 x; v' V5 } - arc_coords.matrix_tag=marix;( ^, P y! I D# p) t- t) u
- UF_CURVE_create_arc(&arc_coords,&arc);0 |' N% e' w+ h; g' I, v8 u9 \% q
- // create point
+ Z! U7 { {( n - double point_coords[3]={100,100,100};# v: o5 D* k' c: j( G/ b8 p" @
- tag_t point;
& `, t- f2 u @! x( b - UF_CURVE_create_point(point_coords,&point); X9 t# X$ U, _$ ~' \( Q
-
6 c0 n; ~" ?" d; l - // create Plane
$ o& K% f* c) @8 t, I3 n3 T - double origin_point[3]={100,100,100};
& x7 I. r5 w: Q+ O - double plane_normal[3]={1,0,0};7 {: ?: ]' q0 |+ `: N: B
- tag_t plane_tag; 7 ^3 j6 |1 }# l
- UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*3 K& D& v7 a3 U9 n
- Get the curve information5 s8 w: T0 m# m9 f; V
- */2 o- c P( f! ^, Z8 {; `- e4 R
- UF_UI_open_listing_window();& c7 O9 G) v5 u
- char msg[132];
4 ^$ i2 J7 J3 N1 J1 ^+ j - // get line information+ c2 u. s1 U1 }" x# N U
- UF_CURVE_line_t line_info;
* D' n6 M0 `8 @7 g e! s - UF_CURVE_ask_line_data(line,&line_info);/ x' Z+ u7 U0 P
- sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],& i0 o6 S- w' S2 y# j
- line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],: \8 E* h0 [3 F0 a2 T) m2 a
- line_info.end_point[2]);
# C2 [- ^# H. R5 L% A3 N - UF_UI_write_listing_window(msg);
: H9 z5 T4 t6 i0 G/ w: e - //get the point information
* t( U6 w0 C" x( T - double point_info[3];+ E" g0 w: p" Z6 z
- UF_CURVE_ask_point_data(point,point_info);, _. `/ h- x9 i+ @2 O& i6 I
- sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);
" w3 S0 I6 T2 j$ q - UF_UI_write_listing_window(msg);</p><p> //get the arc information
3 D# l1 X: P0 |9 b4 _9 @ - UF_CURVE_arc_t arc_info;
1 T9 `' ?& q) { - UF_CURVE_ask_arc_data(arc,&arc_info);$ o+ x/ [. j6 W* R' l
- 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;",
6 \. V- {7 p% F8 |" X4 @* Y - arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],
2 W/ o( }2 r" N* Q, z$ a - arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius
$ T$ Y0 M- M }5 b& N7 V - );
; R, A3 ]; N3 Z; Z% m" K - UF_UI_write_listing_window(msg);
$ L3 b F+ `# D6 M - // calculate the arc length2 ^& @- W" G2 [9 b3 d' ^
- double arc_length;9 d1 b" @/ t7 _+ O) n7 T2 q
- UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);2 d, b& p2 {3 J, R# o' G
- sprintf(msg,"\nArc Length:\n\t%lf",arc_length);: f/ Z6 ]5 K. E
- UF_UI_write_listing_window(msg);. M/ Q# n" b& [
- }7 ]5 k% m) [' e8 }2 z _
- </p><p> </p>
复制代码
) s$ |6 s6 c, V% e9 P! }9 s |
|