|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码3 T6 R* C% m1 z7 b# i; T
4 P! Z: n2 A' L1 X5 A- <p>static void do_UGopenapi()6 I- y1 i3 v3 B/ A# i) I. \
- {
) T0 q. K% k9 U4 {! ]8 ] - /*& a/ L# C$ Q3 R
- Create Curve8 N) V% q. y1 m/ K: h
- */
2 P' n7 D+ t* u/ C+ n - // create line
' A! J; x- R# R: b. |3 j1 h8 ^ - UF_CURVE_line_t line_coords;2 r9 t/ w( X0 G8 u) F
- tag_t line;
8 g5 w$ \( O% C1 G1 }0 T+ B- I - line_coords.start_point[0]=0;
1 W- W; N% p6 V9 H - line_coords.start_point[1]=0;
1 q/ r: q& [1 q0 `- T2 j" i - line_coords.start_point[2]=0;. P- ?9 U6 I$ s; r% R" u
- line_coords.end_point[0]=100;6 Q2 U w$ D( \! _9 [/ D; c" s9 v, d
- line_coords.end_point[1]=100;
* T- Y$ B9 k" D, l% c, T - line_coords.end_point[2]=100;' A7 W7 M3 {# ~
- UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc
# O+ t S4 q8 A3 c - UF_CURVE_arc_t arc_coords;
9 T8 n3 ]( ?9 F% r - tag_t arc,marix,wcs;+ _/ s" y( f7 d" f8 \! v k
- UF_CSYS_ask_wcs(&wcs); n6 J8 B! T# u4 |/ M
- UF_CSYS_ask_matrix_of_object(wcs,&marix);7 j. r0 c% Z4 A0 x
- arc_coords.arc_center[0]=0;
! y. Q5 i% e! Z4 x& o - arc_coords.arc_center[1]=0;
8 R/ E' F- h3 @: t% C- ~ - arc_coords.arc_center[2]=0;
: m7 }- q% w0 ~5 R ~6 ^1 u - arc_coords.start_angle=90*DEGRA;6 o7 d1 S7 z5 y
- arc_coords.end_angle=270*DEGRA;
- ^% w) U, V4 A2 T5 l - arc_coords.radius=100;
, r/ v. O7 f: ~ a# K% A) ~' x: ? - arc_coords.matrix_tag=marix;
; }0 T& t2 U. Y! S$ | - UF_CURVE_create_arc(&arc_coords,&arc);
' d- K0 h! M* |# m) V - // create point 2 M/ }! }1 ~1 g0 [0 c4 m
- double point_coords[3]={100,100,100};
, v" L; E8 x9 P7 U - tag_t point;
! E# x3 j3 z3 n$ k - UF_CURVE_create_point(point_coords,&point);) A1 i* i- d9 e8 U$ f. y2 f- [6 F
- ' x* e$ ~0 N$ ~
- // create Plane
+ h4 C% [0 m% D3 f% ^) J* o - double origin_point[3]={100,100,100};
1 B) T& ^# D. J6 c( _! C& Z - double plane_normal[3]={1,0,0};
' @) G# |, q* F6 K - tag_t plane_tag;
6 Z4 J l. V7 Y7 g, f( J - UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*
L! i Y6 l( d3 H3 ?( O/ n - Get the curve information
. p9 g: a6 k1 @" ` - */
1 W( n- R! b( J; V$ g0 z - UF_UI_open_listing_window();
4 v; L, v: }! u3 @0 @ - char msg[132];
5 B$ K% J6 {5 O; j' g, J - // get line information
, Q* p4 _* D: A4 w1 b- ` - UF_CURVE_line_t line_info;( q" q) V+ P& ~5 v f2 e9 {
- UF_CURVE_ask_line_data(line,&line_info);* t4 e3 ^# N7 ^% s$ T% r8 F+ g( O
- sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],
9 N& |$ D. N, X2 b4 u4 y - line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],
+ V. N. [# Z0 O3 u - line_info.end_point[2]);, G1 [, D" [: g" Y
- UF_UI_write_listing_window(msg);
5 N1 I% {8 P- s' y& C3 Z - //get the point information
3 b- u+ H# U' g+ w& q& S - double point_info[3];
+ o3 p* a& N) [" ~7 M- E, W/ j x. t - UF_CURVE_ask_point_data(point,point_info);. ?* k4 b' b. m6 A
- sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);
& o; S6 d, g( l8 X, w5 X" g - UF_UI_write_listing_window(msg);</p><p> //get the arc information* J2 F/ c. B! f8 b. e
- UF_CURVE_arc_t arc_info;
3 @; K" W2 ^9 e - UF_CURVE_ask_arc_data(arc,&arc_info); R! H" z5 N' A: a3 N8 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;",. ~( e* h: Q X
- arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],
% T: L+ f/ @% b/ U - arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius
: V8 f( R v! \# Y - );2 p+ _" W3 H: y' [, O2 J
- UF_UI_write_listing_window(msg);; S7 ?; |* P# [( F* b9 G- v
- // calculate the arc length- _" c/ O6 ?/ `. T" n
- double arc_length;
( R; ]8 m; \" U- z i - UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);
+ q3 l( B k0 {/ N5 N - sprintf(msg,"\nArc Length:\n\t%lf",arc_length);! S; ?! ^; t3 `. O+ A G
- UF_UI_write_listing_window(msg);; ]' i4 R. U. U/ O* w3 ?
- }
: L" n: K# ^9 T' p7 G" N1 ~* _ - </p><p> </p>
复制代码 8 c" P1 q$ x9 A5 I" v: Z A4 \
|
|