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

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

[复制链接]

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

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

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

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

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

x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码4 R. ~& X1 F/ A( p& X

$ j: X# l4 N  ?5 ?
  1. <p>static void do_UGopenapi(). J' |) D7 h2 @& h3 v. O
  2. {' \' c$ v! c0 A' K# B( f
  3. /*
    ; S5 I/ c+ T* s$ q# g9 \% x  |
  4. Create Curve
    5 q2 [1 V+ A) N  p4 g* s9 m
  5. */
    $ Y8 _* o) j9 V5 d, i
  6. // create line# D" J% F" l4 f2 _1 s
  7. UF_CURVE_line_t line_coords;: ?3 C; Y( U7 d- Q
  8. tag_t line;$ J) _/ @. F) h( H) {& N
  9. line_coords.start_point[0]=0;  K$ g. r' S) r: P: O, o
  10. line_coords.start_point[1]=0;" i6 ?* E/ Q# G! S8 z
  11. line_coords.start_point[2]=0;
    : Z* c3 @. h4 C4 k
  12. line_coords.end_point[0]=100;) g' q5 ]2 ^% F( k* t/ z+ n
  13. line_coords.end_point[1]=100;
    . g% u9 k- }! y* X* Q+ O
  14. line_coords.end_point[2]=100;. S) ]# @* \3 @  w
  15. UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc$ M& k: s+ @% w( L* P1 P. {
  16. UF_CURVE_arc_t arc_coords;! V( o7 s0 d8 l% o: ]  [) X. y
  17. tag_t arc,marix,wcs;  ~' W; A; ~$ T7 I$ J
  18. UF_CSYS_ask_wcs(&wcs);- H1 h( i0 ]' w$ f( C# B
  19. UF_CSYS_ask_matrix_of_object(wcs,&marix);
    * {! s- W  `2 K; W, H" U* q5 ^
  20. arc_coords.arc_center[0]=0;
    . J. N4 L# @  F/ G8 N4 L1 H
  21. arc_coords.arc_center[1]=0;& S' n/ k( ^  A
  22. arc_coords.arc_center[2]=0;8 k( \. t$ v+ d& M3 C
  23. arc_coords.start_angle=90*DEGRA;! e" D/ K) x+ o5 L$ E2 y
  24. arc_coords.end_angle=270*DEGRA;& ~& G9 g' S# b' g- `+ `1 @
  25. arc_coords.radius=100;
    1 c1 w( t* E6 U% D
  26. arc_coords.matrix_tag=marix;
    . q/ C! W9 E0 x' [, I' ~5 j
  27. UF_CURVE_create_arc(&arc_coords,&arc);# Y& H4 B" t, g4 a" X
  28. // create point + o( x3 F4 s! [6 t, g- m
  29. double point_coords[3]={100,100,100};0 z1 P8 Z0 p2 v8 @# J1 e
  30. tag_t point;3 }- C: M  t& z" ?
  31. UF_CURVE_create_point(point_coords,&point);: L/ h7 F7 s3 }9 v  o
  32. 3 ]# o" _6 \4 E' n7 j
  33. // create Plane& S7 M( d( e9 a8 F; Y) x
  34. double    origin_point[3]={100,100,100};
    ! v! e4 M1 g+ E2 h4 T( b3 W1 |
  35. double    plane_normal[3]={1,0,0};
    9 i& o/ ?# ?3 i) r  `# ~+ H
  36. tag_t     plane_tag;   
    $ X  V- J! L: v, [# t  T7 x, Q- s
  37. UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*
    8 W% ^1 D/ }. J8 i* t
  38. Get the curve information5 D7 W' T( k9 A( i" T7 V
  39.   */2 S/ A; W' p& Y. n; j
  40. UF_UI_open_listing_window();
    # [: Q. S; ]; j* E& ^
  41. char msg[132];1 F1 C$ P! c  v: ~( y* l+ B
  42. // get line information9 w* e8 I% a) V5 M# h& d
  43. UF_CURVE_line_t line_info;
    ( o6 ^3 B) b0 P4 [5 j) _
  44. UF_CURVE_ask_line_data(line,&line_info);9 c( y9 H% p. D6 p9 z$ C5 f4 u
  45. sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],
    0 Z2 X; j: T  D
  46.   line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],/ R$ e/ b" `' U- s, t6 h2 r
  47.   line_info.end_point[2]);$ i/ S2 M. e0 k( R8 [
  48. UF_UI_write_listing_window(msg);
    3 E' x/ v  m3 e, g* f3 V$ W
  49. //get the point information7 e3 |+ y8 c. ~5 _8 Z
  50. double point_info[3];
      i& }, ^# B! C
  51. UF_CURVE_ask_point_data(point,point_info);
    8 H# P$ X2 H$ Y0 I  v& |8 u- L, A
  52. sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);
    0 G4 t0 ?# ?9 [: Q
  53. UF_UI_write_listing_window(msg);</p><p> //get the arc information
    2 }; P  u7 P& s* K/ Z& i6 y
  54. UF_CURVE_arc_t arc_info;
    $ X% Q+ u$ y: G1 j8 g' E: y; ~
  55. UF_CURVE_ask_arc_data(arc,&arc_info);
    9 O- {) s# \' ?
  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;",6 r& j6 d7 k% h6 D. [
  57.   arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],
    . x8 }4 E/ z: \4 M7 [  x$ n
  58.   arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius. u" D3 s  J" m# P" j- J
  59.   );4 n& D. l$ H( }$ N7 G  [! _
  60. UF_UI_write_listing_window(msg);
    ( r7 j6 e' N4 t0 ?- W% P
  61. // calculate the arc length) r; k3 U. v3 u
  62. double arc_length;
    8 \% v3 g9 f$ x( V3 ~# G6 s2 y6 r8 p/ K
  63. UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);
    4 K; h# [4 A% c1 j9 i0 H9 D
  64. sprintf(msg,"\nArc Length:\n\t%lf",arc_length);
    * _2 s- H6 c! {$ t
  65. UF_UI_write_listing_window(msg);
    ' k4 L3 x' G: m+ R9 I+ Y' B& K
  66. }5 T+ ]$ q$ m, A
  67. </p><p> </p>
复制代码

- N- L2 g& U7 R' P
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了