PLM之家PLMHome-国产软件践行者

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

[复制链接]

2013-11-27 15:21:12 2987 0

admin 发表于 2013-11-27 15:21:12 |阅读模式

admin 楼主

2013-11-27 15:21:12

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

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

x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码
& f% t" P9 p8 g7 t5 Q4 I0 |* `- E" g/ W* D( B
  1. <p>static void do_UGopenapi()
    4 K" p" k5 ^% {% T
  2. {. q4 X, q: f& y* d4 k1 t
  3. /*
    ) g. o3 A: n0 Z: f) o
  4. Create Curve
    % D2 X1 f1 g" n
  5. */
    ! X; Q3 D9 B, h  ~
  6. // create line2 x; k9 F. D  P2 H
  7. UF_CURVE_line_t line_coords;$ `  r& v% Q, B6 j
  8. tag_t line;
    ! y/ W$ W+ u  D. D
  9. line_coords.start_point[0]=0;; \1 S1 \  y5 M, U+ x
  10. line_coords.start_point[1]=0;
    8 K- s: I& G0 v9 z7 o
  11. line_coords.start_point[2]=0;2 f; M' F9 ]3 k( ^: n0 {. N
  12. line_coords.end_point[0]=100;
    0 J$ B* k" d. z, G
  13. line_coords.end_point[1]=100;  w# A+ Y. T6 x4 Q+ O! {2 G, H; F
  14. line_coords.end_point[2]=100;0 z! \6 E# |' z" v+ Q
  15. UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc% F3 U$ }+ G% w/ @/ w; P3 m8 l
  16. UF_CURVE_arc_t arc_coords;1 \6 z" l8 g: U$ b
  17. tag_t arc,marix,wcs;7 V3 g4 e" F$ ?# w0 @. K0 ?
  18. UF_CSYS_ask_wcs(&wcs);
    ' s2 u; q, o3 H, j, c* i
  19. UF_CSYS_ask_matrix_of_object(wcs,&marix);* S3 z7 q3 b+ `- @4 m8 ]3 Z- }$ z
  20. arc_coords.arc_center[0]=0;* }+ G- {+ J3 Z
  21. arc_coords.arc_center[1]=0;, \. X8 W3 p; n  c: s
  22. arc_coords.arc_center[2]=0;! E( s7 l/ t1 X- R- {$ N. x
  23. arc_coords.start_angle=90*DEGRA;
    9 ~% c- `, a. Q5 R* k
  24. arc_coords.end_angle=270*DEGRA;
    # T. g3 K  U' r2 O, N
  25. arc_coords.radius=100;0 |7 V3 H: O+ {9 R2 W& x
  26. arc_coords.matrix_tag=marix;& M) h/ H) T$ e+ w- j: S! u
  27. UF_CURVE_create_arc(&arc_coords,&arc);
    * X0 U6 f+ e, d1 O
  28. // create point
    , w5 r' R$ L# Y: k" D
  29. double point_coords[3]={100,100,100};
    ' J9 ^! b, y- ^* t4 o; ]6 g
  30. tag_t point;
    ; @. d: i( M) r; W) k, k9 V0 h9 C
  31. UF_CURVE_create_point(point_coords,&point);
    $ M4 o6 Z3 G( a: X. C
  32. 9 I  J0 q5 \( ]. [3 t4 m' K
  33. // create Plane8 w, T4 y% o5 K; y  W
  34. double    origin_point[3]={100,100,100};, q( N: i$ Z! Y! n' x, c& f
  35. double    plane_normal[3]={1,0,0};6 b0 D: H. g9 |1 p# Y! p
  36. tag_t     plane_tag;   
    - X! c7 m# m) k7 W6 X. F4 k  H
  37. UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*
    ) J* @( O  N3 `! _$ ]6 G
  38. Get the curve information
    % p$ r# {1 ~  i2 |+ G
  39.   */
    * `7 D* G& ^. u! l
  40. UF_UI_open_listing_window();
    4 j% a* a* X% n
  41. char msg[132];
    , ^( A+ e+ x* ~4 `
  42. // get line information
    ; B  m& q. ^, k0 Y
  43. UF_CURVE_line_t line_info;- J; q  W0 V5 V: R
  44. UF_CURVE_ask_line_data(line,&line_info);
    - n: H" g; V' e& N; p' C
  45. sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],
    $ U' E9 s( M. F& |
  46.   line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],9 \5 b+ w/ h0 C. ?
  47.   line_info.end_point[2]);' R2 H9 `0 e5 ?& R9 N
  48. UF_UI_write_listing_window(msg);
    - e0 m7 N9 O- R0 K5 l: T
  49. //get the point information
    2 H7 S/ K. n+ t7 ]0 ?  y3 T
  50. double point_info[3];! b& h7 M* Z8 b0 `# d- m& Q0 d
  51. UF_CURVE_ask_point_data(point,point_info);
    " N  c! ?, {) `4 Z) O( J
  52. sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);: `% H- S; T3 H  w- g& S* b9 T
  53. UF_UI_write_listing_window(msg);</p><p> //get the arc information
    ) y' M4 x5 j0 ?$ W
  54. UF_CURVE_arc_t arc_info;! X2 i" Q% h  d/ |
  55. UF_CURVE_ask_arc_data(arc,&arc_info);
    1 d8 h6 U" K0 X) }4 q) u
  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;",* ~( Q4 |  Q$ E/ {- d
  57.   arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],# j0 r1 `' M* m7 \* M, _4 w/ [
  58.   arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius
    ; v5 q) ?: F) w' A1 N! J' }/ s
  59.   );) J# `1 j3 C/ y9 D6 z  \, K
  60. UF_UI_write_listing_window(msg);% c# F6 B5 l' A! |+ I9 i1 v# \) f
  61. // calculate the arc length2 X, P% o; f. ]$ [$ g$ S( m; T
  62. double arc_length;1 R1 v; _! x/ a/ L9 ?  S9 y0 D
  63. UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);
      l* E& ]9 s! `+ c  Y# W% D
  64. sprintf(msg,"\nArc Length:\n\t%lf",arc_length);+ N0 x% G! _) M7 ~4 e- m, Y1 L4 C$ ~
  65. UF_UI_write_listing_window(msg);6 h4 t& z' M$ ^5 M
  66. }
    / \' w: T2 a$ t
  67. </p><p> </p>
复制代码

( c3 ^6 q5 L$ I& ?
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了