|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码
9 ?( z7 ~$ Q) d# a5 z
' u% s" h! Y% a0 y% I- <p>static void do_UGopenapi()
( V( Q/ m0 _, P - {% `2 T& l1 U1 `3 i7 N4 c
- /*
/ a) C# K( x% [1 K! c - Create Curve/ h* l' ]& x- L
- */
! D& k- m4 _' _, a+ E) i% X - // create line
2 O; |$ h# V3 l& L8 y0 V - UF_CURVE_line_t line_coords;- _- Y) W4 v5 p
- tag_t line;7 Z" L: R% R0 F" c: A+ ~ z8 C- M
- line_coords.start_point[0]=0;
* E$ a+ s' w2 } - line_coords.start_point[1]=0;
2 a4 K. C* I$ x6 \. {2 f/ B/ H8 P' V8 m - line_coords.start_point[2]=0;9 U4 |1 c0 x7 m f) @
- line_coords.end_point[0]=100;
9 G, b# V, k1 W" s - line_coords.end_point[1]=100;
F' ~( @2 v! p! N" T; s - line_coords.end_point[2]=100;
: ^4 L; [# {% C3 F6 ~ - UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc
4 O. t( O" ?8 V3 a( ? - UF_CURVE_arc_t arc_coords;( a. g; Y" j' P9 E
- tag_t arc,marix,wcs;2 d# ~9 \# `2 `$ }2 s) W9 e
- UF_CSYS_ask_wcs(&wcs);$ K3 t' w' ]7 o
- UF_CSYS_ask_matrix_of_object(wcs,&marix);
: P* s& X, t& c - arc_coords.arc_center[0]=0;' o) n# ~- G n& V: E- P6 |
- arc_coords.arc_center[1]=0;
( n( X* q/ v: H3 \! r - arc_coords.arc_center[2]=0;
. M9 M+ j9 P3 {+ t- f" U" H) d - arc_coords.start_angle=90*DEGRA;
* a* @0 B9 O. k! Z# F J - arc_coords.end_angle=270*DEGRA;
! u# n/ q/ o. N _% M1 b - arc_coords.radius=100;& P$ H" h! Q* q8 v' {; j2 d/ m" n3 e
- arc_coords.matrix_tag=marix;
; z( J7 u( f3 ?2 r0 V; N8 S6 U! B - UF_CURVE_create_arc(&arc_coords,&arc);
- @1 t0 P! [; Q - // create point % U& E; o/ h' F: r0 l
- double point_coords[3]={100,100,100};0 H" m( [3 w! W
- tag_t point;/ a7 |3 h5 @* [4 P4 h
- UF_CURVE_create_point(point_coords,&point);5 \- l, @3 I, x2 k: M1 K
- 5 C# M7 @$ F; g8 {
- // create Plane
; A, \( ?! J" Q! r5 V - double origin_point[3]={100,100,100};
6 l$ Q" y. z f, s5 f) G - double plane_normal[3]={1,0,0};
B) H+ K& |; E: b3 ]) w) g7 y - tag_t plane_tag; # f" l! r) j: D) n0 P# V6 l3 ~
- UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*
- E/ T5 }0 k9 u# v3 i5 A - Get the curve information
2 ^( w) N9 X& ]7 U" v - */
6 U! N! e x3 y9 m' U - UF_UI_open_listing_window();! l$ C" k( i5 g# \9 o1 Y& O! H
- char msg[132];
: c7 U$ ~2 a9 Y0 ] - // get line information
+ n) \' n7 x# a" A L- N @ - UF_CURVE_line_t line_info;
6 B' z% \4 z: e - UF_CURVE_ask_line_data(line,&line_info);6 N( W/ X" N2 w5 h, J% ]; o
- sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0], P4 [( F& s- y$ W9 n8 F
- line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],
8 H0 @! K- f. T7 t3 y7 `( z4 X - line_info.end_point[2]);
: ]0 k; q7 ]0 r: X: V F4 F - UF_UI_write_listing_window(msg);
6 G" U6 E$ u M! H- `/ M - //get the point information
9 f+ }7 z( T$ c& d3 }: W: ^ - double point_info[3];6 b. U, u4 K5 i4 ?' l* ?3 i; Z
- UF_CURVE_ask_point_data(point,point_info);& a$ L/ R; E4 l
- sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);
- x$ u" Z! z2 x+ @+ P! a0 T" A( B - UF_UI_write_listing_window(msg);</p><p> //get the arc information Y# P' v+ g+ W3 |" |3 O
- UF_CURVE_arc_t arc_info;
+ L" B& h5 C9 Y! D. [4 W) v7 ]9 V - UF_CURVE_ask_arc_data(arc,&arc_info);
: q& n9 B6 I* } - 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;",
4 X8 e: G9 o* a n+ Y+ ` - arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],
5 \: ]' h- u( }: j+ ^4 [4 U - arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius( U3 N8 I+ j2 {; r- |
- );1 K$ _- k/ i4 e1 Q) `1 p5 z$ V1 `9 r" k
- UF_UI_write_listing_window(msg);
; p/ O7 [( n& ~$ F - // calculate the arc length
( o& f, U. [) w7 J - double arc_length;
) T2 |# V) U& f- z: P6 G2 h - UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);
4 \/ P5 Q" |9 ]$ r, O8 K, J - sprintf(msg,"\nArc Length:\n\t%lf",arc_length);1 v" z3 u3 S( z
- UF_UI_write_listing_window(msg);' K3 W: E: x# u
- }
! j9 s0 c: o5 u+ p - </p><p> </p>
复制代码
, B: t$ I$ e9 s8 e$ A* J( _% Y |
|