PLM之家PLMHome-工业软件与AI结合践行者

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

[复制链接]

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

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

admin 楼主

2013-11-27 15:21:12

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

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

x
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码) n% ^! M4 t) v4 x- a
* Z! Y9 }0 K' @
  1. <p>static void do_UGopenapi()- u1 g) C8 h& y1 _! j
  2. {9 d5 X6 E* C; v2 n% D, F
  3. /*
    ) y& ]/ [* b2 o' ^
  4. Create Curve+ D7 Q  _0 x' A# v5 k
  5. */
    # u& B! B: {& B6 z9 ?4 p/ j3 P
  6. // create line0 N' C9 P: B9 j
  7. UF_CURVE_line_t line_coords;$ T; T& S  F! B# t! O% D
  8. tag_t line;2 n7 u5 D' N6 J6 p3 M
  9. line_coords.start_point[0]=0;* n- o' P9 |- \# l- S( `
  10. line_coords.start_point[1]=0;
    5 Y  D* M0 U  w$ o9 _( p
  11. line_coords.start_point[2]=0;; J- U# J2 Y# D9 d% H# B8 i
  12. line_coords.end_point[0]=100;" F+ K5 r: k1 r  ?
  13. line_coords.end_point[1]=100;
    1 z& H$ `8 t; f  Y( U% C
  14. line_coords.end_point[2]=100;
    ' J( g" I6 n% L2 t1 V/ n
  15. UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc* M8 K. \' n* U% _2 Z% P9 H
  16. UF_CURVE_arc_t arc_coords;& j6 P  K3 E5 M5 X% q9 f$ X6 G  `
  17. tag_t arc,marix,wcs;
    / `. @/ Q1 o/ h: L) r3 ]
  18. UF_CSYS_ask_wcs(&wcs);
    9 C0 w/ q+ }6 l; _6 e# F9 }
  19. UF_CSYS_ask_matrix_of_object(wcs,&marix);
    - S9 W+ m( Q+ V$ J1 V
  20. arc_coords.arc_center[0]=0;9 E) [) ^- Y% x2 k# h
  21. arc_coords.arc_center[1]=0;
    # r* m6 u$ r5 a; U1 W& I
  22. arc_coords.arc_center[2]=0;
    2 Q, v7 r) l8 h
  23. arc_coords.start_angle=90*DEGRA;- b& ?: H' q  P
  24. arc_coords.end_angle=270*DEGRA;! t- `  Q4 q2 f3 d
  25. arc_coords.radius=100;
    9 B. Y6 l, I9 X# ~
  26. arc_coords.matrix_tag=marix;) L% E4 R; t6 b
  27. UF_CURVE_create_arc(&arc_coords,&arc);6 F2 p, l$ g$ o7 ~
  28. // create point
    8 E' O: [$ {1 C, h
  29. double point_coords[3]={100,100,100};  {5 |- K$ v3 I+ F
  30. tag_t point;
    ( u6 ?& P4 `0 M: u( e: X
  31. UF_CURVE_create_point(point_coords,&point);
    - |) J4 S" K# N$ }5 z3 u
  32. 6 [4 F" \0 Z% D$ f
  33. // create Plane3 z5 E3 h# k* F9 s! v( y
  34. double    origin_point[3]={100,100,100};
    3 _5 S* m8 Z) a1 m  G
  35. double    plane_normal[3]={1,0,0};
    0 w; G! ?/ _, |- G1 b
  36. tag_t     plane_tag;    9 d- u  x( f. \8 Z* o" g
  37. UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*+ r8 f8 X- T2 d# M6 I
  38. Get the curve information
    % z3 ]3 o- W+ _. y! A
  39.   */; p* }1 r! Q) i! c0 }9 z/ F: t: m* D
  40. UF_UI_open_listing_window();
    5 @! d) S& ^  o5 ?: C/ X! k
  41. char msg[132];
    , n( a4 }/ O1 @# v; ~
  42. // get line information
    , r( G3 N) k5 F) R4 ^
  43. UF_CURVE_line_t line_info;7 }( V* b' j* ?$ I
  44. UF_CURVE_ask_line_data(line,&line_info);8 L' N! f! o% I! @5 w6 t
  45. sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point[0],
    9 B: X5 \7 s$ `! B$ p7 ~. P
  46.   line_info.start_point[1],line_info.start_point[2],line_info.end_point[0],line_info.end_point[1],
    3 v6 b5 d! j8 S% W3 V0 k/ z* J
  47.   line_info.end_point[2]);
    1 u. y+ O/ E! Y3 v7 l" n
  48. UF_UI_write_listing_window(msg);8 y1 x( \, ^9 k- t4 s/ H
  49. //get the point information$ _: z3 j+ a7 Z4 Z- Z! B9 B% K
  50. double point_info[3];& l# P) K1 k: _1 O" K" g2 j
  51. UF_CURVE_ask_point_data(point,point_info);
    ; X8 m) h2 H7 g+ I
  52. sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info[0],point_info[1],point_info[2]);
    3 U7 c: A! }+ V6 |0 B. D
  53. UF_UI_write_listing_window(msg);</p><p> //get the arc information3 l5 G1 B  l+ N$ o1 B
  54. UF_CURVE_arc_t arc_info;
    3 l/ q2 b1 X$ b+ X
  55. UF_CURVE_ask_arc_data(arc,&arc_info);) }, x6 ^9 w9 S7 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;",* W# ~3 `* L% @9 V5 X1 K8 X- T
  57.   arc_info.arc_center[0],arc_info.arc_center[1],arc_info.arc_center[2],
    " q. D0 L3 S3 Y! x1 ]
  58.   arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius
    : B5 ~) r9 v1 j4 o  O6 t
  59.   );" i! L4 N7 h$ @. K: g* `
  60. UF_UI_write_listing_window(msg);
    * N7 G4 U3 R$ [( c& p
  61. // calculate the arc length
    ) L6 p, |+ o; @
  62. double arc_length;+ i& |3 u+ w# ?( ^3 y
  63. UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);; _0 I2 Q1 [0 w
  64. sprintf(msg,"\nArc Length:\n\t%lf",arc_length);, L& |! ]  g3 U
  65. UF_UI_write_listing_window(msg);  V5 e! A+ u6 p
  66. }" V6 P2 X: e1 _: X6 S, \9 G' `# a- t
  67. </p><p> </p>
复制代码
& U/ d! @# i+ t( L: m, W
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了