查看: 3133|回复: 0

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

[复制链接]

4

主题

3

回帖

40

积分

管理员

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

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

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

×
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码) r  o% S1 i" _) V
8 D; S( G. V( m7 R7 n3 [
  1. <p>static void do_UGopenapi()/ r  d; l8 s' v' P; o
  2. {
    0 M. e. h; Z, X' G+ S7 L
  3. /*! c, T2 m4 {- x
  4. Create Curve
    1 X1 N! a- A+ R+ @( f+ R
  5. */
    ; `5 F3 |7 h$ ]# I$ \# R
  6. // create line
    - W  A% ~* R/ j, l7 N# S
  7. UF_CURVE_line_t line_coords;
    ; K  M: s8 l  L3 M
  8. tag_t line;* b; m; g; u) _+ B
  9. line_coords.start_point[0]=0;/ a) ]& I0 e' U
  10. line_coords.start_point[1]=0;, o$ O) R0 V, ~* W/ V$ j7 c
  11. line_coords.start_point[2]=0;
    + D- s0 k) V3 u; m6 U8 [6 L! ~! a
  12. line_coords.end_point[0]=100;
    ) n5 b: h, Q  l, ^6 m2 v! a
  13. line_coords.end_point[1]=100;
    $ n$ q5 M' f9 w2 Z9 X1 X% j4 m( `
  14. line_coords.end_point[2]=100;- F$ J5 ^7 y3 P8 V
  15. UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc
    # u  e2 D, o6 y; b
  16. UF_CURVE_arc_t arc_coords;
    / L" @* q" w1 @+ C! E& V
  17. tag_t arc,marix,wcs;( {* u9 f' `0 B  u2 g& S
  18. UF_CSYS_ask_wcs(&wcs);6 h: S% `7 f4 v0 f8 q5 O
  19. UF_CSYS_ask_matrix_of_object(wcs,&marix);5 O  L6 v# F: t- ^4 j; H& }
  20. arc_coords.arc_center[0]=0;
    8 ]* r% ]4 `/ y9 c" f
  21. arc_coords.arc_center[1]=0;; [4 S% D. L7 i
  22. arc_coords.arc_center[2]=0;* ~5 Z) a4 k0 \1 p9 S
  23. arc_coords.start_angle=90*DEGRA;0 [) _/ m( [# ?# b0 t
  24. arc_coords.end_angle=270*DEGRA;8 \' i% h( s0 y* R
  25. arc_coords.radius=100;
    & @$ t) i! {5 U( T8 t) ?
  26. arc_coords.matrix_tag=marix;
    & {7 s8 L) l( k' m& K
  27. UF_CURVE_create_arc(&arc_coords,&arc);
    , ?0 T& E7 y" Y* U  ~
  28. // create point
    5 v* K) f6 ~7 A% u  d
  29. double point_coords[3]={100,100,100};6 o3 N- f6 J, T5 f, z
  30. tag_t point;, X6 P! ~' S3 `
  31. UF_CURVE_create_point(point_coords,&point);) D. U7 D0 h$ x: g9 Q6 N5 w

  32. 9 Z7 D  P- b3 V3 `
  33. // create Plane% K5 M# A' V% [! D: j+ A
  34. double    origin_point[3]={100,100,100};  [& Z8 D; h( a" ~* k
  35. double    plane_normal[3]={1,0,0};" ^1 X# f4 D/ l
  36. tag_t     plane_tag;    0 \* I; k' \; l+ V) V% j
  37. UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*! z) t  C" e# Z9 j2 N
  38. Get the curve information
    . o* A/ \! N% s+ o$ G# ~( q
  39.   */; w$ f7 u% c9 d9 M; u  @5 S
  40. UF_UI_open_listing_window();
    7 `  s2 t% u& J; ]5 `' \
  41. char msg[132];
    2 q3 f8 Y2 Y8 `3 d9 q
  42. // get line information0 Z5 x8 t( i2 i5 o. q' [9 w& Y9 }
  43. UF_CURVE_line_t line_info;
    8 W" B! d7 x9 h/ Z6 `
  44. UF_CURVE_ask_line_data(line,&line_info);
    % |9 P4 H% y+ A' b; P
  45. sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],
    . W- b- i- q3 O! R% V
  46.   line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],
    9 g- h+ Z4 t8 i" t7 _4 U
  47.   line_info.end_point[2]);4 X1 E* y* ~; J( Z
  48. UF_UI_write_listing_window(msg);# S! L6 A2 w# d) D/ v5 j6 \9 J5 E* g
  49. //get the point information
    6 g$ w% e( f' B/ b
  50. double point_info[3];
    0 }3 z' A# y9 W2 K8 s- ^* \8 n, j( j' \
  51. UF_CURVE_ask_point_data(point,point_info);
    ( I: ?! }" z( k& ?  P" s
  52. sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);" v# }9 Y% d. M- H' h2 V; {+ c; o
  53. UF_UI_write_listing_window(msg);</p><p> //get the arc information1 v, B+ N9 `9 j1 g: ?3 E
  54. UF_CURVE_arc_t arc_info;7 ^1 P4 Q7 G6 ~
  55. UF_CURVE_ask_arc_data(arc,&arc_info);& i1 D( I% {' G6 d) S5 x. X- B% M! P
  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;",
    ( a( l; y& T* Y* ]" f. N$ b$ n
  57.   arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],
    * L0 Y# D  x( p& D4 N6 @4 o
  58.   arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius
    6 Y+ }( Y3 Q/ y2 e
  59.   );
    5 f8 \; z" w, X( K6 q4 G) k5 I5 x
  60. UF_UI_write_listing_window(msg);
    0 x3 w+ ]& h# U4 E2 G2 u% T6 ^
  61. // calculate the arc length& p9 z9 x; M$ e) A- s
  62. double arc_length;
    ( j4 O: e5 d; I( Z1 O) n* l
  63. UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);. ?& R9 G6 c' x
  64. sprintf(msg,"\nArc Length:\n\t%lf",arc_length);4 [' {' j* S" j5 a  h1 _' B- q
  65. UF_UI_write_listing_window(msg);
    1 w2 ]8 q% O5 p. ^% n( C
  66. }
    $ t/ ]! E4 ]3 w+ j# p
  67. </p><p> </p>
复制代码
. M1 F. Q1 {1 X: S) `: v0 i. @# U
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

在本版发帖
关注公众号
QQ客服返回顶部