PLM之家PLMHome-工业软件践行者

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

[复制链接]

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

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

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

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

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

x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码2 d/ u! o1 n3 V; W) Y9 L: H+ f) ~. D

' e/ |; ]$ ]9 x5 N0 E- v
  1. <p>static void do_UGopenapi()6 d8 s" ^: T% C; l& @% ~3 t: u0 Z
  2. {
    . C% f: P; Y& l, d2 o- R0 F& k3 y
  3. /*
    ( p' u9 _  K. a8 V5 |
  4. Create Curve5 M. D+ ]' {/ F, Z; d
  5. */* ^7 p' F3 y. L7 J) P3 L/ L
  6. // create line5 [# Z7 h& T5 K5 T1 P8 G
  7. UF_CURVE_line_t line_coords;5 V5 j" S5 E& U7 b1 N
  8. tag_t line;+ a) e* O2 w# M! g7 ~' W
  9. line_coords.start_point[0]=0;
    % {8 O+ I$ R& [0 i5 J
  10. line_coords.start_point[1]=0;# q" D- }; N4 ?3 H  a' z
  11. line_coords.start_point[2]=0;+ c' y4 J9 i& z+ l
  12. line_coords.end_point[0]=100;( Z5 Y9 p" B( S& B( Y# {
  13. line_coords.end_point[1]=100;
    . `2 N& j1 C: P) U1 F
  14. line_coords.end_point[2]=100;
    / z$ E+ A# h: i! ]* r6 G) x+ U
  15. UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc3 y2 t; d$ m6 j: }9 p  @
  16. UF_CURVE_arc_t arc_coords;$ m4 u$ E9 Y8 ?5 w
  17. tag_t arc,marix,wcs;7 Y" s2 u  d! y# T
  18. UF_CSYS_ask_wcs(&wcs);
    * C/ d6 M5 x0 Z* p; F* k. D
  19. UF_CSYS_ask_matrix_of_object(wcs,&marix);
    0 u! `0 s: \: f. L* B4 @
  20. arc_coords.arc_center[0]=0;
    ' E7 e, z* S7 E4 M' `8 c- b1 G
  21. arc_coords.arc_center[1]=0;4 F! _# ^8 y% N0 d  U
  22. arc_coords.arc_center[2]=0;
    . \! |+ ?5 k- c
  23. arc_coords.start_angle=90*DEGRA;
    2 x+ S8 n3 H" G
  24. arc_coords.end_angle=270*DEGRA;: O( F; ?- `3 j% o. R- \2 u
  25. arc_coords.radius=100;; g* ^3 w3 [/ b/ X, M
  26. arc_coords.matrix_tag=marix;
    * P; ?) l, G& z$ J( b& B' }
  27. UF_CURVE_create_arc(&arc_coords,&arc);
    0 h3 Q! @7 r" ]; i" p
  28. // create point ' v, L" i7 E/ g4 T8 q7 Q& g
  29. double point_coords[3]={100,100,100};" {; S/ I) X+ D3 Y" G
  30. tag_t point;8 ^% E  U* {8 p& f
  31. UF_CURVE_create_point(point_coords,&point);
    ; Q# T% O  m' z' a5 T3 S. i
  32. 3 S7 l  q' Q' T- e; c9 k) y' Q, t
  33. // create Plane
      o! Z/ S# u% K. U! n% {+ W
  34. double    origin_point[3]={100,100,100};
    - y1 q/ P$ y8 W$ S/ `$ x
  35. double    plane_normal[3]={1,0,0};4 J- o& ]* m/ ?! e
  36. tag_t     plane_tag;    ' R+ x2 F4 H% K% g, f1 i4 i; s; m9 p# b3 H
  37. UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*
    ; q( U& D' C5 n
  38. Get the curve information
    3 q9 b5 V- V1 w* D0 d; B
  39.   */
    ! V7 M" k  }5 I5 o- \1 T
  40. UF_UI_open_listing_window();
    $ S6 a; N7 h3 x
  41. char msg[132];
    0 b: x" ~# M, D" Y8 u7 K
  42. // get line information2 L- P. N1 {( L  S8 ?. L* t
  43. UF_CURVE_line_t line_info;; @0 N& x3 ~5 M( S+ s, }
  44. UF_CURVE_ask_line_data(line,&line_info);
    2 p) w- ~5 w+ a) M
  45. sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],
    ) S/ l' X% {8 p
  46.   line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],
    : Z! }3 _3 L  l- j/ H& s
  47.   line_info.end_point[2]);1 n4 ^9 _3 m! }4 q% `
  48. UF_UI_write_listing_window(msg);
    - C$ ?0 o+ s7 P8 O+ ^
  49. //get the point information3 ^& a- o, O& Z! K" q: N; |
  50. double point_info[3];
    0 g9 \) y2 m* V
  51. UF_CURVE_ask_point_data(point,point_info);0 z( L4 _- [1 ?. N0 ~" S
  52. sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);
    / \0 F2 a3 c; |2 J- a- u; z
  53. UF_UI_write_listing_window(msg);</p><p> //get the arc information* \: x3 i! V( W$ Z; m. N
  54. UF_CURVE_arc_t arc_info;9 L( N$ L9 X/ \6 M2 h5 H( o% n; T
  55. UF_CURVE_ask_arc_data(arc,&arc_info);
    ! [5 t; d# `$ c. J+ @
  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;"," L. T4 S4 ?( d$ ?  e
  57.   arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],
    . A$ n8 w2 J5 G5 j% G  N" n
  58.   arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius3 P  G$ a9 A2 c6 w4 A
  59.   );
    5 B0 ^+ y7 {6 }" V
  60. UF_UI_write_listing_window(msg);  B- h* o2 ]5 D  n8 h
  61. // calculate the arc length
    * D  B0 u: F/ O" e$ r2 B, u
  62. double arc_length;* y$ \- {7 m' Q2 d8 T% ^: F9 [
  63. UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);
    ' @! p2 h. _: F4 \* `
  64. sprintf(msg,"\nArc Length:\n\t%lf",arc_length);# r6 q# U1 k& G" V
  65. UF_UI_write_listing_window(msg);
    6 m1 M9 ^% s+ j5 |" {* T# T
  66. }
    1 q# h6 W. W5 l) y" ^5 y/ Z0 n
  67. </p><p> </p>
复制代码
" P3 J9 G1 m, Y
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了