|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码- X, J1 N ]5 R6 h' B8 j, q" G& F
/ [# v; A. s7 G5 J& K- <p>static void do_UGopenapi()
. y4 d% X# r5 M0 | - {: ?* r3 x8 G+ e+ V8 _
- /*
! E% y( V" p. Q$ I2 R" [- m - Create Curve# L6 h1 [' U; b7 w& Z4 H7 T
- */
7 g. B& E* o; S# ] - // create line
2 a! U2 l/ G& U% O+ h3 X - UF_CURVE_line_t line_coords;
: F. M% V7 C" \$ O- m0 [/ z/ R - tag_t line;3 r# O y2 h4 f$ i
- line_coords.start_point[0]=0;
. Q' `* }. }7 X7 i* F- ]7 p - line_coords.start_point[1]=0;+ G4 E" Z# R/ P$ h; p N; q
- line_coords.start_point[2]=0;0 L$ K3 _. Z% x( ?: z! |' Y
- line_coords.end_point[0]=100;: n6 {4 y8 X8 d" l1 n
- line_coords.end_point[1]=100;
# D. H1 U* g6 S. T - line_coords.end_point[2]=100;6 q f, i; a3 E) j
- UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc
# o, p. {. R' T# I. O* N - UF_CURVE_arc_t arc_coords;
: v0 ?5 G" `3 x( h, y- ?/ ]. w+ [7 p - tag_t arc,marix,wcs;# n4 A# g0 F2 h1 d& a3 u6 ~9 m5 f
- UF_CSYS_ask_wcs(&wcs);
( @7 z2 }# O" a; Q; i - UF_CSYS_ask_matrix_of_object(wcs,&marix); I) D- ~/ M! |. L
- arc_coords.arc_center[0]=0;
7 w8 x1 @1 X$ [8 [. t# ]: \- O' I - arc_coords.arc_center[1]=0;
. |7 C* [' s+ r - arc_coords.arc_center[2]=0;9 j- V! P, c$ u, `" v4 B
- arc_coords.start_angle=90*DEGRA;
; g1 F. }5 [; a- G; n - arc_coords.end_angle=270*DEGRA;- p" p- r" V# Q8 `' O' v! U& ^
- arc_coords.radius=100;' a; Q: U* m. i9 J- s4 |2 s% t
- arc_coords.matrix_tag=marix;
8 t! @9 M, n- D$ ~: W# a; ~7 Z8 w - UF_CURVE_create_arc(&arc_coords,&arc);# B/ f) i; m; W7 G4 G" T
- // create point
2 e; _0 h* C( C3 J6 V; i ? - double point_coords[3]={100,100,100};
7 A# h6 v2 r* ? J1 `2 D/ c - tag_t point;
# J% I/ O8 i' X V - UF_CURVE_create_point(point_coords,&point);
* r3 Y" I7 L0 t ` - 9 E0 E5 ^5 w2 w F ?$ s
- // create Plane
0 Y7 i) ] l# K U2 ? - double origin_point[3]={100,100,100};. m& `9 h2 v$ \" Z( K+ q" g, \
- double plane_normal[3]={1,0,0};
2 |& D; \" @0 X; Y4 K - tag_t plane_tag; , z! E1 b4 z3 m; a q
- UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*
9 e- L6 }9 v& M- S% K; u - Get the curve information( M0 ]( |) C& @! A1 h
- */2 ]/ }6 Q8 k8 I2 ^
- UF_UI_open_listing_window();
4 ]4 ?: ?! Q8 {. e7 V4 x; I - char msg[132];
3 F$ |/ _$ a0 @ - // get line information2 S' `6 l3 ?5 d
- UF_CURVE_line_t line_info;/ o* p1 c& e5 B% S$ Y/ I
- UF_CURVE_ask_line_data(line,&line_info);
- T" p' _ a5 h, f; Q - sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],
- z/ |8 ^' D3 D+ ^ - line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],
; [6 _* f8 C, `1 M* p# p - line_info.end_point[2]);$ z$ @! @8 N- K) T- u P1 Q# a8 d
- UF_UI_write_listing_window(msg);
: n1 N. m; @- t% [8 ]; t5 B/ l# U - //get the point information
+ I! |/ c& Z. N+ s4 ?2 w( m4 O- V5 l - double point_info[3]; |9 y+ _0 t5 Q
- UF_CURVE_ask_point_data(point,point_info);
8 k( H2 E- X' T6 h3 }5 ^% l - sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);4 Y8 j- T$ G) g8 z9 p! a9 p' A
- UF_UI_write_listing_window(msg);</p><p> //get the arc information6 Y! u5 B& I" f, ~" m
- UF_CURVE_arc_t arc_info;9 s* K# @+ t- k0 h" m) o4 L8 G1 F
- UF_CURVE_ask_arc_data(arc,&arc_info);
) p+ C5 R# j! 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;",
0 k: Z: d5 |+ x6 s4 r' o1 F - arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],7 G* G% v; H3 l8 G) q
- arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius
% H# t* w0 a! \9 g+ y. c- Q - );
) E9 r' l6 |: K; G$ a/ } - UF_UI_write_listing_window(msg);
: z8 Q3 _5 B; }8 e0 b - // calculate the arc length9 z( u) t/ J% Y$ u6 s
- double arc_length;
6 `; s `" M' x) h' k ^ - UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);) H: C4 Y- e) X1 ~( e V8 ?
- sprintf(msg,"\nArc Length:\n\t%lf",arc_length);
7 J1 x$ a. A5 Z/ k" U - UF_UI_write_listing_window(msg);* ~* l/ E4 C) k% N" ^2 R. x% Y
- }. G- N5 q' _# Z9 |% l ]$ b
- </p><p> </p>
复制代码
, f) c! v) G( t( h8 C |
|