|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码
3 n, P, N9 k( [5 k9 A$ L0 }8 N4 e9 a8 x
- <p>static void do_UGopenapi()
2 c: L1 a9 G7 d3 D9 y0 o+ R - {# h3 i/ Q$ R7 p; _ d
- /*1 S* w2 Q; O3 y, C
- Create Curve
8 ]: _% d+ w" k: b+ E9 Z6 U: W - */
% w' V. N3 n! ^* Z2 n2 n* W/ @6 v - // create line, P" p) |% o; w4 k% ]8 i
- UF_CURVE_line_t line_coords;
, L. O/ U; ^& E- M1 U9 C - tag_t line;
: ^ L1 `# t' R, G - line_coords.start_point[0]=0;3 |0 |; M- m i: ?
- line_coords.start_point[1]=0;
4 n3 m/ c5 J0 B" T0 f6 F% D( k2 ` - line_coords.start_point[2]=0;3 K4 K( y9 P! e6 M, q
- line_coords.end_point[0]=100;
' ^: _6 I7 `# M+ A. Z - line_coords.end_point[1]=100;
G& i( X* X7 k7 |% u3 g/ ? - line_coords.end_point[2]=100;" {/ E: e5 W J8 N# d
- UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc8 O0 @+ e5 ~/ {7 d6 H
- UF_CURVE_arc_t arc_coords;
, `. C( l2 R* M: ?2 G0 w% T- ? - tag_t arc,marix,wcs;
+ I1 S# X/ | `' T! S- J - UF_CSYS_ask_wcs(&wcs);
6 m$ B( S! z3 w$ K! C& h - UF_CSYS_ask_matrix_of_object(wcs,&marix);
/ _ x" o W) x: B - arc_coords.arc_center[0]=0;
( M& }% L# H1 v9 D9 S! ` - arc_coords.arc_center[1]=0;
" Z5 u w$ w# E4 {8 [ - arc_coords.arc_center[2]=0;; ]0 S, G# F. [& c* b3 u1 O6 P
- arc_coords.start_angle=90*DEGRA;( Y/ f! M9 |, G" y
- arc_coords.end_angle=270*DEGRA;8 W" b M# s* j: |+ H8 f+ |/ V; H
- arc_coords.radius=100;
6 n( e+ o" V) ]3 i6 }8 e) _ - arc_coords.matrix_tag=marix;8 K! J6 D z! L; T8 C$ T* E
- UF_CURVE_create_arc(&arc_coords,&arc);
6 D" Z5 ^. R7 R. P1 x3 ? - // create point
; s& E9 x7 |9 ~8 e& m) z$ n( n - double point_coords[3]={100,100,100};
3 ]6 T4 J1 l7 }9 \7 j - tag_t point;. B0 o$ o$ O, {6 A$ M3 ]0 c' U
- UF_CURVE_create_point(point_coords,&point);9 [& ?: H& H+ h+ i
- # t% Z/ h# x: B. z: d" ~
- // create Plane
" L. H. |9 q! G9 q - double origin_point[3]={100,100,100};, C; e6 ?5 K' q
- double plane_normal[3]={1,0,0};4 |* D' b1 X: z0 p6 ^4 r" n* Z2 L3 N
- tag_t plane_tag;
( c' b B5 Z- |3 S* z - UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*
! R, Q8 Y4 \! I) i( d8 s% L% v - Get the curve information
! q4 e* o' `2 t1 N s - */3 G' [, q$ F$ V8 j8 J0 M& K( W- P
- UF_UI_open_listing_window();
6 \ S- S5 [# m$ m7 g - char msg[132];% e5 c! Q0 D1 K% x: i
- // get line information: ^ X* ^; |$ [1 Y
- UF_CURVE_line_t line_info;. Z% T0 a" x; |5 ]/ m% t
- UF_CURVE_ask_line_data(line,&line_info);
) B2 [( i0 ]- j - sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],) \7 `" }+ C0 l" _
- line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],) {* u+ a( `$ M q; m
- line_info.end_point[2]);1 j6 A0 q. [ S( N
- UF_UI_write_listing_window(msg);. C d2 K- C F2 h
- //get the point information
" F( B2 p8 u2 W; C, l9 U" ?1 b) G - double point_info[3];0 Y9 U% R1 l/ L4 }2 o% ]+ k
- UF_CURVE_ask_point_data(point,point_info);- r+ G4 e; |' i/ z# V
- sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);
7 I8 Z* ^! ?: |" z - UF_UI_write_listing_window(msg);</p><p> //get the arc information6 T; ?/ g& `0 x" G8 z( j i
- UF_CURVE_arc_t arc_info;
( ~! H8 `+ x7 {* K9 j3 A: R - UF_CURVE_ask_arc_data(arc,&arc_info);
/ `; K3 L1 @! q4 i+ L- @ - 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;",
* y: l% y! B6 W, U - arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],
& X7 W2 e. G# u; ?( N4 k - arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius# ?" \1 ?( i- R9 a. Y- i0 u
- );! j! i! W+ w& Q2 |
- UF_UI_write_listing_window(msg);. ?& \3 E& k# P& t d8 X1 \$ L
- // calculate the arc length
: x' G1 O& }. Q' F- U - double arc_length; Z' w9 T6 B# _) z. I0 U j
- UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);6 L9 y' m- ?( r- ~# o" x4 r
- sprintf(msg,"\nArc Length:\n\t%lf",arc_length);
; q0 P3 g$ I# t4 c5 {+ y - UF_UI_write_listing_window(msg);, g* X: e* a7 `2 Q4 _( n0 ]- g
- }0 g) h$ w5 S9 J' _7 Q
- </p><p> </p>
复制代码 4 P2 ]6 z) G3 o% E) ]- G1 g
|
|