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

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

[复制链接]

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

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

admin 楼主

2013-11-27 15:21:12

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

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

x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码
1 K6 N6 x# G/ r* I3 E, w" \
5 I' e0 D0 p, a
  1. <p>static void do_UGopenapi()
    $ j, n. o% i# b" P! x: c" l; o9 H, [
  2. {7 ?0 L; r% t' ^4 Q7 x/ I# u
  3. /*
    1 n; [1 [' i, ^+ ^( J" O% h
  4. Create Curve
    $ o$ c  s% s; k6 U4 G
  5. */
    4 k5 ^2 H0 |; M& a& d0 M
  6. // create line
    2 u' I1 s5 a8 M* d1 _& z3 u
  7. UF_CURVE_line_t line_coords;5 Q: R( q0 p1 w2 L! s% V  y$ X9 q
  8. tag_t line;0 D: h; O2 n3 G; y8 ?' s
  9. line_coords.start_point[0]=0;# j* i/ W! e$ z0 X- _
  10. line_coords.start_point[1]=0;, H! n4 U  `4 e% k
  11. line_coords.start_point[2]=0;
    " b5 v9 J6 E5 i" N5 g" [) R( |
  12. line_coords.end_point[0]=100;3 F( a$ c4 q8 j1 p; Z7 X/ i) p
  13. line_coords.end_point[1]=100;
    ( \- j# r9 {, |$ {9 O: E, I
  14. line_coords.end_point[2]=100;
    8 K5 E' w8 K2 N) N3 J: ]
  15. UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc
    4 e% Z* H: K* G/ s& p
  16. UF_CURVE_arc_t arc_coords;% Z  s! s* z  Z' L/ ?4 u7 |: ?
  17. tag_t arc,marix,wcs;
    9 A- a! e; q# u" X( {7 T
  18. UF_CSYS_ask_wcs(&wcs);
    % |3 H3 o# D- P& h: i. ]# G
  19. UF_CSYS_ask_matrix_of_object(wcs,&marix);
    0 ~; G, L) F& h3 q  W- A* }6 h
  20. arc_coords.arc_center[0]=0;
    + _- n" r" x% v
  21. arc_coords.arc_center[1]=0;
    2 U2 H4 G! b% L9 z7 h! d  J6 d, W
  22. arc_coords.arc_center[2]=0;
    6 Y% X3 V6 u4 x& _! K1 }& `. O  u
  23. arc_coords.start_angle=90*DEGRA;
    " P' _: H3 {+ a7 r$ n, W# d) W
  24. arc_coords.end_angle=270*DEGRA;
    / d4 Q- b  p4 j- h+ Q* j- {
  25. arc_coords.radius=100;( e) N/ u- m) }8 ~# D; [
  26. arc_coords.matrix_tag=marix;
    + L+ _4 P% R  [8 v8 Q5 C  K9 {
  27. UF_CURVE_create_arc(&arc_coords,&arc);
    % j" D6 R1 I; x: [& C
  28. // create point
    ; Q+ G) f3 T- ~
  29. double point_coords[3]={100,100,100};- r- X& R$ M( x  _1 [, I! S1 r
  30. tag_t point;" m8 Y1 t# H% Y' ~  S
  31. UF_CURVE_create_point(point_coords,&point);
    , t1 M6 z! Z+ Z6 a

  32. 1 i& N. n; d7 ^0 x
  33. // create Plane  F+ H; f# o; e" [
  34. double    origin_point[3]={100,100,100};
    8 a/ o# c1 W9 j4 ]
  35. double    plane_normal[3]={1,0,0};# t7 B7 s* y* ?4 O+ }4 g( S
  36. tag_t     plane_tag;   
    * H! b% V, [4 j4 b6 A
  37. UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*% o4 b$ G" P% q6 g1 Q- K0 {
  38. Get the curve information
    ( V7 I; D5 D' @% N
  39.   */( P" C/ d8 U$ J$ q& E
  40. UF_UI_open_listing_window();5 n$ b. _$ _5 H% [. _
  41. char msg[132];
    ' }: |& n7 U' [- D3 B
  42. // get line information
    6 w; I1 F. l, c8 l4 V
  43. UF_CURVE_line_t line_info;
    & Z: U# x4 ?, N- c
  44. UF_CURVE_ask_line_data(line,&line_info);
    ) t1 u, d0 N0 |0 q
  45. sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],
      |5 B& }) v7 G# Z
  46.   line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],
    5 A3 m* v, h1 y$ B; j- M; }
  47.   line_info.end_point[2]);
    , P7 q4 T, v3 e8 p% O# d- ]
  48. UF_UI_write_listing_window(msg);
    - C$ ~" j3 R# q0 h) L. s! O% C
  49. //get the point information
    0 @5 C) d+ @8 C# O+ C
  50. double point_info[3];
    * _$ [1 ^" ^: H
  51. UF_CURVE_ask_point_data(point,point_info);
    % e4 S5 \; p/ I4 l" I& B8 O
  52. sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);
    ; }9 Q$ l3 B7 Y) s) T
  53. UF_UI_write_listing_window(msg);</p><p> //get the arc information
    ; J# @& s5 j. H* E
  54. UF_CURVE_arc_t arc_info;
    / W4 G  b$ V7 i, n- U
  55. UF_CURVE_ask_arc_data(arc,&arc_info);
    2 o2 w' z8 [- T: T  t6 h
  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;",0 L' B$ S, h( P9 N
  57.   arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],
    " U( ?2 }+ K% H
  58.   arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius
    ) i6 f  E5 N" Y5 C% S) r: s
  59.   );! W8 b& X7 z. c# Y  d2 e& R. \8 u
  60. UF_UI_write_listing_window(msg);
    ( k+ B3 w3 H" X, E2 y: g
  61. // calculate the arc length1 [' |* ?0 G; g) S" M7 K1 D) Z1 p
  62. double arc_length;
    3 `& m( Y5 V" h3 r4 k7 c
  63. UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);
    4 ~6 |3 {1 {) Y9 r- ^, y0 m
  64. sprintf(msg,"\nArc Length:\n\t%lf",arc_length);
    * v  E5 H- o' K) c9 O% o; j4 c
  65. UF_UI_write_listing_window(msg);
    " o7 C) U( Y6 g! N
  66. }8 d9 w6 m: ^" H% F- L
  67. </p><p> </p>
复制代码
9 @+ I$ d7 V, o, B
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了