|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码
& p3 \, c2 E; O& X4 e* o5 q; N, {' x8 T% i% w
- <p>static void do_UGopenapi()2 c& z- ~+ E% q, c: H5 z' s
- {% Y1 w! A* M* C
- /*
1 j8 W" ^4 E9 X) [7 j% z' i - Create Curve. [, O, X3 D/ U% S* \5 ?* I
- */5 u: e: W0 A2 t+ u- d- w
- // create line% i, @/ m" u2 m1 L! [. r- o# j- \6 W& }
- UF_CURVE_line_t line_coords;. h: Z) J; W) R7 e4 g
- tag_t line;$ s/ m3 W2 _( z9 j0 D: L
- line_coords.start_point[0]=0;
: ?/ t" i/ W+ @( m! Q" G8 n( A - line_coords.start_point[1]=0;4 `9 j" a0 i! V8 O
- line_coords.start_point[2]=0;9 W. ]/ j4 x9 ?2 g
- line_coords.end_point[0]=100;
$ G3 `+ g3 |' D; y I* k% `3 D - line_coords.end_point[1]=100;/ f# J3 y; Y$ \( U5 f2 k
- line_coords.end_point[2]=100;. L5 c/ ~5 x9 g8 R8 A, l
- UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc' R% z3 ]% f4 b \. y1 O2 q9 q4 A
- UF_CURVE_arc_t arc_coords;3 J$ V9 z) N+ r1 B3 h1 ~
- tag_t arc,marix,wcs;: T0 N( w0 M1 {. E1 w* [. p: K
- UF_CSYS_ask_wcs(&wcs); E# R9 L% p' R4 [* ?+ G) _
- UF_CSYS_ask_matrix_of_object(wcs,&marix);
! ?7 P# e4 X- G# c- w - arc_coords.arc_center[0]=0;7 J$ ]8 e7 k; O7 [5 u$ x1 I2 e
- arc_coords.arc_center[1]=0;
" v, H) j+ R' S - arc_coords.arc_center[2]=0;% _1 D* ~; a+ s G0 C4 E. F: Q- r7 T
- arc_coords.start_angle=90*DEGRA;) H& e6 h+ d! a) ]) r
- arc_coords.end_angle=270*DEGRA;3 R) w) _/ S- D! h
- arc_coords.radius=100;
& |/ g5 u5 v# g- _2 @! X& K - arc_coords.matrix_tag=marix;- d& _+ c, z! \/ K2 @6 t
- UF_CURVE_create_arc(&arc_coords,&arc);
) h8 a h3 g1 m# h; v - // create point ( y$ k2 M9 P; H
- double point_coords[3]={100,100,100};: k1 ?9 I; F; L: ?( @8 O
- tag_t point;7 ~; Y& k2 r6 ?( B9 u8 ?4 o
- UF_CURVE_create_point(point_coords,&point);* f" P- M* [( L) k7 C9 Z g
- ' P! @6 B; i; f6 O+ d
- // create Plane
+ d* G5 A C2 b - double origin_point[3]={100,100,100};
- x4 ]! g4 C6 N" p+ @* I - double plane_normal[3]={1,0,0};1 I% j7 h! m6 H& s j; h9 w" a
- tag_t plane_tag;
: _9 J5 j2 m1 w5 T. N - UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*
, {, o$ g: N6 t/ ~' _ - Get the curve information! w3 Y0 T- b9 x P( q
- */, ^ J3 \) o# y
- UF_UI_open_listing_window();! b/ l7 r: e: R+ r' y0 X
- char msg[132];4 e! b& w/ \3 y1 e
- // get line information( [( C: b s& Y9 v7 O9 X3 c
- UF_CURVE_line_t line_info;
, |7 ~ u) Q2 g. ` - UF_CURVE_ask_line_data(line,&line_info);
0 _+ J+ k/ t7 O7 d - sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],
. _. X' c) z- t! a$ v$ E `" b; K - line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],
5 T7 n3 C/ G4 A( }, i/ W- B - line_info.end_point[2]);
/ m! l. k7 ~9 |. z8 V& y' j - UF_UI_write_listing_window(msg);
, F( y$ B6 ?8 V - //get the point information9 y( I' G( H9 o) J/ W! M
- double point_info[3];
, }% C: a1 \/ [ E6 X - UF_CURVE_ask_point_data(point,point_info);
: u: \: }5 e- i- S - sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);
: K# \! J" z" f8 r) M - UF_UI_write_listing_window(msg);</p><p> //get the arc information, R8 {) l7 ], m2 p
- UF_CURVE_arc_t arc_info;% o5 ~* M1 S3 y3 J4 u
- UF_CURVE_ask_arc_data(arc,&arc_info);
' v' Y6 P, l4 {% O, v% 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;",4 Y6 b% K B; i( O6 ?! R
- arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],
y( [ D& R8 X' r# i# { - arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius5 h0 F$ m$ d/ {8 ?+ H) O
- );5 Z: K! {; O9 k1 ^) {/ c
- UF_UI_write_listing_window(msg);
% E7 v* n$ Y T6 P1 @5 E - // calculate the arc length9 ]) q& q1 n0 Q& v
- double arc_length;
& S/ K% n1 {8 { t' s8 }+ W, i# I - UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);, {6 N7 ?* |# X2 E
- sprintf(msg,"\nArc Length:\n\t%lf",arc_length);
) q' e+ c8 }" ?5 F - UF_UI_write_listing_window(msg);
+ `6 H0 _. K/ v3 G - }
" m9 z8 e( s; i4 N) q" A - </p><p> </p>
复制代码
' d$ @9 v) b2 K |
|