|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码
( w6 X- \' C* B& [0 K( \. t# w# g" w' h# s M
- <p>static void do_UGopenapi()6 l3 q/ ?" P8 p' N2 h4 Q" v' D% q
- {, s: o- g/ O, m' @7 R L$ C) H$ z
- /*
( {2 B1 C+ e% i! W3 C4 R* I - Create Curve7 p' r& _3 a2 ^, F7 l" _
- */- V% z* j4 ]2 U/ ~* t
- // create line Z+ Z }- w8 F2 f# Q$ S: y1 W
- UF_CURVE_line_t line_coords;
& C1 Q# C6 j* Z* W1 k2 A - tag_t line;' ^" r+ v& e4 c4 t! S% D
- line_coords.start_point[0]=0;
% v( j/ m/ i/ t0 \0 n - line_coords.start_point[1]=0;
) m& ?. X: E( N' U+ s; D - line_coords.start_point[2]=0;
6 m1 F! F l2 D9 J' c. K - line_coords.end_point[0]=100;
" u4 B3 \. V( v) E3 l5 X- N3 s - line_coords.end_point[1]=100;5 Q/ a; ]# B! U9 z- G0 m
- line_coords.end_point[2]=100;
% {$ X0 x: I0 H: W4 B& m, N - UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc
6 G: a1 w$ b% V& z" K7 D - UF_CURVE_arc_t arc_coords;! K1 p( y. c' u* d! M
- tag_t arc,marix,wcs;- m* m T" I$ M( `0 ^) i* Y
- UF_CSYS_ask_wcs(&wcs);& X( Z0 |. K" ?9 s# {# }! E( ^# _0 W
- UF_CSYS_ask_matrix_of_object(wcs,&marix);9 ]; J1 o3 J) u) S
- arc_coords.arc_center[0]=0;
, {$ u3 T7 \- c% I. ^- A8 _/ [ - arc_coords.arc_center[1]=0;" x. W; `& @$ X& ?5 F" ]! X
- arc_coords.arc_center[2]=0;
$ {! y: }# i/ r/ I3 a - arc_coords.start_angle=90*DEGRA;
{2 p& X% Q" `7 ] e W - arc_coords.end_angle=270*DEGRA;
6 N. n2 m& {6 {- J' P - arc_coords.radius=100;! }+ p% x+ D6 K6 h2 Z0 ^. L1 E
- arc_coords.matrix_tag=marix;- z: h- U! u4 |) R
- UF_CURVE_create_arc(&arc_coords,&arc);
" k; H( k, Y d7 J: U - // create point
+ m% r1 v0 I2 L' i - double point_coords[3]={100,100,100};
& K) \0 @# O& S: W2 K, x2 c - tag_t point;" w! H, s/ r% k( x6 [6 ?
- UF_CURVE_create_point(point_coords,&point);* N0 U( Q2 a3 O/ n G! N6 O
-
4 q/ F7 m, e" o3 k) i2 [( r' W7 u - // create Plane$ M; T7 B6 v8 q S, }6 r
- double origin_point[3]={100,100,100};# X1 s: ^$ q, Q; ~2 W- i- i& q
- double plane_normal[3]={1,0,0};
. T; e! H4 M, e( Q0 D4 U - tag_t plane_tag; 7 h8 @. z7 ?; a' _1 U6 o1 P+ V; e
- UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*
2 z" n8 O6 R1 K' a$ R: s - Get the curve information0 R- z3 H8 e$ r- p5 {, {
- *// j$ \$ K* V& \+ ^: W# U! d
- UF_UI_open_listing_window();
; d! ^" x' [6 O6 }9 _: o - char msg[132];3 V. V7 ~8 r2 C( g6 ]+ {
- // get line information
! n) C+ [2 `. l7 v/ x0 K; m5 U) ]) L - UF_CURVE_line_t line_info;8 s# v7 X* M- c4 b" d) a
- UF_CURVE_ask_line_data(line,&line_info);
; V9 c& u3 E: Y+ y - sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],
! O! _) K& a$ @' Y0 {3 k - line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],
; F( K0 U2 x* o$ u - line_info.end_point[2]); ?8 |" [2 Y) L k# b: |
- UF_UI_write_listing_window(msg);
, R# R# M3 W0 }2 R% t - //get the point information
9 N0 i& n; J6 e* U6 j - double point_info[3];
6 _% @5 b$ K( i4 ]8 u - UF_CURVE_ask_point_data(point,point_info);
1 P+ R# U1 h! O. R! }* y7 N+ A - sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);; R9 B0 n5 w" L/ B) x" C
- UF_UI_write_listing_window(msg);</p><p> //get the arc information
; B3 Y) \ Y# k- p - UF_CURVE_arc_t arc_info;
. G6 S- x0 Q% O; B% z - UF_CURVE_ask_arc_data(arc,&arc_info);
# O, P: {$ M" n - 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;",
: }/ m' ]4 a$ O6 ?( B: V$ c7 w - arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],9 [! a2 c; ^: F) `: P
- arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius- P, h5 x# s4 d4 L% V! V/ d: c y; L
- );9 R7 r; n+ ^ \: c4 z3 p
- UF_UI_write_listing_window(msg);
]+ a5 H$ p4 t$ z* X: q - // calculate the arc length
: M7 ]6 R$ m5 c W1 b - double arc_length;# M9 ~/ Q% r8 t* X1 n
- UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);
( X3 {* \. w9 [3 G - sprintf(msg,"\nArc Length:\n\t%lf",arc_length);: ]1 V% c' x. A. ?1 Z2 i
- UF_UI_write_listing_window(msg);5 G5 D/ q" B& v! j
- }, F- G" W3 {5 _' g
- </p><p> </p>
复制代码
( B5 ^$ K9 @; K |
|