|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码
1 K6 N6 x# G/ r* I3 E, w" \
5 I' e0 D0 p, a- <p>static void do_UGopenapi()
$ j, n. o% i# b" P! x: c" l; o9 H, [ - {7 ?0 L; r% t' ^4 Q7 x/ I# u
- /*
1 n; [1 [' i, ^+ ^( J" O% h - Create Curve
$ o$ c s% s; k6 U4 G - */
4 k5 ^2 H0 |; M& a& d0 M - // create line
2 u' I1 s5 a8 M* d1 _& z3 u - UF_CURVE_line_t line_coords;5 Q: R( q0 p1 w2 L! s% V y$ X9 q
- tag_t line;0 D: h; O2 n3 G; y8 ?' s
- line_coords.start_point[0]=0;# j* i/ W! e$ z0 X- _
- line_coords.start_point[1]=0;, H! n4 U `4 e% k
- line_coords.start_point[2]=0;
" b5 v9 J6 E5 i" N5 g" [) R( | - line_coords.end_point[0]=100;3 F( a$ c4 q8 j1 p; Z7 X/ i) p
- line_coords.end_point[1]=100;
( \- j# r9 {, |$ {9 O: E, I - line_coords.end_point[2]=100;
8 K5 E' w8 K2 N) N3 J: ] - UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc
4 e% Z* H: K* G/ s& p - UF_CURVE_arc_t arc_coords;% Z s! s* z Z' L/ ?4 u7 |: ?
- tag_t arc,marix,wcs;
9 A- a! e; q# u" X( {7 T - UF_CSYS_ask_wcs(&wcs);
% |3 H3 o# D- P& h: i. ]# G - UF_CSYS_ask_matrix_of_object(wcs,&marix);
0 ~; G, L) F& h3 q W- A* }6 h - arc_coords.arc_center[0]=0;
+ _- n" r" x% v - arc_coords.arc_center[1]=0;
2 U2 H4 G! b% L9 z7 h! d J6 d, W - arc_coords.arc_center[2]=0;
6 Y% X3 V6 u4 x& _! K1 }& `. O u - arc_coords.start_angle=90*DEGRA;
" P' _: H3 {+ a7 r$ n, W# d) W - arc_coords.end_angle=270*DEGRA;
/ d4 Q- b p4 j- h+ Q* j- { - arc_coords.radius=100;( e) N/ u- m) }8 ~# D; [
- arc_coords.matrix_tag=marix;
+ L+ _4 P% R [8 v8 Q5 C K9 { - UF_CURVE_create_arc(&arc_coords,&arc);
% j" D6 R1 I; x: [& C - // create point
; Q+ G) f3 T- ~ - double point_coords[3]={100,100,100};- r- X& R$ M( x _1 [, I! S1 r
- tag_t point;" m8 Y1 t# H% Y' ~ S
- UF_CURVE_create_point(point_coords,&point);
, t1 M6 z! Z+ Z6 a -
1 i& N. n; d7 ^0 x - // create Plane F+ H; f# o; e" [
- double origin_point[3]={100,100,100};
8 a/ o# c1 W9 j4 ] - double plane_normal[3]={1,0,0};# t7 B7 s* y* ?4 O+ }4 g( S
- tag_t plane_tag;
* H! b% V, [4 j4 b6 A - UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*% o4 b$ G" P% q6 g1 Q- K0 {
- Get the curve information
( V7 I; D5 D' @% N - */( P" C/ d8 U$ J$ q& E
- UF_UI_open_listing_window();5 n$ b. _$ _5 H% [. _
- char msg[132];
' }: |& n7 U' [- D3 B - // get line information
6 w; I1 F. l, c8 l4 V - UF_CURVE_line_t line_info;
& Z: U# x4 ?, N- c - UF_CURVE_ask_line_data(line,&line_info);
) t1 u, d0 N0 |0 q - sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],
|5 B& }) v7 G# Z - line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],
5 A3 m* v, h1 y$ B; j- M; } - line_info.end_point[2]);
, P7 q4 T, v3 e8 p% O# d- ] - UF_UI_write_listing_window(msg);
- C$ ~" j3 R# q0 h) L. s! O% C - //get the point information
0 @5 C) d+ @8 C# O+ C - double point_info[3];
* _$ [1 ^" ^: H - UF_CURVE_ask_point_data(point,point_info);
% e4 S5 \; p/ I4 l" I& B8 O - sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);
; }9 Q$ l3 B7 Y) s) T - UF_UI_write_listing_window(msg);</p><p> //get the arc information
; J# @& s5 j. H* E - UF_CURVE_arc_t arc_info;
/ W4 G b$ V7 i, n- U - UF_CURVE_ask_arc_data(arc,&arc_info);
2 o2 w' z8 [- T: T t6 h - 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;",0 L' B$ S, h( P9 N
- arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],
" U( ?2 }+ K% H - arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius
) i6 f E5 N" Y5 C% S) r: s - );! W8 b& X7 z. c# Y d2 e& R. \8 u
- UF_UI_write_listing_window(msg);
( k+ B3 w3 H" X, E2 y: g - // calculate the arc length1 [' |* ?0 G; g) S" M7 K1 D) Z1 p
- double arc_length;
3 `& m( Y5 V" h3 r4 k7 c - UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);
4 ~6 |3 {1 {) Y9 r- ^, y0 m - sprintf(msg,"\nArc Length:\n\t%lf",arc_length);
* v E5 H- o' K) c9 O% o; j4 c - UF_UI_write_listing_window(msg);
" o7 C) U( Y6 g! N - }8 d9 w6 m: ^" H% F- L
- </p><p> </p>
复制代码 9 @+ I$ d7 V, o, B
|
|