查看: 3263|回复: 0

[二次开发源码] NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码

[复制链接]

6

主题

4

回帖

60

积分

管理员

积分
60
发表于 2013-11-27 15:21:12 | 显示全部楼层 |阅读模式

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

×
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码3 T6 R* C% m1 z7 b# i; T

4 P! Z: n2 A' L1 X5 A
  1. <p>static void do_UGopenapi()6 I- y1 i3 v3 B/ A# i) I. \
  2. {
    ) T0 q. K% k9 U4 {! ]8 ]
  3. /*& a/ L# C$ Q3 R
  4. Create Curve8 N) V% q. y1 m/ K: h
  5. */
    2 P' n7 D+ t* u/ C+ n
  6. // create line
    ' A! J; x- R# R: b. |3 j1 h8 ^
  7. UF_CURVE_line_t line_coords;2 r9 t/ w( X0 G8 u) F
  8. tag_t line;
    8 g5 w$ \( O% C1 G1 }0 T+ B- I
  9. line_coords.start_point[0]=0;
    1 W- W; N% p6 V9 H
  10. line_coords.start_point[1]=0;
    1 q/ r: q& [1 q0 `- T2 j" i
  11. line_coords.start_point[2]=0;. P- ?9 U6 I$ s; r% R" u
  12. line_coords.end_point[0]=100;6 Q2 U  w$ D( \! _9 [/ D; c" s9 v, d
  13. line_coords.end_point[1]=100;
    * T- Y$ B9 k" D, l% c, T
  14. line_coords.end_point[2]=100;' A7 W7 M3 {# ~
  15. UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc
    # O+ t  S4 q8 A3 c
  16. UF_CURVE_arc_t arc_coords;
    9 T8 n3 ]( ?9 F% r
  17. tag_t arc,marix,wcs;+ _/ s" y( f7 d" f8 \! v  k
  18. UF_CSYS_ask_wcs(&wcs);  n6 J8 B! T# u4 |/ M
  19. UF_CSYS_ask_matrix_of_object(wcs,&marix);7 j. r0 c% Z4 A0 x
  20. arc_coords.arc_center[0]=0;
    ! y. Q5 i% e! Z4 x& o
  21. arc_coords.arc_center[1]=0;
    8 R/ E' F- h3 @: t% C- ~
  22. arc_coords.arc_center[2]=0;
    : m7 }- q% w0 ~5 R  ~6 ^1 u
  23. arc_coords.start_angle=90*DEGRA;6 o7 d1 S7 z5 y
  24. arc_coords.end_angle=270*DEGRA;
    - ^% w) U, V4 A2 T5 l
  25. arc_coords.radius=100;
    , r/ v. O7 f: ~  a# K% A) ~' x: ?
  26. arc_coords.matrix_tag=marix;
    ; }0 T& t2 U. Y! S$ |
  27. UF_CURVE_create_arc(&arc_coords,&arc);
    ' d- K0 h! M* |# m) V
  28. // create point 2 M/ }! }1 ~1 g0 [0 c4 m
  29. double point_coords[3]={100,100,100};
    , v" L; E8 x9 P7 U
  30. tag_t point;
    ! E# x3 j3 z3 n$ k
  31. UF_CURVE_create_point(point_coords,&point);) A1 i* i- d9 e8 U$ f. y2 f- [6 F
  32. ' x* e$ ~0 N$ ~
  33. // create Plane
    + h4 C% [0 m% D3 f% ^) J* o
  34. double    origin_point[3]={100,100,100};
    1 B) T& ^# D. J6 c( _! C& Z
  35. double    plane_normal[3]={1,0,0};
    ' @) G# |, q* F6 K
  36. tag_t     plane_tag;   
    6 Z4 J  l. V7 Y7 g, f( J
  37. UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*
      L! i  Y6 l( d3 H3 ?( O/ n
  38. Get the curve information
    . p9 g: a6 k1 @" `
  39.   */
    1 W( n- R! b( J; V$ g0 z
  40. UF_UI_open_listing_window();
    4 v; L, v: }! u3 @0 @
  41. char msg[132];
    5 B$ K% J6 {5 O; j' g, J
  42. // get line information
    , Q* p4 _* D: A4 w1 b- `
  43. UF_CURVE_line_t line_info;( q" q) V+ P& ~5 v  f2 e9 {
  44. UF_CURVE_ask_line_data(line,&line_info);* t4 e3 ^# N7 ^% s$ T% r8 F+ g( O
  45. sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],
    9 N& |$ D. N, X2 b4 u4 y
  46.   line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],
    + V. N. [# Z0 O3 u
  47.   line_info.end_point[2]);, G1 [, D" [: g" Y
  48. UF_UI_write_listing_window(msg);
    5 N1 I% {8 P- s' y& C3 Z
  49. //get the point information
    3 b- u+ H# U' g+ w& q& S
  50. double point_info[3];
    + o3 p* a& N) [" ~7 M- E, W/ j  x. t
  51. UF_CURVE_ask_point_data(point,point_info);. ?* k4 b' b. m6 A
  52. sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);
    & o; S6 d, g( l8 X, w5 X" g
  53. UF_UI_write_listing_window(msg);</p><p> //get the arc information* J2 F/ c. B! f8 b. e
  54. UF_CURVE_arc_t arc_info;
    3 @; K" W2 ^9 e
  55. UF_CURVE_ask_arc_data(arc,&arc_info);  R! H" z5 N' A: a3 N8 N: [
  56. 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;",. ~( e* h: Q  X
  57.   arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],
    % T: L+ f/ @% b/ U
  58.   arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius
    : V8 f( R  v! \# Y
  59.   );2 p+ _" W3 H: y' [, O2 J
  60. UF_UI_write_listing_window(msg);; S7 ?; |* P# [( F* b9 G- v
  61. // calculate the arc length- _" c/ O6 ?/ `. T" n
  62. double arc_length;
    ( R; ]8 m; \" U- z  i
  63. UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);
    + q3 l( B  k0 {/ N5 N
  64. sprintf(msg,"\nArc Length:\n\t%lf",arc_length);! S; ?! ^; t3 `. O+ A  G
  65. UF_UI_write_listing_window(msg);; ]' i4 R. U. U/ O* w3 ?
  66. }
    : L" n: K# ^9 T' p7 G" N1 ~* _
  67. </p><p> </p>
复制代码
8 c" P1 q$ x9 A5 I" v: Z  A4 \
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

在本版发帖
关注公众号
QQ客服返回顶部