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

[二次开发源码] UG NX二次开发源码分享:有关用户设置方面的使用

[复制链接]

2014-3-13 11:22:36 3246 0

admin 发表于 2014-3-13 11:22:36 |阅读模式

admin 楼主

2014-3-13 11:22:36

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

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

x
有关用户设置的使用,如果你想设置一个模版文件,可以通过下列方式:
) y" [- ~- }0 {$ m$ T9 P5 D
* U6 r# `, r( ~; Y
  1. + t) }/ P# o+ C4 i& x
  2. #include <uf_defs.h>1 X' Q& E5 W/ B
  3. #include <NXOpen/NXException.hxx>; `) a4 S3 Y" N% H7 |+ `
  4. #include <NXOpen/Session.hxx>  L2 `" Q# j% H5 j7 u
  5. #include <NXOpen/Builder.hxx>
    $ J- [8 P; ?7 n  A8 j, u: J. {% m
  6. #include <NXOpen/FileNew.hxx>
    5 p; m6 g( p$ w; N* K0 p) a& e
  7. #include <NXOpen/NXObject.hxx>
    8 O, }# j  u: E3 G/ Z% O" U
  8. #include <NXOpen/Part.hxx>+ r+ B% B0 a3 j5 q' s! _
  9. #include <NXOpen/ParTCollection.hxx>: Z9 P5 B6 d) T* w+ H& c- S
  10. #include <NXOpen/Preferences_PartPreferences.hxx>. ]$ B9 Y) C) ^. w$ m) B
  11. #include <NXOpen/Preferences_PartSketch.hxx>
    % T1 d2 T& `$ z6 o# X/ ?3 n
  12. #include <NXOpen/Preferences_SessionPreferences.hxx>0 a) X8 F4 p; ^8 w" t8 }+ ?
  13. #include <NXOpen/Preferences_SessionSketch.hxx>1 ]' P( n; k5 i6 j/ K
  14. #include <NXOpen/Preferences_WorkPlane.hxx>
    4 [* |+ t6 {( {3 K! G8 B& N
  15. #include <NXOpen/Session.hxx>( }5 d4 U, S2 U7 I! ?' l* X: L
  16. using namespace NXOpen;8 Q9 D$ I1 m6 l; s2 h3 Y
  17. 6 m8 B# K$ j- U' d  c9 U$ V9 i
  18. extern "C" DllExport int ufusr_ask_unload()  }; P, E' k7 H" `* h- F. I
  19. {& O! j$ e/ R! i, U
  20.     return (int)Session::LibraryUnloadOptionImmediately;$ V4 T1 W; n* |5 Z& j: D
  21. }1 W! s: v6 s! G& N- M0 c# L

  22. 3 m3 S: ]) _: @* D/ K1 X6 u; @! i
  23. extern "C" DllExport void ufusr(char *param, int *retCode, int paramLen)
    $ f- M/ D7 N7 @8 `
  24. {/ G1 T; {1 y1 ~4 _5 t) `
  25.     Session *theSession = Session::GetSession();8 N4 _) {; F! }( H9 d8 x

  26. 6 q* s4 d  t. N5 K
  27.     //Creates New Part with name as Preferences.prt
    - ~' f3 ?! i, v
  28.     NXOpen::Part *part1;3 y8 Q: M4 x1 i( v
  29.     part1=theSession->Parts()->NewDisplay("Preferences",Part::UnitsMillimeters); . x( T0 ?( [; N: m8 I& g# r" ^* s3 a+ Q: Y
  30.     Part *workPart(theSession->Parts()->Work());5 Y* ^; w( F- A2 M& G' t
  31.     Part *displayPart(theSession->Parts()->Display());
    - l+ A4 f) h3 L1 `& y0 `+ ~( X
  32. 0 O: a8 [! w- J# T8 g" w

  33. : K+ C1 l8 @/ U, F
  34. * Z1 S2 R* _5 x9 ~$ Z2 @8 V
  35.     // ----------------------------------------------$ ?% L" U+ U7 i% B0 ^' W0 S/ l% D
  36.     //  Changing Sketch Prefix names+ N! O( g5 b! ?- j3 t9 b1 P: ~7 @
  37.     // ----------------------------------------------   % T  @7 C! n- w. P
  38.       
    4 m# Z3 a  G1 c+ c
  39.     theSession->Preferences()->Sketch()->SetDefaultSketchNamePrefix("SKT_");0 \; a7 z3 |, L4 P* h" E
  40. 1 \7 ?* h% o' d* B/ x1 J$ @( m
  41.     theSession->Preferences()->Sketch()->SetDefaultVertexNamePrefix("VRT_");
    , B6 ], X9 R! j4 W) a

  42. ) B3 f2 w9 f6 X  ]& C  y' v
  43.     theSession->Preferences()->Sketch()->SetDefaultLineNamePrefix("LIN_");3 F# @9 A# i" Z' Q4 z: ?* s

  44. : y" P4 L8 g/ X3 y
  45.     theSession->Preferences()->Sketch()->SetDefaultArcNamePrefix("ARC_");0 U9 \2 y0 c% o# Z
  46. 9 c: \  L! g7 |
  47.     theSession->Preferences()->Sketch()->SetDefaultConicNamePrefix("CON_");! D- S' I( @/ w9 ?4 u, w1 W
  48. . e6 U8 q  v" k8 O2 {4 S" p& t' c
  49.     theSession->Preferences()->Sketch()->SetDefaultSplineNamePrefix("SPL_");       ; y0 U7 l# \9 I
  50.      m6 \; V; B6 g( \" d# w: I2 A
  51.     ; m9 A4 Z& J0 r) P9 W- e( T- N
  52.     // ----------------------------------------------
      B; q# y# J* f) O
  53.     //  Changing Grid values
    ( I) U9 q% ~& j5 {; M: Z
  54.     // ----------------------------------------------  ( L. T0 R8 H" M$ F1 g' D! s# ^' |
  55.    
    ( Y8 r+ M! T, r7 m+ q
  56.     Preferences::WorkPlane *workPlane1;
    5 l# v+ c. z( _; X% J, L) q2 k
  57.     workPlane1 = workPart->Preferences()->Workplane();
    # n$ d! M( @% w- o: d  K0 O
  58.    
    ) E, v! A4 D( ]3 ~% F6 a- ]
  59.     workPlane1->SetGridType(Preferences::WorkPlane::GridPolar);- Y3 T; j' f  h) i7 b( ]* v
  60.    
    4 q( t) L; `8 y
  61.     Preferences::WorkPlane::PolarGridSize polarGridSize1;; U2 g2 t% q: f0 s
  62.     polarGridSize1.RadialGridSize.MajorGridSpacing = 75.0;
    8 T" X: H$ T- ~$ O
  63.     polarGridSize1.RadialGridSize.MinorLinesPerMajor = 3;/ z+ s, d: `4 o7 _+ d0 [
  64.     polarGridSize1.RadialGridSize.SnapPointsPerMinor = 5;. r, n: j8 K: M3 h
  65.     polarGridSize1.AngularGridSize.MajorGridSpacing = 45.0;* o# k  v+ u% }0 I7 B
  66.     polarGridSize1.AngularGridSize.MinorLinesPerMajor = 4;
    . A, F) y/ Y. F9 q
  67.     polarGridSize1.AngularGridSize.SnapPointsPerMinor = 2;
    ( Q; n8 s9 D6 M' Y: y
  68.     workPlane1->SetPolarGridSize(polarGridSize1);
    $ k% Z+ R/ B% }2 n
  69.     6 b7 Q5 o5 _. i# U. k
  70.     workPlane1->SetShowGrid(true);: r( ~- a# Y  D! o+ h
  71.     7 e  t# v4 V$ X, z7 z) u
  72.     workPlane1->SetShowLabels(false);4 N' \- D6 b- ]
  73.    
    - t. Y  a( L* s" ?2 S
  74.     workPlane1->SetSnapToGrid(false);7 m/ E% t/ M+ M& U& h
  75.     - l0 ]/ o1 B5 s, J7 R
  76.     workPlane1->SetGridOnTop(false);
    $ T& c- P: d7 ?' X
  77.    
    : |2 d- x7 ^( \: Z1 x
  78.     workPlane1->SetRectangularShowMajorLines(false);
    - |2 w* }# g' ~# T. y
  79.    
    3 D6 Q- R) E$ U+ H
  80.     workPlane1->SetPolarShowMajorLines(true);
    + ~% P" S' T; L
  81.     / F8 c; ^- R) n$ F
  82.     workPlane1->SetGridColor(130);
    # u5 f4 T% G3 d( i6 k+ i2 J
  83. }
复制代码

! p: Y( y3 G( X: e* c+ C1 J( ]7 x! z
; J6 f, q$ ^) y3 e
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了