PLM之家PLMHome-工业软件践行者

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

[复制链接]

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

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

admin 楼主

2014-3-13 11:22:36

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

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

x
有关用户设置的使用,如果你想设置一个模版文件,可以通过下列方式:  ]: e) B. p* d: j

) |. ~5 V, R; S9 P

  1. % b( o( i4 k6 N. H! Q5 c' B' O) V
  2. #include <uf_defs.h>/ b# _! T7 b! p
  3. #include <NXOpen/NXException.hxx>
    0 g/ u( `! \9 @$ I/ J
  4. #include <NXOpen/Session.hxx>+ l* S- P! q7 b( S- O/ Y% r6 L4 z
  5. #include <NXOpen/Builder.hxx>& _1 J- x0 s1 r$ N7 F5 M$ b' p
  6. #include <NXOpen/FileNew.hxx>/ [# x5 ^) ]8 d* a, ^7 h  O, F8 p
  7. #include <NXOpen/NXObject.hxx>
    ! \5 a9 B# I( e0 C- U9 Y3 O! f! T% k% \
  8. #include <NXOpen/Part.hxx>2 y0 O% O! d2 {1 W+ a
  9. #include <NXOpen/ParTCollection.hxx>
    7 r! J+ M2 o" e
  10. #include <NXOpen/Preferences_PartPreferences.hxx>, W& J, b' r$ s0 o2 z
  11. #include <NXOpen/Preferences_PartSketch.hxx>
    + t+ n+ y: J' \5 X* d( o
  12. #include <NXOpen/Preferences_SessionPreferences.hxx>: \7 s: S% b% p' l+ V& c/ |( R
  13. #include <NXOpen/Preferences_SessionSketch.hxx>
    5 t2 S! _8 e' T2 t
  14. #include <NXOpen/Preferences_WorkPlane.hxx>
    * U* H/ R5 X. z" h$ g  L  q
  15. #include <NXOpen/Session.hxx>
    ! ?& i3 w3 K: S1 ]8 Q$ p6 n' w' @
  16. using namespace NXOpen;* C# }& H# O" V4 N' b
  17. 4 d3 G( D0 b$ E% Z% }' m. d
  18. extern "C" DllExport int ufusr_ask_unload()
    5 y0 M; e4 t/ f3 R
  19. {0 |$ P; o1 K) `$ V% }9 P% \
  20.     return (int)Session::LibraryUnloadOptionImmediately;8 Q# g4 q  S( S* A6 A
  21. }# z' a$ i& }6 h' e# q: r

  22. 8 {# C2 C+ X) n- Q( T3 t6 r! v
  23. extern "C" DllExport void ufusr(char *param, int *retCode, int paramLen)' I; N: U) {( u5 d" q6 R
  24. {
      ^% i9 v: u" u/ z9 S! |- Z7 V0 \: |
  25.     Session *theSession = Session::GetSession();
    . Z. v3 ?) H' U
  26. ) a0 s  V3 ~$ w. k/ ~4 i0 \# e
  27.     //Creates New Part with name as Preferences.prt
    . B9 n  [+ @7 }+ v$ x0 H% u
  28.     NXOpen::Part *part1;# D3 P4 E; q  F" E+ ]( y
  29.     part1=theSession->Parts()->NewDisplay("Preferences",Part::UnitsMillimeters);
    7 G: S) r( o  J0 M
  30.     Part *workPart(theSession->Parts()->Work());
    + A7 w0 X/ S% g: X% U2 ^6 |! M
  31.     Part *displayPart(theSession->Parts()->Display()); 2 J/ h, j) g+ F( K" ^3 S7 \0 F
  32.   p7 _! [* \! \' ?+ v

  33. . l# q8 Y. _6 a, ^9 ]: [4 x' }
  34. ! w* Q& w! S. x( b/ a
  35.     // ----------------------------------------------# h% y1 p  t& {6 t# G! ^% o
  36.     //  Changing Sketch Prefix names% R5 n0 P% c0 B% B
  37.     // ----------------------------------------------   & ]& r1 C2 U/ n# Q
  38.       
    8 x# _- b' n( C9 r: H
  39.     theSession->Preferences()->Sketch()->SetDefaultSketchNamePrefix("SKT_");0 ?4 M" G5 a% s( f4 m1 ]0 g5 T( Y5 K$ m

  40. , Y; H- i/ k9 [/ w% x
  41.     theSession->Preferences()->Sketch()->SetDefaultVertexNamePrefix("VRT_");7 B3 ~* U7 S' E; C+ P% C; f
  42. 0 j% U  b- W! h
  43.     theSession->Preferences()->Sketch()->SetDefaultLineNamePrefix("LIN_");8 j" l* h6 w$ M% F. V1 G
  44. 9 r. A3 y, Z5 w% N6 {1 B3 Y! w) ?
  45.     theSession->Preferences()->Sketch()->SetDefaultArcNamePrefix("ARC_");. W" D0 X2 o  ], R( x/ t8 o
  46. % v/ p3 ?: r6 S& L/ ?& R
  47.     theSession->Preferences()->Sketch()->SetDefaultConicNamePrefix("CON_");
    0 B4 d/ P% V3 l& l, x

  48. . I) P1 L0 |3 S5 x1 s+ M
  49.     theSession->Preferences()->Sketch()->SetDefaultSplineNamePrefix("SPL_");      
    # P5 i: ~( Z% }
  50.    ( e; H" y8 V) f7 L4 o
  51.     % S% h# l" @! \, c, k: w
  52.     // ----------------------------------------------& K3 g9 w+ F! Q5 j5 H/ w- t" `2 e
  53.     //  Changing Grid values! B/ q. D) ], n5 d
  54.     // ----------------------------------------------  
    5 y0 w( f* w1 K
  55.    
    1 v3 v5 T/ d% I& F$ q8 o" F/ I
  56.     Preferences::WorkPlane *workPlane1;! R  q; I6 o* G! t
  57.     workPlane1 = workPart->Preferences()->Workplane();
    . ^% b  P$ c/ i/ l, @
  58.     * _- i* N2 d% ^# m# ~( `
  59.     workPlane1->SetGridType(Preferences::WorkPlane::GridPolar);$ z. [9 e( V; s. x/ k+ d# s; t
  60.     ! E% R  {. E; j( ~" z$ }  G; s
  61.     Preferences::WorkPlane::PolarGridSize polarGridSize1;, t% Z$ ~* E( U) M( A" I8 J4 s7 e
  62.     polarGridSize1.RadialGridSize.MajorGridSpacing = 75.0;8 f' @9 i: `  g' V" j
  63.     polarGridSize1.RadialGridSize.MinorLinesPerMajor = 3;: {1 w7 C* o8 U* h, N/ |
  64.     polarGridSize1.RadialGridSize.SnapPointsPerMinor = 5;
    9 }7 a; G6 ^- c6 V# l* Z+ n( b: X+ j
  65.     polarGridSize1.AngularGridSize.MajorGridSpacing = 45.0;
    + {" O! B7 H5 @( z4 _8 `; |
  66.     polarGridSize1.AngularGridSize.MinorLinesPerMajor = 4;
    : }7 {3 w; A/ c) v  N
  67.     polarGridSize1.AngularGridSize.SnapPointsPerMinor = 2;) [7 W7 p# {  O2 w0 `
  68.     workPlane1->SetPolarGridSize(polarGridSize1);
    * E2 E5 V2 R8 q5 a' W0 h
  69.     . P  I% E7 v0 }
  70.     workPlane1->SetShowGrid(true);# L4 m* s. N( j% j+ |0 c, D8 N
  71.     / C3 R. p6 c* W# x2 C
  72.     workPlane1->SetShowLabels(false);
    5 O/ S; n# q0 o; i. V, c/ J
  73.     9 f) y3 ?# Z/ m& i6 C
  74.     workPlane1->SetSnapToGrid(false);
    9 T' r5 q% x6 g1 X
  75.    
    ) e$ H! a% `: b7 b# S
  76.     workPlane1->SetGridOnTop(false);
    7 ?! V3 |$ T/ w3 P% l
  77.    
    % d/ B3 {! j% {; Z/ ~" O5 a# |  J
  78.     workPlane1->SetRectangularShowMajorLines(false);0 z) q, y/ A3 c- \
  79.     / l  z- G# E6 p& |
  80.     workPlane1->SetPolarShowMajorLines(true);
    , U; p! k, U) H
  81.    
    ! e( E& m( J: \6 x- P
  82.     workPlane1->SetGridColor(130);3 f. T+ B. j# K: Z
  83. }
复制代码

3 P* e2 ]4 A& i1 v0 ~, r8 c5 N8 d# ^, J# i* n+ e1 ~
  o: ]( n% l- ]6 ^0 f$ I6 j
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了