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

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

[复制链接]

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

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

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

x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码5 Z" I: t# U: H; q1 o. W
$ J7 C6 j; m$ @3 d0 U3 d( U  ?
  1. <p>static void do_UGopenapi()
      S  |9 C7 o% p4 k
  2. {
    : K, b& F) l: ~- u8 {
  3. /*! A! O* G! M# F# f% B/ J
  4. Create Curve' f0 w4 h( F" _+ ^- o$ ~/ r
  5. */& D, f- E+ c/ D5 ?# Q
  6. // create line
    2 a! ^7 n; k; r: X( r& y
  7. UF_CURVE_line_t line_coords;, j2 c, |/ W: C  I8 ~0 x' f
  8. tag_t line;6 A, l! i- _, B1 Y; E8 [+ X/ O
  9. line_coords.start_point[0]=0;# q% L1 F6 N4 z! n. x
  10. line_coords.start_point[1]=0;
    % K8 U. _* T3 B  H) p
  11. line_coords.start_point[2]=0;/ b' l& X: _0 P% L
  12. line_coords.end_point[0]=100;
    . F2 r/ P* `, L6 L( U
  13. line_coords.end_point[1]=100;  w# v8 a+ a/ [0 e# F' O9 _
  14. line_coords.end_point[2]=100;; o* A7 w. N3 E0 u
  15. UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc( E# b* `" k: z
  16. UF_CURVE_arc_t arc_coords;  F1 T5 n0 |4 c7 P6 n5 V1 g- d; j
  17. tag_t arc,marix,wcs;
    - \7 o! L2 `6 t
  18. UF_CSYS_ask_wcs(&wcs);
    % k4 P2 F! q& t: t, e
  19. UF_CSYS_ask_matrix_of_object(wcs,&marix);  }& _* e2 H" u. }) y; x: V
  20. arc_coords.arc_center[0]=0;5 X' Q) G; S; ?$ z
  21. arc_coords.arc_center[1]=0;/ v; |1 P: X5 g8 y& |9 S& i) w- a
  22. arc_coords.arc_center[2]=0;
    : _' z: P7 y: N! v$ R- A; W# c; Z
  23. arc_coords.start_angle=90*DEGRA;+ u; C4 y% ?9 S, B
  24. arc_coords.end_angle=270*DEGRA;
    ' y! w' ~- s6 \
  25. arc_coords.radius=100;
    * j2 @5 a5 O" w* p3 U  z2 y
  26. arc_coords.matrix_tag=marix;% q5 `8 K3 c9 k
  27. UF_CURVE_create_arc(&arc_coords,&arc);7 J& _1 ?+ l2 q, V4 e( @
  28. // create point
    . e$ {6 \9 {( p, w( I! o+ w/ i
  29. double point_coords[3]={100,100,100};. i7 o  a$ X6 C2 X" X# H
  30. tag_t point;) A7 ?1 D( [5 T  p
  31. UF_CURVE_create_point(point_coords,&point);( R, @4 E+ c- J5 p2 @' L' O

  32. 0 m8 N% N* a/ y5 B
  33. // create Plane
    , a/ ]9 p2 O1 s+ L- E
  34. double    origin_point[3]={100,100,100};
    ; W1 r/ b5 k. R# h& g9 y
  35. double    plane_normal[3]={1,0,0};: k0 R( u- N# t9 z& M0 O
  36. tag_t     plane_tag;    " _6 X9 H, s# E+ a
  37. UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*! x8 I4 e6 u0 b  v/ I+ d* z
  38. Get the curve information
    3 G$ U' t$ m3 H% S" k
  39.   */; B" F6 k5 A3 D" |8 i9 c1 }
  40. UF_UI_open_listing_window();
    ( X& P5 w% F* x3 {
  41. char msg[132];* D1 s2 X9 ^3 g* k0 L! ]" Q0 S
  42. // get line information+ C, H( C- ^6 s* C' C- }
  43. UF_CURVE_line_t line_info;4 H) u' N9 ?2 a) k9 a7 s* t- @4 i
  44. UF_CURVE_ask_line_data(line,&line_info);; s' K: O  l/ Z$ u' A& d% a; S
  45. sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],
    ; z0 P* R1 t5 U9 e3 P) ~9 J
  46.   line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],4 Q& I8 k& H% b% l. n1 u
  47.   line_info.end_point[2]);
    + G9 Q/ l  P5 _; J2 @( @6 m6 b
  48. UF_UI_write_listing_window(msg);( C, d# S5 Y3 N  Z# O% I
  49. //get the point information
    ; O5 b1 P7 q+ r" X9 H
  50. double point_info[3];0 M& s" z: a2 V! T5 _8 w% h
  51. UF_CURVE_ask_point_data(point,point_info);' g# G/ ^* A2 |' D& E. \: d
  52. sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);
    1 W4 M8 c* ~1 m1 d. M8 t
  53. UF_UI_write_listing_window(msg);</p><p> //get the arc information' V* [% a9 I, A/ M+ V8 p  z
  54. UF_CURVE_arc_t arc_info;
    4 M- |* t" S( J4 `5 x" `. C
  55. UF_CURVE_ask_arc_data(arc,&arc_info);# _4 H9 q8 V4 E& a# z; g
  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 r+ w3 U8 g: f$ ^
  57.   arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],8 m# N; q, i* q
  58.   arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius
    - ~" c6 e1 f# R3 J
  59.   );4 W0 {. |# U+ Y$ I
  60. UF_UI_write_listing_window(msg);4 m& m7 y: F* {9 k  G
  61. // calculate the arc length
    4 y! l) G( Q# @* s3 ]2 J6 }
  62. double arc_length;
    5 }* z8 a  v* e. w; F$ [8 _" l0 w8 |
  63. UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);9 }: N' ~0 M0 n: D' G
  64. sprintf(msg,"\nArc Length:\n\t%lf",arc_length);
    ; R5 ^9 D  h0 {$ K+ o
  65. UF_UI_write_listing_window(msg);1 s) B' H3 `/ A$ _
  66. }
    * c; I: Z' M; I$ w; [
  67. </p><p> </p>
复制代码

9 h# }) L* r6 A0 g- T* f
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了