|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码
+ j* a' V9 o8 J+ d9 e/ b/ T: W
! t, |7 Z) @6 E4 {8 P l- <p>static void do_UGopenapi()4 } u# M0 Y7 w3 m& S8 ?0 L
- {
- e" c" c$ S/ g! A: k# a3 | - /*
0 Q! [8 b6 m, J% p% U* `. H - Create Curve( K& `8 B. O) V7 b. ~3 Y" J9 j
- */
* y" W4 }5 G8 a% E& Z, @ - // create line
" G$ _: o. w- U7 ^ - UF_CURVE_line_t line_coords;' D, R: G) @% H! ~( |* X
- tag_t line;# f) [& n, O) ~, Q, R1 S
- line_coords.start_point[0]=0;% P. X0 Y+ @5 z, N1 R0 \ y
- line_coords.start_point[1]=0;8 L: \) m2 ?! H; |2 E
- line_coords.start_point[2]=0;
c; x" ^0 [8 V' l# e/ s! J4 a - line_coords.end_point[0]=100;( j- b7 a3 T- J7 p/ F N. ^$ k
- line_coords.end_point[1]=100; S, }' C1 P( ]' X: W Y
- line_coords.end_point[2]=100;) V5 B, E+ A2 Y4 h
- UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc* T; G6 T$ R: z' I
- UF_CURVE_arc_t arc_coords;/ } C+ }# y: i3 }
- tag_t arc,marix,wcs;# p9 `. \5 @9 Z H. o
- UF_CSYS_ask_wcs(&wcs);; Z/ P7 {* L& X9 k. `: c
- UF_CSYS_ask_matrix_of_object(wcs,&marix);1 B# k4 i7 E$ D. O
- arc_coords.arc_center[0]=0;
+ V! Z" m, A7 a8 b- K/ G6 ] - arc_coords.arc_center[1]=0;: d( G d. ~2 x( v8 j$ [; C! m% o
- arc_coords.arc_center[2]=0;2 V( r. q. ?. v0 H4 {& T
- arc_coords.start_angle=90*DEGRA;
5 ]6 h# t6 c- |& j) D+ F& F8 l5 J - arc_coords.end_angle=270*DEGRA;" d |" m" j7 n
- arc_coords.radius=100;! `% x0 Y/ V" Z
- arc_coords.matrix_tag=marix;
9 j+ M, ~. V" P% S6 n/ N/ U - UF_CURVE_create_arc(&arc_coords,&arc);& C- {8 h( j4 V/ b* E9 X. Z
- // create point - s9 D% C" o2 a7 H# K$ g
- double point_coords[3]={100,100,100};9 \0 u/ P3 c( `$ g) e9 M
- tag_t point;
1 ?" u( Q9 s" q; E - UF_CURVE_create_point(point_coords,&point);$ `% f5 X* S% s. }0 s& o8 C' r a7 N
-
2 [% _4 Q" P9 G4 [ - // create Plane
0 i# f7 N& c' r" `' j - double origin_point[3]={100,100,100};
- g7 W/ K) r- D- S# ? - double plane_normal[3]={1,0,0};
$ I/ \# S) U) X3 X" ]& F2 K - tag_t plane_tag; ) G, N7 R- J; Y8 M
- UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*
" \# G. B; l i: E& H" l - Get the curve information! m0 U; b8 z8 [+ \) H' N) L
- */
3 |4 p$ |' e9 Q+ z: n% v3 B- z - UF_UI_open_listing_window();
8 y3 p B4 X+ O+ ~ - char msg[132];% c8 x% o% ?# G
- // get line information
8 L8 s) J% v9 `; z/ ~- S - UF_CURVE_line_t line_info;
: O' @' l" d i% L - UF_CURVE_ask_line_data(line,&line_info);: Z8 M; {! }2 s8 h; C& r) Y
- sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],! S% s2 {* k6 G- \# {; M2 W
- line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],# F) D; V9 A# V, D8 d, @
- line_info.end_point[2]);/ U' R; R1 I) f+ L9 T
- UF_UI_write_listing_window(msg);
0 _ u; R3 s4 k5 \& R - //get the point information4 {8 n0 X$ K. ~, N6 D
- double point_info[3];
3 L5 [: Q5 t4 j3 L! w - UF_CURVE_ask_point_data(point,point_info);
E' a! f- T; p) ^4 L - sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);
7 E& L& g8 s8 M0 ^3 ]. c - UF_UI_write_listing_window(msg);</p><p> //get the arc information7 q$ }5 s. `, F5 K% u) Q. M1 y
- UF_CURVE_arc_t arc_info;/ d! c9 T% v7 @- ]- Z! p
- UF_CURVE_ask_arc_data(arc,&arc_info);' \! |$ z s! Z
- 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;",$ W( @7 s% I* y, Z% c; V- S% l' S
- arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],
4 B5 M$ e Y$ T e* `6 ]6 F2 r( L - arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius
+ s3 I9 h) u2 c9 |% h, | - );
" c8 |1 c/ Z# V( e6 G1 x' R - UF_UI_write_listing_window(msg);
+ u8 ~0 \5 M- {, p - // calculate the arc length
( ~" o' h- N, A# s( v - double arc_length;
* t( v8 I$ k+ S) D% Y' P - UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);4 l2 C$ P/ }9 m0 ^0 a N) b
- sprintf(msg,"\nArc Length:\n\t%lf",arc_length);. S* q/ t; @! Z! m* A! _" E
- UF_UI_write_listing_window(msg);
4 v) {8 ]& l! @ - }
4 p# G/ _6 J: ?0 U1 A& g - </p><p> </p>
复制代码
5 I9 F. ^9 E# _& G, M |
|