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

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

[复制链接]

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

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

admin 楼主

2013-11-27 15:21:12

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

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

x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码
3 n, P, N9 k( [5 k9 A$ L0 }8 N4 e9 a8 x
  1. <p>static void do_UGopenapi()
    2 c: L1 a9 G7 d3 D9 y0 o+ R
  2. {# h3 i/ Q$ R7 p; _  d
  3. /*1 S* w2 Q; O3 y, C
  4. Create Curve
    8 ]: _% d+ w" k: b+ E9 Z6 U: W
  5. */
    % w' V. N3 n! ^* Z2 n2 n* W/ @6 v
  6. // create line, P" p) |% o; w4 k% ]8 i
  7. UF_CURVE_line_t line_coords;
    , L. O/ U; ^& E- M1 U9 C
  8. tag_t line;
    : ^  L1 `# t' R, G
  9. line_coords.start_point[0]=0;3 |0 |; M- m  i: ?
  10. line_coords.start_point[1]=0;
    4 n3 m/ c5 J0 B" T0 f6 F% D( k2 `
  11. line_coords.start_point[2]=0;3 K4 K( y9 P! e6 M, q
  12. line_coords.end_point[0]=100;
    ' ^: _6 I7 `# M+ A. Z
  13. line_coords.end_point[1]=100;
      G& i( X* X7 k7 |% u3 g/ ?
  14. line_coords.end_point[2]=100;" {/ E: e5 W  J8 N# d
  15. UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc8 O0 @+ e5 ~/ {7 d6 H
  16. UF_CURVE_arc_t arc_coords;
    , `. C( l2 R* M: ?2 G0 w% T- ?
  17. tag_t arc,marix,wcs;
    + I1 S# X/ |  `' T! S- J
  18. UF_CSYS_ask_wcs(&wcs);
    6 m$ B( S! z3 w$ K! C& h
  19. UF_CSYS_ask_matrix_of_object(wcs,&marix);
    / _  x" o  W) x: B
  20. arc_coords.arc_center[0]=0;
    ( M& }% L# H1 v9 D9 S! `
  21. arc_coords.arc_center[1]=0;
    " Z5 u  w$ w# E4 {8 [
  22. arc_coords.arc_center[2]=0;; ]0 S, G# F. [& c* b3 u1 O6 P
  23. arc_coords.start_angle=90*DEGRA;( Y/ f! M9 |, G" y
  24. arc_coords.end_angle=270*DEGRA;8 W" b  M# s* j: |+ H8 f+ |/ V; H
  25. arc_coords.radius=100;
    6 n( e+ o" V) ]3 i6 }8 e) _
  26. arc_coords.matrix_tag=marix;8 K! J6 D  z! L; T8 C$ T* E
  27. UF_CURVE_create_arc(&arc_coords,&arc);
    6 D" Z5 ^. R7 R. P1 x3 ?
  28. // create point
    ; s& E9 x7 |9 ~8 e& m) z$ n( n
  29. double point_coords[3]={100,100,100};
    3 ]6 T4 J1 l7 }9 \7 j
  30. tag_t point;. B0 o$ o$ O, {6 A$ M3 ]0 c' U
  31. UF_CURVE_create_point(point_coords,&point);9 [& ?: H& H+ h+ i
  32. # t% Z/ h# x: B. z: d" ~
  33. // create Plane
    " L. H. |9 q! G9 q
  34. double    origin_point[3]={100,100,100};, C; e6 ?5 K' q
  35. double    plane_normal[3]={1,0,0};4 |* D' b1 X: z0 p6 ^4 r" n* Z2 L3 N
  36. tag_t     plane_tag;   
    ( c' b  B5 Z- |3 S* z
  37. UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*
    ! R, Q8 Y4 \! I) i( d8 s% L% v
  38. Get the curve information
    ! q4 e* o' `2 t1 N  s
  39.   */3 G' [, q$ F$ V8 j8 J0 M& K( W- P
  40. UF_UI_open_listing_window();
    6 \  S- S5 [# m$ m7 g
  41. char msg[132];% e5 c! Q0 D1 K% x: i
  42. // get line information: ^  X* ^; |$ [1 Y
  43. UF_CURVE_line_t line_info;. Z% T0 a" x; |5 ]/ m% t
  44. UF_CURVE_ask_line_data(line,&line_info);
    ) B2 [( i0 ]- j
  45. sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],) \7 `" }+ C0 l" _
  46.   line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],) {* u+ a( `$ M  q; m
  47.   line_info.end_point[2]);1 j6 A0 q. [  S( N
  48. UF_UI_write_listing_window(msg);. C  d2 K- C  F2 h
  49. //get the point information
    " F( B2 p8 u2 W; C, l9 U" ?1 b) G
  50. double point_info[3];0 Y9 U% R1 l/ L4 }2 o% ]+ k
  51. UF_CURVE_ask_point_data(point,point_info);- r+ G4 e; |' i/ z# V
  52. sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);
    7 I8 Z* ^! ?: |" z
  53. UF_UI_write_listing_window(msg);</p><p> //get the arc information6 T; ?/ g& `0 x" G8 z( j  i
  54. UF_CURVE_arc_t arc_info;
    ( ~! H8 `+ x7 {* K9 j3 A: R
  55. UF_CURVE_ask_arc_data(arc,&arc_info);
    / `; K3 L1 @! q4 i+ L- @
  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;",
    * y: l% y! B6 W, U
  57.   arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],
    & X7 W2 e. G# u; ?( N4 k
  58.   arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius# ?" \1 ?( i- R9 a. Y- i0 u
  59.   );! j! i! W+ w& Q2 |
  60. UF_UI_write_listing_window(msg);. ?& \3 E& k# P& t  d8 X1 \$ L
  61. // calculate the arc length
    : x' G1 O& }. Q' F- U
  62. double arc_length;  Z' w9 T6 B# _) z. I0 U  j
  63. UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);6 L9 y' m- ?( r- ~# o" x4 r
  64. sprintf(msg,"\nArc Length:\n\t%lf",arc_length);
    ; q0 P3 g$ I# t4 c5 {+ y
  65. UF_UI_write_listing_window(msg);, g* X: e* a7 `2 Q4 _( n0 ]- g
  66. }0 g) h$ w5 S9 J' _7 Q
  67. </p><p> </p>
复制代码
4 P2 ]6 z) G3 o% E) ]- G1 g
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了