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

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

[复制链接]

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

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

admin 楼主

2014-3-13 11:22:36

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

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

x
有关用户设置的使用,如果你想设置一个模版文件,可以通过下列方式:" H) `; j# q8 @: ]

2 t) n, X  ~, d3 r

  1. " h  A1 X5 }3 X; T! v1 O0 R
  2. #include <uf_defs.h>1 C+ b0 Y8 ^9 K. G8 [) z' w& H
  3. #include <NXOpen/NXException.hxx>
    , r5 s' @4 w7 R
  4. #include <NXOpen/Session.hxx>, m2 G. a9 b2 `3 s2 }( |
  5. #include <NXOpen/Builder.hxx>
    ; R2 X0 i  Z" _- V$ P
  6. #include <NXOpen/FileNew.hxx>
      R( a  h+ y5 O
  7. #include <NXOpen/NXObject.hxx>
    , y6 _7 G" i9 A1 K8 J/ Z+ `
  8. #include <NXOpen/Part.hxx>
    ' a& X. J$ }3 d2 j& H! F
  9. #include <NXOpen/ParTCollection.hxx>
    2 [+ M) v6 E- H
  10. #include <NXOpen/Preferences_PartPreferences.hxx>  j$ G3 X9 _% I
  11. #include <NXOpen/Preferences_PartSketch.hxx>0 [9 k- {0 l" S& {- G
  12. #include <NXOpen/Preferences_SessionPreferences.hxx>
    # o* w* u$ C$ m+ f* W, j
  13. #include <NXOpen/Preferences_SessionSketch.hxx>
    ) N7 a; Q+ u  \. a0 m6 [
  14. #include <NXOpen/Preferences_WorkPlane.hxx>
    . w/ c" e' C; k$ a9 I) p; m  ?
  15. #include <NXOpen/Session.hxx>8 A3 d: }0 u1 F, G2 w6 I: y  |7 [' W
  16. using namespace NXOpen;
    - u! `8 w- Q' n

  17. % T8 o0 h6 ?( V* y
  18. extern "C" DllExport int ufusr_ask_unload()+ t% Z4 |* W- M
  19. {1 y6 F. k4 K6 _% b: l
  20.     return (int)Session::LibraryUnloadOptionImmediately;
    & _6 X6 u5 {8 M2 ~% o8 s
  21. }
    5 U' F8 f5 e) F  V- x
  22. 0 b# {  |  v/ N% z2 ~- L+ C
  23. extern "C" DllExport void ufusr(char *param, int *retCode, int paramLen)
    2 f8 i4 q% Z& Y; ?# U5 Y
  24. {
    - N# ^4 i% j+ o; z
  25.     Session *theSession = Session::GetSession();
    $ r5 Y1 y7 w/ A; L# }9 N! J
  26. # n1 ^7 ~* P2 b* K% ~
  27.     //Creates New Part with name as Preferences.prt
    6 ?+ ^2 s3 w# N. B! k
  28.     NXOpen::Part *part1;$ T0 C8 z) `* o1 z
  29.     part1=theSession->Parts()->NewDisplay("Preferences",Part::UnitsMillimeters);
    : \. g8 e: [, o5 h8 J! u
  30.     Part *workPart(theSession->Parts()->Work());
    1 }* f5 y+ S+ T4 r" Z8 \8 l
  31.     Part *displayPart(theSession->Parts()->Display()); * ?; [1 r* n8 e3 w! L8 z/ _

  32. ' a, D; J5 h! b2 c0 |8 V
  33. 4 h2 V$ P+ h- R; L; H

  34. ( n) l4 M8 L* j
  35.     // ----------------------------------------------- F& I* Z" m- x$ m& o0 M, e
  36.     //  Changing Sketch Prefix names: v% @: l9 h: _0 _( i& ^$ p
  37.     // ----------------------------------------------   6 d% A8 z3 s5 C4 H/ W
  38.       
    + ^1 Z. d) a! d# x# d0 N
  39.     theSession->Preferences()->Sketch()->SetDefaultSketchNamePrefix("SKT_");
    7 Y9 A7 @8 C0 {$ T
  40. " i1 ]8 T2 v7 r" `
  41.     theSession->Preferences()->Sketch()->SetDefaultVertexNamePrefix("VRT_");5 C# N" d+ e7 p4 S' |
  42. 4 a, w+ D" J3 r& L& L
  43.     theSession->Preferences()->Sketch()->SetDefaultLineNamePrefix("LIN_");) s8 @" M/ W2 _" X) M- Q; s: P

  44. : `1 n+ k$ I- G; R( H3 e4 h
  45.     theSession->Preferences()->Sketch()->SetDefaultArcNamePrefix("ARC_");
    % b3 V+ c+ V- x) j' U4 ^1 ^
  46. 0 N# X5 }& K6 B: j! ?3 b
  47.     theSession->Preferences()->Sketch()->SetDefaultConicNamePrefix("CON_");! p& M) k) X. h. d" {) J
  48. 5 d& N% h2 d3 b9 N2 C1 K6 }
  49.     theSession->Preferences()->Sketch()->SetDefaultSplineNamePrefix("SPL_");      
    : s2 N0 f# a2 r4 W
  50.    
    ' x7 O% \( S; t) e* N/ n
  51.    
    3 b+ _% ^: U" |1 j
  52.     // ----------------------------------------------( P6 c, X+ K" K$ K" J% k( A' @
  53.     //  Changing Grid values
    + m1 y# F' B/ H
  54.     // ----------------------------------------------  
    6 b" ^; H4 H. t: u0 J% J$ `( q
  55.     5 j8 e5 R4 Q/ C  H- k
  56.     Preferences::WorkPlane *workPlane1;9 g6 E$ ~& o8 ?1 {
  57.     workPlane1 = workPart->Preferences()->Workplane();
    4 T# y1 d3 N8 ?# u  I" j
  58.     7 M6 T! ?4 \: v$ T* {9 n0 T
  59.     workPlane1->SetGridType(Preferences::WorkPlane::GridPolar);, Z) X( M; e3 @7 J. W7 A, ~
  60.     " X. ^7 r  m* o' n. @
  61.     Preferences::WorkPlane::PolarGridSize polarGridSize1;( n, z3 q; ]4 }
  62.     polarGridSize1.RadialGridSize.MajorGridSpacing = 75.0;7 E% O, f5 i  z0 A& x2 L
  63.     polarGridSize1.RadialGridSize.MinorLinesPerMajor = 3;
    , G2 t* I- l3 y3 c+ m7 t
  64.     polarGridSize1.RadialGridSize.SnapPointsPerMinor = 5;
    % h) @0 i7 D: a: a6 T& ^
  65.     polarGridSize1.AngularGridSize.MajorGridSpacing = 45.0;4 |$ k3 v0 @1 p
  66.     polarGridSize1.AngularGridSize.MinorLinesPerMajor = 4;
    5 e0 \+ w/ e. Z
  67.     polarGridSize1.AngularGridSize.SnapPointsPerMinor = 2;) _  R6 {7 K. U4 U
  68.     workPlane1->SetPolarGridSize(polarGridSize1);
    ; r: y$ C9 B2 l0 j3 P
  69.     / i9 R, N7 G" Y* b. T
  70.     workPlane1->SetShowGrid(true);' G9 y9 E+ e! G0 H
  71.     4 v: y6 m* A' C  i, l
  72.     workPlane1->SetShowLabels(false);8 j& q/ l* \. v) X( B5 r
  73.    
    + t9 \* }' g; e/ O: v- k" G$ O  V( P
  74.     workPlane1->SetSnapToGrid(false);8 G7 T6 r& u! e' f. _) b6 L, U
  75.    
    ) m% I" O8 j* Z0 k' `7 p
  76.     workPlane1->SetGridOnTop(false);
    6 j/ [5 x' w0 R
  77.    
    ( B' a5 @8 S2 w% M) }( ?4 N8 e
  78.     workPlane1->SetRectangularShowMajorLines(false);5 ?! \( D5 K* j( p/ r
  79.     * `" a4 D6 ]9 i+ b8 b
  80.     workPlane1->SetPolarShowMajorLines(true);5 i+ @0 \1 G! J4 h
  81.     5 G0 @- h# G+ ^/ R7 S3 q
  82.     workPlane1->SetGridColor(130);
    . k* v0 ], N+ I) e4 [! `/ g
  83. }
复制代码
: K) o0 p0 ]$ l: q: o

' l* F- n5 |8 s6 M6 S; |7 ]
: @2 ^: j" b( _+ }4 k, C
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了