|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码
4 U+ J& A) M1 X" F" C) J1 P3 ^: @1 B" S* r1 e$ {( |) d3 D* ^
- <p>static void do_UGopenapi()5 L! A8 R# {( N* y8 O
- {
3 Y5 \: U6 z0 U - /*
) [$ q0 C, U; b, i& ] - Create Curve( i( Y4 p0 ^# U4 ~* e3 i
- */9 y6 w' E' a% S; q2 W8 r2 Q
- // create line
, U6 R( i) ^3 b0 B: R - UF_CURVE_line_t line_coords;
& k ^4 K; W! H! k T& u - tag_t line;
/ |% a) @2 V# f# `; O6 u - line_coords.start_point[0]=0;' y+ b4 V2 H8 H- Y+ _, o5 r3 ~# P
- line_coords.start_point[1]=0;
5 k8 w2 Z" `; Q1 P# ^7 A: f4 l - line_coords.start_point[2]=0;% z5 U# A) u5 ~- Q7 [( C2 n+ ?( j
- line_coords.end_point[0]=100;
* Q- }. B9 y0 W - line_coords.end_point[1]=100;! Z9 g; F; T( s9 |2 o6 l
- line_coords.end_point[2]=100;
3 v' J$ D% z% {; p6 b: ]7 Q - UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc. U2 Y6 Z% c1 C
- UF_CURVE_arc_t arc_coords;6 L# g7 V4 q0 E
- tag_t arc,marix,wcs;
, V H$ d( Q% u7 M4 l1 P, H! z5 [ - UF_CSYS_ask_wcs(&wcs); _; q" S/ q$ x2 V' f
- UF_CSYS_ask_matrix_of_object(wcs,&marix);
3 Z5 U! p4 q9 m - arc_coords.arc_center[0]=0;% b2 u6 l0 |; T% b! Q
- arc_coords.arc_center[1]=0;
8 |7 Y) t6 x0 R( R: |5 D - arc_coords.arc_center[2]=0;
9 J$ C; @* c/ L$ Q* x6 h2 g - arc_coords.start_angle=90*DEGRA;2 u5 N+ P: Z2 S
- arc_coords.end_angle=270*DEGRA;+ I% c3 f6 D, t
- arc_coords.radius=100;
8 q( h: G3 J% \ - arc_coords.matrix_tag=marix;5 ^$ W+ i' T# a) Y/ ~
- UF_CURVE_create_arc(&arc_coords,&arc);
) u) C3 Q3 f2 U5 [ - // create point ' j' \# }+ J& v' w+ Q9 C' f' h( y
- double point_coords[3]={100,100,100};; W, ~! S$ w9 q8 @
- tag_t point;
2 }1 ?5 L6 s, Z/ P. N - UF_CURVE_create_point(point_coords,&point);7 h5 }$ z3 L2 z% H4 k
- - F8 c( C7 C7 T/ M+ N
- // create Plane# ~ j/ X/ Y( i, i
- double origin_point[3]={100,100,100};. C8 `; G) a) I3 @3 w
- double plane_normal[3]={1,0,0};& q s$ r7 c! K- o
- tag_t plane_tag; : `( x7 a0 `& Q5 M% ]) H- a9 t: O0 E6 i
- UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*
( |% @% `5 y7 [) F - Get the curve information" c- V+ I6 y! J) g
- */; a0 E1 s2 |3 N6 S4 r+ f3 E! ^* M
- UF_UI_open_listing_window();
- Y' K9 h9 x, x8 j H. u1 K - char msg[132];
& u; |4 [% E/ a+ |8 Y: c* s S - // get line information' E2 i* J5 c3 Y9 K
- UF_CURVE_line_t line_info;
( H% k$ {- r4 @ - UF_CURVE_ask_line_data(line,&line_info);- ~- O$ T4 L( ~ n' O! p
- sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],
( a" p8 Y9 ]: C. k j - line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],
# Y( Z- S, s' d - line_info.end_point[2]);/ X- ^0 e& }; C! a( |, E$ h
- UF_UI_write_listing_window(msg);! P3 ~3 I9 O6 D2 b6 U6 ]2 R
- //get the point information
; i" P9 o* b% d3 i+ |& f( \3 J r - double point_info[3];; t9 y$ s6 T; ^, A! m% J
- UF_CURVE_ask_point_data(point,point_info);# ?' D1 R( N3 z, S# s
- sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);% S+ R' Y' c( {1 g: L
- UF_UI_write_listing_window(msg);</p><p> //get the arc information
$ n9 S3 s/ N ?) A) | - UF_CURVE_arc_t arc_info;0 a8 |/ [3 e# w* D) a! C1 H
- UF_CURVE_ask_arc_data(arc,&arc_info);
7 o; u8 E) b! k* l& r - 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;",
" U! ]$ q; x& t8 @8 E5 T, e. K" s - arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],( c( a, c7 Q7 t6 }- ]* V
- arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius
, `8 Z3 q* ~! Z# T - );. @8 f7 Q7 Y1 t5 N% Y. A
- UF_UI_write_listing_window(msg);8 O! M' P' v& u2 Y( k, r: v- T
- // calculate the arc length
- ?" q' c% D' W% x) o - double arc_length;
/ d5 u6 O7 K4 B) ] - UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);
1 k) e' H0 m$ K$ o$ _, }4 P - sprintf(msg,"\nArc Length:\n\t%lf",arc_length);- m, L' d: {6 n4 M
- UF_UI_write_listing_window(msg);
7 k" ^1 E6 `" w4 E3 y: \ - }1 A! G! i6 m) |. ?: J% g
- </p><p> </p>
复制代码 % ~# ]: Y$ `4 p. W1 ^6 J: X8 J8 o
|
|