|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码
7 L- F; Z" g2 H; o8 ^( v% [
, u$ x& B: ?8 X2 D; b- <p>static void do_UGopenapi(). u9 [$ o5 b. r2 u
- {
f, z5 H+ v3 j - /*
+ I+ N+ W! c8 l: @7 C - Create Curve
2 [& y+ n5 T' P+ w. ]0 Z - */
% B1 |$ a5 s6 Z8 ~ - // create line9 \# [3 V' P: }! V- r5 U6 Q
- UF_CURVE_line_t line_coords;9 U# Q% n" q' y9 z
- tag_t line;
3 w* }4 c' U7 T: N# t* m% p! T* ? - line_coords.start_point[0]=0; M8 e1 Q+ N2 L
- line_coords.start_point[1]=0;
6 M/ E# o! r4 U$ _8 J' R - line_coords.start_point[2]=0;
. x; \/ y h$ K$ Z+ p" e( H7 k/ c - line_coords.end_point[0]=100;
) M5 s# g8 ?7 Q9 j% U5 z - line_coords.end_point[1]=100;
+ @6 \. W; n7 ^' ] - line_coords.end_point[2]=100;* I3 Z% V5 G9 I* L8 m5 y! _
- UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc/ f- I$ ]/ ^4 J
- UF_CURVE_arc_t arc_coords;
* T' h1 ^1 P5 W' ~/ f7 m q - tag_t arc,marix,wcs;1 Z4 ]2 r; p+ w! B+ g1 @3 ~
- UF_CSYS_ask_wcs(&wcs);) W" J/ n7 J# R& p
- UF_CSYS_ask_matrix_of_object(wcs,&marix);
2 |" j3 v% q1 v U# y9 C1 m% r - arc_coords.arc_center[0]=0;1 z8 d: T* G1 @
- arc_coords.arc_center[1]=0;6 k+ J5 e; d; m. f0 v& C: r5 k
- arc_coords.arc_center[2]=0;0 X, i1 u( q$ L' x8 B
- arc_coords.start_angle=90*DEGRA;
4 h& b x+ p7 n" `" S: s: u - arc_coords.end_angle=270*DEGRA;5 w" j5 ?0 J6 ^ P! k
- arc_coords.radius=100;
6 A& r/ b$ G) z - arc_coords.matrix_tag=marix;! z1 e) v8 I( c6 g
- UF_CURVE_create_arc(&arc_coords,&arc);7 L9 u' Q9 o; e0 U- A: P
- // create point w( N" h6 R8 f- V; L8 V' X8 z
- double point_coords[3]={100,100,100};
) a" @/ w4 }" n/ {( O - tag_t point;# I; N% U+ {+ S3 ^7 k' u$ R
- UF_CURVE_create_point(point_coords,&point);! q) G+ V+ n Z, k
-
& w) b6 Q2 l& X5 Y - // create Plane+ ^/ |0 e! ]( [2 F$ i0 r
- double origin_point[3]={100,100,100};/ C( V( Q* t- F2 L+ T: c5 \
- double plane_normal[3]={1,0,0};
! V' Q- b& \; }) B% z - tag_t plane_tag; 2 z# u% k& e( y/ Y, y, |, q5 W
- UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*
* |0 r2 o) }5 Y4 c( F - Get the curve information2 I$ g, d$ t! J, c4 n6 v) |
- */6 u" o# E" b P Q
- UF_UI_open_listing_window();
1 K$ F% Y0 |. p/ b2 p, z- t9 a, t - char msg[132];
! y) L7 Z; u9 }# s - // get line information
3 g% o$ Z$ S9 l - UF_CURVE_line_t line_info;
$ N+ G! U) Q7 w& F1 K8 V5 Z% Y - UF_CURVE_ask_line_data(line,&line_info);& A; r/ E/ J5 P" M7 I- w5 O
- sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],9 J7 |9 k$ D8 r. G; L* e; Z
- line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],1 `5 V' ?, i5 c" {% D% K9 x
- line_info.end_point[2]);
* U3 M+ X/ S1 x5 |+ r/ d - UF_UI_write_listing_window(msg);
' k9 `' s8 ~# K. R - //get the point information
6 K0 F7 o$ v$ G3 i) Z - double point_info[3];( d, V" _) R* P
- UF_CURVE_ask_point_data(point,point_info);
" r2 y+ J8 C" e5 a1 M - sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);" E3 X5 S! ?6 U4 N1 P
- UF_UI_write_listing_window(msg);</p><p> //get the arc information
. D/ D# B; p6 e6 y& G b( \. c - UF_CURVE_arc_t arc_info;
3 X, D* i- s1 Z: q( k) x! P - UF_CURVE_ask_arc_data(arc,&arc_info);, S- e$ D2 s$ a" D
- 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;",) O" X- U) W+ G) R; s4 c* z
- arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],
: c' V) T( M2 v# {; B - arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius
. k0 k, h7 s) [& o9 e: W - );+ y6 ?3 D! M' K7 |( P" E# q4 f
- UF_UI_write_listing_window(msg);* `" K5 A6 g3 P& M
- // calculate the arc length# A) F' [# g( z/ }. a6 K
- double arc_length;5 t- _; T% \, c$ b$ T
- UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);9 `- R) Y! \- s9 x; ^
- sprintf(msg,"\nArc Length:\n\t%lf",arc_length);3 W. l- W! O1 p! O* v( x
- UF_UI_write_listing_window(msg);# Z* L% T4 L0 L E; W) f% v
- }# ^" U) g% F/ k
- </p><p> </p>
复制代码
5 l9 ~0 E9 T' h' A# k# | |
|