|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码
. R# o! n, `8 V2 K
9 L" ]2 f/ J# k; E- <p>static void do_UGopenapi()
5 [( ~2 S; T% A" m - {4 S0 I6 E4 T6 \: q5 N1 f& X
- /*
2 ?( a8 A' O |# I5 ~0 \* g - Create Curve0 O- a2 [! I1 j: m0 `, m( i
- */$ Q* ]2 p9 S+ N- A) _, m
- // create line
2 N: ^' {# B/ f8 G - UF_CURVE_line_t line_coords;2 C0 W/ U$ b: e2 ]2 f- |1 T( P
- tag_t line;7 r* X9 N, G' W; {( _5 R% H$ r9 q
- line_coords.start_point[0]=0;# _8 R' `6 ?7 g/ J3 I: p
- line_coords.start_point[1]=0;
2 a0 _4 v' y9 D! M' F2 J - line_coords.start_point[2]=0;" c+ ^" `$ n8 J/ e
- line_coords.end_point[0]=100;
5 K& _, O8 S* V1 q2 t2 z3 R: a - line_coords.end_point[1]=100;2 ^$ W+ F9 ]' }* ` ]
- line_coords.end_point[2]=100;2 a- \' M& z. S' P. W
- UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc- w+ [) x' p+ G! v
- UF_CURVE_arc_t arc_coords;
( {! ]: y q) T# i5 I- X6 a. Z8 [ - tag_t arc,marix,wcs;
# s& o9 l, `6 C! W3 P+ m - UF_CSYS_ask_wcs(&wcs);0 K( m8 |3 U3 q3 U
- UF_CSYS_ask_matrix_of_object(wcs,&marix);1 E2 J- Z% q! Z& [" Z9 x
- arc_coords.arc_center[0]=0;
% N6 i. \( t4 ]7 r& `- N( N8 c' G - arc_coords.arc_center[1]=0;
( w* M& d; }9 t+ V+ a' H, B* | ^ - arc_coords.arc_center[2]=0;
# e2 N) {9 l% P0 H$ J& Y- c( B) _ - arc_coords.start_angle=90*DEGRA;
2 ]9 V; ~4 k$ D4 z/ k, ?! { - arc_coords.end_angle=270*DEGRA;
' J/ e( z6 t4 t; Y - arc_coords.radius=100;
x' P9 }/ |" r+ T) c/ Z N& l - arc_coords.matrix_tag=marix;
+ D9 d# o K3 j. ?, K - UF_CURVE_create_arc(&arc_coords,&arc);# J2 U5 U. y* g) x- f
- // create point
~) ^1 C1 A5 c/ c3 S' U9 @ - double point_coords[3]={100,100,100};* c; E! v; t- k, u$ X
- tag_t point;
9 B) Q' z. o _: C! w( d - UF_CURVE_create_point(point_coords,&point);
( p% [0 d( L, C0 r3 X -
& A. R8 T) S: f2 O/ n4 e0 [ - // create Plane
* ]% a( j7 Z' \5 Y+ N - double origin_point[3]={100,100,100};$ W. i9 f5 m, G
- double plane_normal[3]={1,0,0};) o$ P, O- c& ?1 j- i
- tag_t plane_tag; 7 i* w2 \6 D5 y# q
- UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*
9 o# ?: I* K7 H9 I( L) ?+ | - Get the curve information
: t2 P2 j0 C$ l- o% [ - */
7 G r2 o* Y7 @2 p - UF_UI_open_listing_window();
4 y f# m7 |& J. }% v4 o3 j - char msg[132];
% Q7 H# G: x- {% O( r7 x% ^ - // get line information4 K1 _9 i: A( r8 R2 T- C3 O7 W
- UF_CURVE_line_t line_info;
7 g$ ?! l) l7 ^& B8 z# J, v - UF_CURVE_ask_line_data(line,&line_info);2 A# _, \0 j7 [; D) P- |9 {
- sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],
/ M8 T E& M5 K; y - line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],% }' ^9 \( F: T( \7 s8 f/ h
- line_info.end_point[2]);
8 `# l* Q! {$ V7 \! b5 e - UF_UI_write_listing_window(msg);: ^- y' N& Z0 y7 L5 q) c
- //get the point information
3 ^6 _* k# E# w' k - double point_info[3];6 [' i2 G0 D4 j5 s8 ?! r" i
- UF_CURVE_ask_point_data(point,point_info);
' A! i ?' a; z7 q* b1 U$ M - sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);
6 X" [1 Q4 }- U" V( B6 f. ^) a9 h - UF_UI_write_listing_window(msg);</p><p> //get the arc information" G/ m' p' i! n/ h; z4 `( u
- UF_CURVE_arc_t arc_info;+ y. i7 [+ G) S- `& v4 V# ?
- UF_CURVE_ask_arc_data(arc,&arc_info);2 F, F3 ^/ j7 `' A$ 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;",) i* F9 b X3 A/ O
- arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],
3 m: s: L. O) V( B - arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius
$ s+ R( D8 Z5 V6 `+ A - );
2 K, W/ J7 u- R( \+ b - UF_UI_write_listing_window(msg);( o9 Z7 }+ C. c8 D* Y
- // calculate the arc length( j' `" T0 q4 H" ^* [$ S5 R
- double arc_length;; j( ?4 I0 A' f4 M* }
- UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);. R% ~4 o4 ]1 L( ?" |
- sprintf(msg,"\nArc Length:\n\t%lf",arc_length);
% |4 _ c; R! y% |/ ?! e1 T" ^* F% _7 p - UF_UI_write_listing_window(msg);
- C% T8 v6 F6 S9 d- o& R, z - }
6 I; ?8 s/ y( D - </p><p> </p>
复制代码
4 k" k1 v* y1 |% h |
|