|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码
& n f6 f1 r+ u% h6 o4 Y; h
6 F0 b; k- Z( O$ w% |- <p>static void do_UGopenapi()% s- g: F& d9 n7 ]; C5 I( N
- {" g% z' i. U3 O- [6 i
- /*
" W2 z5 q7 O g6 V3 b8 n' x8 ` - Create Curve
% Q1 B0 W& p5 y6 O7 I. k - */4 m# K7 L$ S# q" l1 L
- // create line0 g3 _* E, v! E1 ]' F$ t: T6 o! C7 [6 |
- UF_CURVE_line_t line_coords;3 N D" E# a" c/ n& q
- tag_t line;
^1 v2 N2 D* L/ Z- } - line_coords.start_point[0]=0;
# K1 g; ]1 L) o$ |' v- b# Z - line_coords.start_point[1]=0;
% B# X' e+ ?8 |: X5 q - line_coords.start_point[2]=0;
7 d8 ?+ _8 h' ~8 p7 X/ @" h$ _ - line_coords.end_point[0]=100;
: [+ S8 ?: w* j - line_coords.end_point[1]=100;
3 |% \ j8 [7 j& @2 ^7 U - line_coords.end_point[2]=100;
" s( [! z' n$ V; H/ h# j( T - UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc* b" h" L. s' k) F ]6 Q; a
- UF_CURVE_arc_t arc_coords;
+ L: C# M, J; L$ X; \# e1 W - tag_t arc,marix,wcs;
' S/ U6 L r0 r' F/ V - UF_CSYS_ask_wcs(&wcs);# V+ d% \/ m7 h% P' l6 e! ~
- UF_CSYS_ask_matrix_of_object(wcs,&marix);
. H# H* }9 P; N v9 u F - arc_coords.arc_center[0]=0;
! \ g2 A0 f. j+ |% k. k - arc_coords.arc_center[1]=0;5 u# o" U( O+ }4 g% m2 L0 y5 X: \
- arc_coords.arc_center[2]=0;
. q& B1 g* R, F" y7 Q - arc_coords.start_angle=90*DEGRA;4 M5 L/ n- i) e, y
- arc_coords.end_angle=270*DEGRA;8 L, F3 d8 _# F& [0 \. A3 v: u
- arc_coords.radius=100;: k g o, c( M( j1 ]1 x2 c, O/ v. C
- arc_coords.matrix_tag=marix;$ w0 o% w& S% ]
- UF_CURVE_create_arc(&arc_coords,&arc);
9 p4 L+ v8 Y! M, m4 W - // create point
: P; [4 u5 f, L; y3 T - double point_coords[3]={100,100,100};
6 b/ Q9 |0 w; }' c - tag_t point;3 ]; n: n! B3 W9 i; X
- UF_CURVE_create_point(point_coords,&point);4 Z5 ^/ Q# Y* s: i* K
-
- \/ n4 |* x% B5 ` - // create Plane
' a0 G- n# R. r! q& ~9 ?! T - double origin_point[3]={100,100,100};4 ~/ z" l7 M7 p( ^" w! s
- double plane_normal[3]={1,0,0};
" c6 U. N4 `5 d; m$ a - tag_t plane_tag; 6 n: b$ k B. G. i
- UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*# P$ s2 s Q1 l' L0 }+ y+ `2 @* ], Q7 [
- Get the curve information
0 {: m8 I+ c7 c+ p3 R" o: j - */) B: K; |. M, Z9 v
- UF_UI_open_listing_window();
* L3 U- r+ k1 o7 z - char msg[132];, x8 K& E- ]" G8 F4 B a( n
- // get line information- `7 c6 _* w- O' T% ~* n, V5 a1 F, j" Y
- UF_CURVE_line_t line_info;$ d8 |/ Y7 w! e
- UF_CURVE_ask_line_data(line,&line_info);
4 Y: V+ z# r% a" Z5 X% k - sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],
. a7 }% d: _+ _& I" b' m' D1 K5 Y - line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],
% h8 p5 B' M" d! k - line_info.end_point[2]);
6 Q$ E( Q( s o6 Y- p! n - UF_UI_write_listing_window(msg);- Z! n+ W) l7 s5 M
- //get the point information+ d8 C$ h1 S! h- M0 K# @" p8 s
- double point_info[3];
! N2 A3 f% j8 ^1 l5 C' P - UF_CURVE_ask_point_data(point,point_info);
- A1 m, b2 M- s4 h - sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);
! ?6 k6 i, D G0 B - UF_UI_write_listing_window(msg);</p><p> //get the arc information m8 z' @% p1 B$ v% q) m
- UF_CURVE_arc_t arc_info;7 y5 j; K! `; u4 F& F% S" X
- UF_CURVE_ask_arc_data(arc,&arc_info);0 o9 J8 K! G7 z) S' c/ X( 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;",% W- O# J* ^, V$ y* e+ o
- arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],
7 y2 T x9 |% x2 c& R% ] - arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius
0 g7 ?2 N# |) T) a7 z! M - );" h) U! E2 F$ j* h
- UF_UI_write_listing_window(msg);, E0 H# O" e; s+ i. {
- // calculate the arc length
' ]( W! ~1 H9 _ - double arc_length;% x" O" D5 d7 z; \) l+ [. W
- UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);% g% J) b( [% y6 p2 J3 h
- sprintf(msg,"\nArc Length:\n\t%lf",arc_length);
& p9 _8 q' R$ I7 o! d - UF_UI_write_listing_window(msg);
1 o6 G: f! j: _! H+ e% i. u - }
, N3 P# `+ V6 i8 g ^: l1 x - </p><p> </p>
复制代码 0 z0 Y/ A8 N y& y+ ~$ n) f
|
|