|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码
& ]% o1 R$ G7 C% q9 Q! c5 E+ ]. }; |' m
- <p>static void do_UGopenapi()$ f3 m: h% N' {& D- } e) Z+ S2 J
- {
. m* f; f0 u. |/ L2 i' E - /*9 z( J# r3 c$ a: a' u9 n
- Create Curve
& o/ \+ ]( y! Q* }/ U - *// i9 `, j P; |# d" d9 @
- // create line y# K; s/ {7 R+ l
- UF_CURVE_line_t line_coords;% }- N* ^( i* f$ O) I8 E! N8 }. h
- tag_t line;
( @+ M' [/ P' t( J - line_coords.start_point[0]=0;
# b3 n0 P1 }4 z. E3 p4 W - line_coords.start_point[1]=0;
( J9 L0 Q, a' P+ }: L/ B7 T9 _ - line_coords.start_point[2]=0;# D4 J9 ~& u/ T" G- _7 z6 t* _
- line_coords.end_point[0]=100;
$ v6 H. P& l) N! y - line_coords.end_point[1]=100;8 ]$ O# [- K/ r% j2 K1 n
- line_coords.end_point[2]=100;
2 D( |& q( X" x/ j7 u! ] - UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc/ P. e4 X' B J1 C! q6 f
- UF_CURVE_arc_t arc_coords;
6 p" _* v0 ?* @8 h* u% o" L" ] - tag_t arc,marix,wcs;! W: ^3 d# ^9 R; T
- UF_CSYS_ask_wcs(&wcs);
2 [# `. H; P' z/ r* t' }* t i6 f8 u5 [ - UF_CSYS_ask_matrix_of_object(wcs,&marix);, ^; ]2 h. B0 g! h7 g- b2 j
- arc_coords.arc_center[0]=0;" d0 I% _1 ^9 t; a, [: ]% S
- arc_coords.arc_center[1]=0;
" W1 u: d6 ?2 h) ?3 K. o: p9 Z! i( B - arc_coords.arc_center[2]=0;
7 k' d r: A. R+ E+ M" {; T7 d0 p0 R - arc_coords.start_angle=90*DEGRA;
( J; h# ~ [% J! w* j1 c7 U - arc_coords.end_angle=270*DEGRA;
; w( Q% s% ]. O ^ - arc_coords.radius=100;
d8 |. O0 J- I0 s9 A0 ~" x - arc_coords.matrix_tag=marix;
6 v* }: f, P- i& _6 B - UF_CURVE_create_arc(&arc_coords,&arc);5 a& L" r9 _+ ~2 @ r, H
- // create point
& f0 M7 N8 Y+ Z: S - double point_coords[3]={100,100,100};4 p9 v) \$ p! W
- tag_t point;, e! Z. E6 H. f7 r- O P* E
- UF_CURVE_create_point(point_coords,&point);* N L) i | d6 |- `8 G! k* g$ v
- 1 m: M# |* ?' `- y
- // create Plane8 ]8 x& ~6 W2 W9 W
- double origin_point[3]={100,100,100};
& W/ T' M' |$ T3 [- w% ~ - double plane_normal[3]={1,0,0};' D- K* j6 b: W9 T. I8 i6 x6 Q
- tag_t plane_tag; ) a) P5 r; l$ M, b
- UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*
- w# D4 q4 C: [/ b - Get the curve information
- J) e. u+ ]2 e" l - */
3 U! j3 T8 s$ |/ M* O, Z. P - UF_UI_open_listing_window();' g8 s! H+ u0 z' z( k
- char msg[132];
0 @$ Q9 N/ B* A8 N - // get line information
5 E2 n' ~ ?5 m' E& y& T; | - UF_CURVE_line_t line_info;
' C M- \4 w- v! J - UF_CURVE_ask_line_data(line,&line_info);3 y0 ^! C: b, [& t% Y, m
- sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0]," _. J9 C2 F5 X* c' \7 M$ ^
- line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],% V) G1 u7 e) }- \: v; S. }
- line_info.end_point[2]);
% c* D- ] g# ]8 H; B0 o - UF_UI_write_listing_window(msg);
" P! U& `# H4 Q' u" O- z9 {: H - //get the point information
/ T$ j" v( F1 \ `/ O! d - double point_info[3];' E! x& I* ?( J$ G- f) F" ?: ^
- UF_CURVE_ask_point_data(point,point_info);: b7 b# a5 ]# y1 h, P* ~5 V: D
- sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);2 L: }' |* E9 P! p
- UF_UI_write_listing_window(msg);</p><p> //get the arc information
5 B! I- g& I, A7 R6 ] - UF_CURVE_arc_t arc_info;% ?2 B: G6 z8 ?; u3 G
- UF_CURVE_ask_arc_data(arc,&arc_info);
" W+ J/ E; T7 L; C0 f1 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;",
! N# b% ~, _: I; [- b7 M - arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],5 q0 ?7 T) S6 ~* H: c h
- arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius" _) t" W! S0 J" W
- );
8 _! t# T+ \; _) i - UF_UI_write_listing_window(msg);
% T0 a/ y; K9 j2 S4 @" G& q - // calculate the arc length6 y1 ?) g- ]; n8 r( p$ M9 `
- double arc_length;
- ?: H8 s2 A: k- U) A& x - UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);
$ m. U: R% [# o - sprintf(msg,"\nArc Length:\n\t%lf",arc_length);# t" |. d, G) r6 `- H
- UF_UI_write_listing_window(msg);, _3 `4 }: d, ]7 `' b4 ^
- }& m0 I3 i) F4 ^+ k
- </p><p> </p>
复制代码 7 J5 c; r5 n2 I) q* b
|
|