PLM之家PLMHome-国产软件践行者

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

[复制链接]

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

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

admin 楼主

2014-3-13 11:22:36

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

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

x
有关用户设置的使用,如果你想设置一个模版文件,可以通过下列方式:: A; p) r" B/ H( X8 i: Y0 I

: Q6 e+ N  V; H# R% r+ A

  1. 5 L/ I) N' i$ f( ^% C, ]
  2. #include <uf_defs.h>
    ) N2 F& U4 {* P% I4 I( @' T
  3. #include <NXOpen/NXException.hxx>
    ! X9 v& }4 W) b$ _# Z6 }; P
  4. #include <NXOpen/Session.hxx>! a7 B  `5 J- w9 E& x$ L5 U
  5. #include <NXOpen/Builder.hxx>
    ' E2 u4 E9 r; c* x4 _; q* A$ |+ ~
  6. #include <NXOpen/FileNew.hxx>7 b1 `1 R9 c3 @
  7. #include <NXOpen/NXObject.hxx>) c  C; o: F0 T5 o6 U  a6 V  w
  8. #include <NXOpen/Part.hxx>
    : V. u0 d* M- T4 u3 o
  9. #include <NXOpen/ParTCollection.hxx>" j/ Z" ?" g" C- g- H0 m9 a
  10. #include <NXOpen/Preferences_PartPreferences.hxx>" t+ w0 w: a2 y5 M9 H- R
  11. #include <NXOpen/Preferences_PartSketch.hxx>' c. C# h. ]( u; e# A
  12. #include <NXOpen/Preferences_SessionPreferences.hxx>
    # W; N, e7 d4 C  }
  13. #include <NXOpen/Preferences_SessionSketch.hxx>
    6 k; @& v  ~9 g6 K, N
  14. #include <NXOpen/Preferences_WorkPlane.hxx>) k6 s' \' A( {' u
  15. #include <NXOpen/Session.hxx>
    0 G, k% `2 X( f: U' p% w
  16. using namespace NXOpen;2 X% g3 i! G5 A+ |+ C

  17. 3 ^" G! U* E% X+ m0 q8 j
  18. extern "C" DllExport int ufusr_ask_unload()" E+ w5 X, k. a# G3 |0 }
  19. {
    " s5 a2 h0 T$ O, O  E6 f0 [1 H; V; |
  20.     return (int)Session::LibraryUnloadOptionImmediately;
    3 \& E% Z3 _: ?1 ?6 h7 F
  21. }" x/ M$ B# y  f& f
  22. 3 l9 A+ d2 }! x, |; w) F- [3 w
  23. extern "C" DllExport void ufusr(char *param, int *retCode, int paramLen)7 c( u' Z" i& Y# a+ s  X+ R
  24. {4 [1 c4 R# A1 O2 V8 [
  25.     Session *theSession = Session::GetSession();% f  m3 `* G+ o" n0 r8 |9 W

  26. * H+ K, i6 U" i9 v
  27.     //Creates New Part with name as Preferences.prt) b7 N/ I" k7 s6 a
  28.     NXOpen::Part *part1;- h7 g  j! k3 x1 t
  29.     part1=theSession->Parts()->NewDisplay("Preferences",Part::UnitsMillimeters);
    4 S, f2 R! q2 O: \+ \$ I
  30.     Part *workPart(theSession->Parts()->Work());
    # ~, Y% l: c$ _$ k" I
  31.     Part *displayPart(theSession->Parts()->Display());
    " e( ~2 z0 p: b5 e/ j( ?& `! U
  32. 3 d- j3 e. k" E* n$ n$ D9 s  ]
  33. 5 i' Z% |6 Z# B# {0 y2 ~, p4 k2 R. Y
  34. & u2 c. N. Q% A5 B: c
  35.     // ----------------------------------------------+ o9 M* }$ n# Y0 _6 U/ g
  36.     //  Changing Sketch Prefix names* ]  d$ o7 Z3 B( }- w
  37.     // ----------------------------------------------   : i+ D& i' ~# W8 t, [+ \; j( E
  38.       % ?" L. I3 ~5 i5 R; }
  39.     theSession->Preferences()->Sketch()->SetDefaultSketchNamePrefix("SKT_");
    6 G; m) I# d& m/ _. j/ s
  40. " Q- [0 [. U2 U( v( X# K% r$ l
  41.     theSession->Preferences()->Sketch()->SetDefaultVertexNamePrefix("VRT_");
    & ?6 v% e# @1 r. X* X$ z

  42. 0 m. |' f* T6 A+ i+ C9 Q  J0 w
  43.     theSession->Preferences()->Sketch()->SetDefaultLineNamePrefix("LIN_");
    5 ~1 {$ j8 n4 J# J5 c. Y

  44. / x- O/ K' u+ G9 f
  45.     theSession->Preferences()->Sketch()->SetDefaultArcNamePrefix("ARC_");
    + t8 b: D% A" Y8 K) ?$ O9 k/ k5 A

  46. 0 U$ B6 y6 P8 G
  47.     theSession->Preferences()->Sketch()->SetDefaultConicNamePrefix("CON_");
    ( k* k2 Z) N9 `! C& c/ i& x
  48. " G5 w5 \+ c% W, c! A6 y' L
  49.     theSession->Preferences()->Sketch()->SetDefaultSplineNamePrefix("SPL_");       ( x8 w* n! t8 C: g2 o0 V$ u
  50.    8 ?( A' V) p$ n4 n
  51.    
    6 N# {& C+ z5 J1 L9 a
  52.     // ----------------------------------------------
    $ C. o% a8 U6 l4 J' ^1 m; J
  53.     //  Changing Grid values
    & w% u( u: ]! }  {4 z! L) H2 C
  54.     // ----------------------------------------------  3 v+ c1 o; D7 x
  55.    
    9 }4 u( R9 V: z8 }' g. r! l
  56.     Preferences::WorkPlane *workPlane1;' S* s# L* N( Q' R) [
  57.     workPlane1 = workPart->Preferences()->Workplane();$ j5 C/ Q% q, i2 J
  58.    
    + a! z& e" p0 i# {% j2 b5 k
  59.     workPlane1->SetGridType(Preferences::WorkPlane::GridPolar);
    6 y" `( S8 E) J& T/ B4 A4 V1 s
  60.    
    : N, U. k. S7 N* r; _
  61.     Preferences::WorkPlane::PolarGridSize polarGridSize1;! y8 o6 m+ D' E3 g) I. @
  62.     polarGridSize1.RadialGridSize.MajorGridSpacing = 75.0;! X& D! d7 P0 W: j9 L4 J
  63.     polarGridSize1.RadialGridSize.MinorLinesPerMajor = 3;3 j: f1 M$ y6 N0 ]. q& u4 S0 n5 J
  64.     polarGridSize1.RadialGridSize.SnapPointsPerMinor = 5;, P0 L+ I) V  c/ _( o2 o
  65.     polarGridSize1.AngularGridSize.MajorGridSpacing = 45.0;( e- G, E3 k, i7 }3 g4 ^
  66.     polarGridSize1.AngularGridSize.MinorLinesPerMajor = 4;# W7 t1 S5 L' R9 U
  67.     polarGridSize1.AngularGridSize.SnapPointsPerMinor = 2;
    ; a# M0 v6 ?/ P  t8 n' w
  68.     workPlane1->SetPolarGridSize(polarGridSize1);
    & X1 Q+ a9 j4 n. V2 t
  69.     8 u1 \. A3 ~2 G7 g2 j4 ?
  70.     workPlane1->SetShowGrid(true);
    % x2 a; P; G! l+ ]3 M) ^; ^% ~
  71.     - I# w# \) G: e
  72.     workPlane1->SetShowLabels(false);
      s6 L! \% R7 {
  73.    
    0 T  M1 M9 S9 E; e9 y2 N6 d/ v# u+ R$ _
  74.     workPlane1->SetSnapToGrid(false);
    . C9 h/ {# x0 C- _3 p: _6 V
  75.    
    0 @* f/ S! D( C) o4 m  G7 v
  76.     workPlane1->SetGridOnTop(false);
    8 }1 t' q! ^/ E
  77.     - S! C9 A6 b: ^
  78.     workPlane1->SetRectangularShowMajorLines(false);
    3 t  N+ i" h3 D; y" j! M
  79.     5 u+ g2 x  X: c! B* @  h! ^) [! r% H7 W) E
  80.     workPlane1->SetPolarShowMajorLines(true);
    ) [; _/ U; ]% L) H5 j) c$ |
  81.     / p6 e  _/ F* ~/ l
  82.     workPlane1->SetGridColor(130);
    8 l" v( b8 ^* |6 t8 o9 }* }. v
  83. }
复制代码

7 T- k& S0 m; I  Y, [1 Y7 E% S8 ?/ n" ]% K! F! ^4 y
' Z" Z, d/ O+ S. k/ E+ \$ ?, A
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了