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

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

[复制链接]

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

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

admin 楼主

2013-11-27 15:21:12

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

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

x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码- b: M% a5 @& S5 P& s" W% H, o

# d, v' k: k: s( H
  1. <p>static void do_UGopenapi()
    1 ?5 I7 z1 b/ W( J1 [
  2. {! i* Y3 K( o7 e4 M
  3. /*, c7 w( l! d8 w, N0 m& M% |
  4. Create Curve$ I! k/ w+ ~7 v- w; h2 d
  5. */8 V% Y  _0 ]6 X* o5 x' m7 U$ X
  6. // create line
    0 Q0 B- N( B8 `1 R
  7. UF_CURVE_line_t line_coords;
    9 p; O. v& m. x5 t# {( j1 l
  8. tag_t line;8 Z* r# ]! A6 P& N2 o) l% r  [# y6 I
  9. line_coords.start_point[0]=0;
    3 Y1 t$ H7 F( L8 h
  10. line_coords.start_point[1]=0;9 ~) O/ A! R& h0 M7 }
  11. line_coords.start_point[2]=0;
    4 _6 ?% s1 e# c: \/ v  l
  12. line_coords.end_point[0]=100;! K  }2 R4 n: X/ g/ C: Z
  13. line_coords.end_point[1]=100;3 N" z# c9 x- x  N6 d
  14. line_coords.end_point[2]=100;
    ) u# T/ I8 l4 S" x- e9 n7 l* G
  15. UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc- ]: a" G0 P  Z/ n! _0 n. z
  16. UF_CURVE_arc_t arc_coords;/ K/ Z' E( j) M) [' \9 w% ~5 `
  17. tag_t arc,marix,wcs;6 R0 Y! E- O# O9 S+ Y+ i: \2 k
  18. UF_CSYS_ask_wcs(&wcs);1 L2 D1 }0 X3 J: \* p$ x7 Q* g
  19. UF_CSYS_ask_matrix_of_object(wcs,&marix);
    + a' R2 F$ R8 F$ P8 y; v
  20. arc_coords.arc_center[0]=0;
    & S  S* |: G7 ?0 R- M( h
  21. arc_coords.arc_center[1]=0;
    , e/ A1 s' _2 n: b+ Y
  22. arc_coords.arc_center[2]=0;/ G4 M+ X4 m" W3 w2 M1 P5 f
  23. arc_coords.start_angle=90*DEGRA;! t4 I1 U9 w: {3 W* H6 h
  24. arc_coords.end_angle=270*DEGRA;
    " c! _/ x! n) @
  25. arc_coords.radius=100;
    % N8 {' |; G+ U6 n7 b
  26. arc_coords.matrix_tag=marix;% w* l- W4 a) ~- W& W9 B! y
  27. UF_CURVE_create_arc(&arc_coords,&arc);, b' ^. n: w# p' T' g
  28. // create point
    ; y# L$ A1 m0 ^1 ]. v
  29. double point_coords[3]={100,100,100};
    1 \6 m/ {& m# a: m- X" {2 ^
  30. tag_t point;
    ( L' ~. Z& h. N
  31. UF_CURVE_create_point(point_coords,&point);
    8 C3 Q9 c: }0 {% \( ^* K( J
  32. 0 h0 V5 D: [4 o# l% x7 }; v
  33. // create Plane2 n8 n$ s+ ]  P+ J6 w- y
  34. double    origin_point[3]={100,100,100};( w  G% X) p9 f9 Y& H
  35. double    plane_normal[3]={1,0,0};
    5 _& Y: n$ O" ]! h9 p( K* r8 c5 q
  36. tag_t     plane_tag;    : s5 |' L4 {  F; f) T+ }7 h
  37. UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*2 I7 s5 |; l* G6 H( o- p# G
  38. Get the curve information+ M; D0 a4 G3 G) R" U
  39.   */  v) v3 h" L; [
  40. UF_UI_open_listing_window();
    7 ?( {# G$ a1 |* Z  a3 G
  41. char msg[132];7 Q2 j* M1 P$ a
  42. // get line information" I7 t( A/ ]; S7 Q
  43. UF_CURVE_line_t line_info;
    ' E# a; L# X2 ?4 ?9 G
  44. UF_CURVE_ask_line_data(line,&line_info);
    , N1 E7 r0 O( `5 e
  45. sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],
    0 D  P4 o2 A# ]& e
  46.   line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],
    ' ?+ @4 v) a, N4 d7 \3 D6 V0 t
  47.   line_info.end_point[2]);
    ' W, K" @3 ?: E' q, ^' ?
  48. UF_UI_write_listing_window(msg);0 @5 m3 P7 x6 E, Q
  49. //get the point information
    + X5 E$ s2 `2 a
  50. double point_info[3];
    " ^) a8 Q; A/ t2 C
  51. UF_CURVE_ask_point_data(point,point_info);. S6 Z5 V2 U! y* N6 b4 s; T1 I7 M5 o
  52. sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);. ?% m- t8 I. l0 z; |2 t. O
  53. UF_UI_write_listing_window(msg);</p><p> //get the arc information
    ' W9 T( z" ?) N2 K7 x, r/ Q
  54. UF_CURVE_arc_t arc_info;
    6 I- R) }9 j; _6 k8 {! A* t7 j
  55. UF_CURVE_ask_arc_data(arc,&arc_info);+ t( B, _$ W5 N0 w+ M
  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;",! O) [0 X$ h, R2 m7 q
  57.   arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],
    9 I0 K* @8 Q' L- K
  58.   arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius. r9 V) l# I/ o
  59.   );
    & _/ P1 S+ q+ x. n9 q
  60. UF_UI_write_listing_window(msg);
      O% j5 N* N8 h- o
  61. // calculate the arc length
    : J  [" {/ t% a. D) V% f
  62. double arc_length;" P% U, D  a( k
  63. UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);( ?4 W( o5 W$ @) x4 @, [# L
  64. sprintf(msg,"\nArc Length:\n\t%lf",arc_length);
    , _$ i5 [: e0 l, O
  65. UF_UI_write_listing_window(msg);3 W; X8 e% b0 E
  66. }
    3 i" ]( U* g2 K; r, M
  67. </p><p> </p>
复制代码
+ e5 @7 d: i$ \6 A
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了