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

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

[复制链接]

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

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

admin 楼主

2014-3-13 11:22:36

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

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

x
有关用户设置的使用,如果你想设置一个模版文件,可以通过下列方式:5 [3 R; _' F- J3 P8 g" L; ]
" p7 p3 E- E; M8 f6 ~8 d( R. M0 z
  1. 9 O8 P4 n6 z/ L% l- B
  2. #include <uf_defs.h>& G: H+ }% _3 Z) _8 \0 Y: ^) D
  3. #include <NXOpen/NXException.hxx># v; W, G+ Y; X( s  H, {3 a
  4. #include <NXOpen/Session.hxx>4 o! R+ X  V) i6 J0 Y4 [- G
  5. #include <NXOpen/Builder.hxx>- Y: K3 \+ m6 P  ~; I
  6. #include <NXOpen/FileNew.hxx>+ u" V/ @$ _2 a+ B6 N0 |: Z
  7. #include <NXOpen/NXObject.hxx>
    ! {. q" [' x8 M# K
  8. #include <NXOpen/Part.hxx>
    1 R2 `' M) Q% G  s6 D) F0 w! }6 L
  9. #include <NXOpen/ParTCollection.hxx>" a# g. `; g4 {3 Z* h% d
  10. #include <NXOpen/Preferences_PartPreferences.hxx>
    ( u+ S" l0 M# }3 _$ T* D; m, A- q
  11. #include <NXOpen/Preferences_PartSketch.hxx>! V  C4 E; h% \2 U# d9 R
  12. #include <NXOpen/Preferences_SessionPreferences.hxx>( {3 F$ V9 T) }8 D" M2 y
  13. #include <NXOpen/Preferences_SessionSketch.hxx>
    0 G) `" g1 I3 B! ~5 g
  14. #include <NXOpen/Preferences_WorkPlane.hxx>
    ) Y7 A4 Q. [& a6 m# M
  15. #include <NXOpen/Session.hxx>) h9 Z$ j" J( ^5 C
  16. using namespace NXOpen;
    / u! u  D  O- \$ `* ?

  17. ' U% a- _! i! P3 r
  18. extern "C" DllExport int ufusr_ask_unload()
    / `. V- y4 f( f; v. C
  19. {- a% P* \) C) D; ?8 [8 `
  20.     return (int)Session::LibraryUnloadOptionImmediately;
    . n, p$ t+ [! O+ @% J
  21. }
    6 F' |" u  O& j) W/ z" t: z' e& a
  22. & Z) o7 i0 L( ]) {! g( b
  23. extern "C" DllExport void ufusr(char *param, int *retCode, int paramLen). G8 Y$ V7 y- x) f
  24. {8 f+ p2 o/ ^7 |, ?, r
  25.     Session *theSession = Session::GetSession();! a0 S% X- V. W7 h9 b" N  i
  26. , c6 T: i+ l+ }: D8 q7 Y
  27.     //Creates New Part with name as Preferences.prt. o: V5 T, b5 a3 O/ a
  28.     NXOpen::Part *part1;
    $ P5 p$ i7 _6 A
  29.     part1=theSession->Parts()->NewDisplay("Preferences",Part::UnitsMillimeters);
    3 X* ?4 O. X; b, x% p
  30.     Part *workPart(theSession->Parts()->Work());
    5 W7 H+ n# i9 }) L& X
  31.     Part *displayPart(theSession->Parts()->Display());
    0 y/ C7 @" g: u% a( T
  32. 3 W' u3 _7 r% h& P7 z4 f' S/ L

  33. 2 i7 U0 |. C' `# T7 }9 L" Z

  34. 3 B' _8 a; N& k' V" U. E) U/ D
  35.     // ----------------------------------------------/ J' Y) {+ N8 M( O  n9 f* N
  36.     //  Changing Sketch Prefix names8 `- X$ |! e& e4 B8 l" ?9 W* K
  37.     // ----------------------------------------------   
    . R9 @1 C# j- r8 I$ r
  38.       
    - K- |" S! r; t6 D1 u# A
  39.     theSession->Preferences()->Sketch()->SetDefaultSketchNamePrefix("SKT_");
    / I  i1 c5 i9 s1 H
  40. 0 }! V! f: z- ~% E6 W7 W7 b' _
  41.     theSession->Preferences()->Sketch()->SetDefaultVertexNamePrefix("VRT_");6 \& X6 X4 ^$ `3 @, [" s

  42. 0 X1 t- o0 [0 z2 U
  43.     theSession->Preferences()->Sketch()->SetDefaultLineNamePrefix("LIN_");
    ( l; o) |. O* |" o

  44. ) q& y4 H' n$ K5 w, N: }" s
  45.     theSession->Preferences()->Sketch()->SetDefaultArcNamePrefix("ARC_");0 R0 s' f8 g. q; F

  46. ) A1 c7 F0 D; @, D
  47.     theSession->Preferences()->Sketch()->SetDefaultConicNamePrefix("CON_");, m+ b8 n. _6 f

  48. - L. {/ @8 W, I2 q5 O$ O5 J' x/ Y
  49.     theSession->Preferences()->Sketch()->SetDefaultSplineNamePrefix("SPL_");      
    $ T/ o! Z2 N% J4 P
  50.      I9 _6 ~3 [! }
  51.    
    ' L- |6 D( _9 r4 D7 F
  52.     // ----------------------------------------------
      e% A5 n4 e; ]7 q
  53.     //  Changing Grid values
    1 m$ R6 P# d- U6 T/ e  u5 @/ y/ @/ V
  54.     // ----------------------------------------------  
    7 c) m8 I( Y( f  C
  55.     $ d3 ]1 k  A; M5 ^& u. s
  56.     Preferences::WorkPlane *workPlane1;& z5 J5 Q- S4 g
  57.     workPlane1 = workPart->Preferences()->Workplane();9 c6 a& D$ [7 H9 R, F2 ^$ v
  58.     : ?6 l$ i0 D' m; ?
  59.     workPlane1->SetGridType(Preferences::WorkPlane::GridPolar);
    ; X* B% E# s2 y8 O: s4 `7 l  ?( ^
  60.     # _, r( A6 P4 w( ^
  61.     Preferences::WorkPlane::PolarGridSize polarGridSize1;
    1 H" b& f# \% G0 o; q
  62.     polarGridSize1.RadialGridSize.MajorGridSpacing = 75.0;3 }1 o: d- a$ \6 l5 `# L* O
  63.     polarGridSize1.RadialGridSize.MinorLinesPerMajor = 3;: ^7 Q2 I$ j# `; |4 _, e; p
  64.     polarGridSize1.RadialGridSize.SnapPointsPerMinor = 5;; l$ E1 t* W+ A) N& R  k& B
  65.     polarGridSize1.AngularGridSize.MajorGridSpacing = 45.0;8 d# O7 K5 F& {2 _8 s9 c
  66.     polarGridSize1.AngularGridSize.MinorLinesPerMajor = 4;0 F2 C4 M' p& Q% ~  F
  67.     polarGridSize1.AngularGridSize.SnapPointsPerMinor = 2;- i5 P& M; o( G7 S  E  O
  68.     workPlane1->SetPolarGridSize(polarGridSize1);2 B3 D- g" l5 x  C# j; R+ O
  69.    
    ! v- R! S0 _' T; R: x
  70.     workPlane1->SetShowGrid(true);
    2 j- R% m' Q) x- P
  71.     , c/ C; n; S% j
  72.     workPlane1->SetShowLabels(false);" z5 C1 @0 c' A( t
  73.    
    $ z* k7 f  c, j* i$ N5 j8 L
  74.     workPlane1->SetSnapToGrid(false);- J" A4 {. R& X# \) K
  75.       Q  a2 Q+ C% F. l
  76.     workPlane1->SetGridOnTop(false);
    : a0 \* M/ m9 ?  L1 ?  K
  77.    
    # A5 u+ x, G1 B
  78.     workPlane1->SetRectangularShowMajorLines(false);
    5 c% o7 w7 [5 u: W+ o0 X0 t
  79.    
    7 `( O- t- m: b6 T6 f
  80.     workPlane1->SetPolarShowMajorLines(true);
    6 u4 q4 n! L! i3 _* M
  81.     8 d" o, N/ j; x' ?6 N4 G8 G
  82.     workPlane1->SetGridColor(130);
    ; n- K9 b! E) B, _' ]- F
  83. }
复制代码
2 G* [4 }. l3 e3 o

6 {1 f/ y8 h; }( ^6 G
4 I- ]" l" i6 n6 J& l0 ]/ y& b' v* W
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了