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

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

[复制链接]

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

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

admin 楼主

2014-3-13 11:22:36

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

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

x
有关用户设置的使用,如果你想设置一个模版文件,可以通过下列方式:
3 q2 G2 p9 M0 t9 F/ U
, m  q/ W5 l+ D, ~' p

  1. 9 Z' t; R0 G6 X  o
  2. #include <uf_defs.h>
    9 \5 j8 E0 ^1 w, Y  A' w
  3. #include <NXOpen/NXException.hxx>
    ( @. [4 O9 C  D/ F, G
  4. #include <NXOpen/Session.hxx>; G5 r& T" N; c
  5. #include <NXOpen/Builder.hxx>
    / y1 R& }. a" J4 b. S6 j0 d: U4 F; `0 V
  6. #include <NXOpen/FileNew.hxx># m; x; m, B5 r6 a+ I
  7. #include <NXOpen/NXObject.hxx>
    4 e, m" T# V6 a
  8. #include <NXOpen/Part.hxx>
    % q9 m" ^) B" T9 c. R2 t. f
  9. #include <NXOpen/ParTCollection.hxx>) s0 v2 x$ x% |  }& D1 {; h
  10. #include <NXOpen/Preferences_PartPreferences.hxx>
    : t# p: h% s- p" `* [- s
  11. #include <NXOpen/Preferences_PartSketch.hxx>
    + ?# ?' ~1 d5 ]5 R7 d# x* ]
  12. #include <NXOpen/Preferences_SessionPreferences.hxx>
    + {% _& r7 \% ?* `
  13. #include <NXOpen/Preferences_SessionSketch.hxx>
    : I4 l9 l+ N2 K5 ^9 A
  14. #include <NXOpen/Preferences_WorkPlane.hxx>
    $ \7 t* [# v, ~+ ~3 M: K) K" z; p
  15. #include <NXOpen/Session.hxx>
    % p3 ?  |) _) b# u5 T) `7 K
  16. using namespace NXOpen;
    & J: e8 T: [) W( F( z# H

  17. + n5 f6 M0 J9 p" t. N- `
  18. extern "C" DllExport int ufusr_ask_unload()
    - C# E# ~' ?6 `
  19. {5 P! s3 G; F2 Q* U
  20.     return (int)Session::LibraryUnloadOptionImmediately;
    6 h: V+ i1 S0 x- A6 ?
  21. }
    . q/ o* _1 v/ o% ?+ [
  22. ) B6 p+ @& o4 l* g. v/ b$ ~( F2 O
  23. extern "C" DllExport void ufusr(char *param, int *retCode, int paramLen)
    5 u6 W) ^0 g& v* K
  24. {& q% y7 Q1 {' P  c5 [
  25.     Session *theSession = Session::GetSession();
    - W8 H) _# {0 M. R$ u  E- ?

  26. 0 a9 \2 _; d. B( o# `9 g/ A2 d
  27.     //Creates New Part with name as Preferences.prt
    $ ~2 {0 L$ T+ A& E
  28.     NXOpen::Part *part1;8 z7 o5 p. ~# h, I+ `
  29.     part1=theSession->Parts()->NewDisplay("Preferences",Part::UnitsMillimeters);
    3 c/ a; ]( Z9 E+ b7 m- K
  30.     Part *workPart(theSession->Parts()->Work());0 k0 `1 V# Q2 a" R5 T# `
  31.     Part *displayPart(theSession->Parts()->Display()); 8 [- A( @, q7 J3 J
  32. 5 h) j9 M0 t# |: v+ D( r" Y( Q
  33. 1 ~$ C: H- U# g
  34. 3 Z/ U, j) F# G8 [. T$ O2 U
  35.     // ----------------------------------------------4 g- {$ u3 C" Y: U
  36.     //  Changing Sketch Prefix names
    0 ?! h, s# A2 l" U: O
  37.     // ----------------------------------------------   
    4 J& d% _3 ^1 o8 R; s
  38.       3 o. ^( y( j5 T: D% U
  39.     theSession->Preferences()->Sketch()->SetDefaultSketchNamePrefix("SKT_");
    & A: m% ]  Y; v
  40. 6 k& _3 v. P7 z( h
  41.     theSession->Preferences()->Sketch()->SetDefaultVertexNamePrefix("VRT_");
    / w( \! |9 ?. j6 V3 j
  42. - D% w; q" X3 M2 G* J/ m
  43.     theSession->Preferences()->Sketch()->SetDefaultLineNamePrefix("LIN_");
    9 F- \- l9 F1 r+ I7 Z
  44. 3 n" Q) g7 t# a# ]3 p
  45.     theSession->Preferences()->Sketch()->SetDefaultArcNamePrefix("ARC_");
    : O& q/ H. u8 O5 M, M2 Q( a0 g

  46. # u1 X* r; B+ o3 ]
  47.     theSession->Preferences()->Sketch()->SetDefaultConicNamePrefix("CON_");4 E: {* {& a; G+ g0 @1 }
  48. - ?) v* l/ C: X
  49.     theSession->Preferences()->Sketch()->SetDefaultSplineNamePrefix("SPL_");      
    6 Y' ~% {( d' G$ Z6 ^
  50.    
    0 j. e4 G8 h: R
  51.     . m+ d4 e3 @+ n8 m7 W* |" z
  52.     // ----------------------------------------------  T% t4 L  ]8 A
  53.     //  Changing Grid values
    & u5 |/ `" B2 d& V
  54.     // ----------------------------------------------  
    ' Y6 D. d" C2 Y# f4 B/ ?, z
  55.    
    9 m5 Q) l4 |: ~  ]4 w
  56.     Preferences::WorkPlane *workPlane1;
    # l7 ~: Z! `  q
  57.     workPlane1 = workPart->Preferences()->Workplane();
    8 {" V3 e! p9 O
  58.    
    9 I8 h& I. N. t" k
  59.     workPlane1->SetGridType(Preferences::WorkPlane::GridPolar);2 @& F  I( K3 G7 a: b
  60.     7 ?! _" q* Z. M
  61.     Preferences::WorkPlane::PolarGridSize polarGridSize1;8 F! ?+ N. p" }- @0 _3 }1 V
  62.     polarGridSize1.RadialGridSize.MajorGridSpacing = 75.0;+ R6 v1 N4 j& F
  63.     polarGridSize1.RadialGridSize.MinorLinesPerMajor = 3;6 _, h2 S" F$ R' b9 N: L
  64.     polarGridSize1.RadialGridSize.SnapPointsPerMinor = 5;
    , \# E) I, z# N4 l3 @, x5 B
  65.     polarGridSize1.AngularGridSize.MajorGridSpacing = 45.0;
    ; \$ i9 C. J) b" C; {& K; A
  66.     polarGridSize1.AngularGridSize.MinorLinesPerMajor = 4;2 X" z1 v: S  Q- K
  67.     polarGridSize1.AngularGridSize.SnapPointsPerMinor = 2;5 v1 e" o; {2 {6 i: I
  68.     workPlane1->SetPolarGridSize(polarGridSize1);
    ' l6 N  s8 t$ m6 ?( y: o8 |
  69.     ( P, {& t. b) H6 m3 Z
  70.     workPlane1->SetShowGrid(true);3 S, S! a( f9 M: T* T0 Z" [
  71.    
    + E$ n% N- E7 [! s; ]
  72.     workPlane1->SetShowLabels(false);
    % H3 y9 v0 _# Y1 Q/ R+ {7 y
  73.     3 p4 a! T3 t0 ~) c% y3 Q* d
  74.     workPlane1->SetSnapToGrid(false);. {( S/ ]- O+ G6 R- o  b. `
  75.     : F) h5 U7 B4 g$ {0 _/ P' i: O6 U
  76.     workPlane1->SetGridOnTop(false);; I! j2 a# G6 S3 L- \
  77.     2 R! B5 j( C/ I
  78.     workPlane1->SetRectangularShowMajorLines(false);+ b/ b* H1 {/ b+ `! T; ?$ a* b6 J
  79.     " u  t+ O. n% m0 ~* q8 W
  80.     workPlane1->SetPolarShowMajorLines(true);, d+ B8 d% E5 K( w
  81.    
    * j( O( l8 s" k! q/ z2 p, X
  82.     workPlane1->SetGridColor(130);
    " ?, J. C6 `: I) f6 c) e3 [8 m
  83. }
复制代码
! T5 l. a8 [* z+ @. {

% g" U* ~4 E7 [% X/ o7 W
* T) Y+ o1 }' J/ U8 D
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了