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

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

[复制链接]

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

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

admin 楼主

2014-3-13 11:22:36

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

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

x
有关用户设置的使用,如果你想设置一个模版文件,可以通过下列方式:+ D9 v" e# z" _3 J6 M

4 R5 G3 N5 v- J

  1. ( W' E8 G0 `! s( z$ u1 d# o5 h- E
  2. #include <uf_defs.h># r+ Y2 t) d5 i7 J" J8 t4 d! v
  3. #include <NXOpen/NXException.hxx>7 |% c% Y& V8 u3 q
  4. #include <NXOpen/Session.hxx>
    2 l1 ?/ s, ~( X$ A
  5. #include <NXOpen/Builder.hxx>$ q( j+ x; j$ p+ g( G
  6. #include <NXOpen/FileNew.hxx>; X" f2 W3 U" \) g; F
  7. #include <NXOpen/NXObject.hxx>' d% D7 s/ ]1 @7 g! |6 E6 z
  8. #include <NXOpen/Part.hxx>
    6 C# a; H" A# ~; k9 T# Z# u" ~. _
  9. #include <NXOpen/ParTCollection.hxx>4 P3 s; S+ ?) i8 n) S6 K% D8 `( Y3 K
  10. #include <NXOpen/Preferences_PartPreferences.hxx>
    5 X% h  @3 Z# I5 N/ t
  11. #include <NXOpen/Preferences_PartSketch.hxx>
    ; F+ P$ x4 m4 u7 \
  12. #include <NXOpen/Preferences_SessionPreferences.hxx>
    6 H/ S1 a5 I+ P! r
  13. #include <NXOpen/Preferences_SessionSketch.hxx>- q  L. ~$ s1 y- C# m
  14. #include <NXOpen/Preferences_WorkPlane.hxx>* U- F; x2 |6 E0 P- z; T
  15. #include <NXOpen/Session.hxx>0 O, p! I+ A2 Q7 F) p
  16. using namespace NXOpen;
    " M. e( M, O( n$ O; o
  17. 8 M& u0 l; v6 ?9 T( a
  18. extern "C" DllExport int ufusr_ask_unload()
    $ ~8 t7 l! p# j
  19. {/ L8 e" M7 h# C# u# n
  20.     return (int)Session::LibraryUnloadOptionImmediately;" G% g% `! Z6 e& i6 D( ?
  21. }
    $ N! \: Q" ], ^* V4 f1 z

  22. 3 {( X  k- \4 _8 t
  23. extern "C" DllExport void ufusr(char *param, int *retCode, int paramLen)
    " d* C7 o% |: |
  24. {
    5 L& s" _% {- t
  25.     Session *theSession = Session::GetSession();  E7 G6 D" l( {# p4 ~+ b
  26. / N/ W9 ?: H0 k# ^9 @+ a" A
  27.     //Creates New Part with name as Preferences.prt
    0 i0 d9 D, T; j3 G; |; j
  28.     NXOpen::Part *part1;3 ?) _& }+ L0 ]. M
  29.     part1=theSession->Parts()->NewDisplay("Preferences",Part::UnitsMillimeters);
    & R4 G5 h2 ~6 `: b, R
  30.     Part *workPart(theSession->Parts()->Work());
    ' J3 Q7 u$ |7 M: B& b
  31.     Part *displayPart(theSession->Parts()->Display());
    6 D  U5 M5 ^  P2 i

  32. / q! b, E- a  {1 P1 R  ^) C

  33. + _* v+ a9 O7 R

  34. ; ~4 y' Q, w0 w! o; r
  35.     // ----------------------------------------------
    4 q' `  ?# \# W7 k5 H
  36.     //  Changing Sketch Prefix names2 }+ |- B4 U9 ?& _0 G
  37.     // ----------------------------------------------   ' A5 ~1 }5 n0 L
  38.       
    4 X2 x9 I6 m+ j. K8 z
  39.     theSession->Preferences()->Sketch()->SetDefaultSketchNamePrefix("SKT_");- }: c+ q$ `, l3 i4 i, B: w

  40. , R, k! q% _# `/ ~& v/ W. o- J4 M
  41.     theSession->Preferences()->Sketch()->SetDefaultVertexNamePrefix("VRT_");
    " O* \' g7 N) Z2 N' m

  42. ; h' Q- J0 l8 _& v
  43.     theSession->Preferences()->Sketch()->SetDefaultLineNamePrefix("LIN_");
    ; V( n! V" n! X9 W5 A* ~

  44. 0 }1 M- q* U( K( z
  45.     theSession->Preferences()->Sketch()->SetDefaultArcNamePrefix("ARC_");6 V$ b, U; M' `- I% T
  46. / Q, L3 V% }7 c4 i; @2 w0 k' q5 ]
  47.     theSession->Preferences()->Sketch()->SetDefaultConicNamePrefix("CON_");9 R  T" T9 m/ A: h. A. ?
  48. - W0 \/ o. x+ n& k+ G
  49.     theSession->Preferences()->Sketch()->SetDefaultSplineNamePrefix("SPL_");      
    3 l  `$ i1 R, T1 H" E
  50.    ( H0 }; r& h1 A9 _$ n
  51.    
    ' V3 m- @* f( ^. r/ ]
  52.     // ----------------------------------------------
    % l' p4 |8 K3 u; G! D
  53.     //  Changing Grid values8 F) N0 c2 R# v9 z
  54.     // ----------------------------------------------  2 O6 d9 l5 g- q+ A
  55.     1 w4 m( K9 `6 L' Q/ Y
  56.     Preferences::WorkPlane *workPlane1;; Q8 ?+ V8 C: o7 n; _, b
  57.     workPlane1 = workPart->Preferences()->Workplane();
    " f7 e4 p$ O7 K8 Q
  58.    
    & _) y4 _' i" T" _4 ~! I
  59.     workPlane1->SetGridType(Preferences::WorkPlane::GridPolar);
    $ R7 m# ?: Y/ `: J, ~
  60.     % [7 r; D2 I3 u( Q2 J" b$ T
  61.     Preferences::WorkPlane::PolarGridSize polarGridSize1;5 U2 m! p" n; n0 i( m0 }
  62.     polarGridSize1.RadialGridSize.MajorGridSpacing = 75.0;4 ?& e6 _8 `" R  H
  63.     polarGridSize1.RadialGridSize.MinorLinesPerMajor = 3;: ~# P# [. }* }" h; h
  64.     polarGridSize1.RadialGridSize.SnapPointsPerMinor = 5;" _2 k! I- `+ D; L1 X9 W/ i; u
  65.     polarGridSize1.AngularGridSize.MajorGridSpacing = 45.0;
    , U# _9 k  z" \% c0 G
  66.     polarGridSize1.AngularGridSize.MinorLinesPerMajor = 4;
    7 b5 E  P  d6 M6 H
  67.     polarGridSize1.AngularGridSize.SnapPointsPerMinor = 2;& u* o" Y7 e/ b6 h; `
  68.     workPlane1->SetPolarGridSize(polarGridSize1);
      N0 [. i8 \( C: s& v2 `
  69.    
    8 |6 [2 F! d6 P3 k# s
  70.     workPlane1->SetShowGrid(true);" a1 [  `# p/ l# |- _
  71.     7 e5 s6 M4 Z8 S) f$ U9 ]7 z
  72.     workPlane1->SetShowLabels(false);
    6 x6 e; F4 {* H
  73.    
    # D& x7 y5 {4 r- w4 X# T  `) Y  _6 z
  74.     workPlane1->SetSnapToGrid(false);& F- l! p) x; M2 {" v
  75.    
    " t/ {! s8 c( s
  76.     workPlane1->SetGridOnTop(false);
      e$ z0 F! l$ F- I
  77.     / W( u' y' _$ |4 Q# J8 r" }$ [, |
  78.     workPlane1->SetRectangularShowMajorLines(false);) V- j5 k+ Z: E& a( V- r5 b% H
  79.    
    - b5 `& L$ t! \" q0 i) }6 D- p
  80.     workPlane1->SetPolarShowMajorLines(true);2 s' J2 Z! A% {2 q
  81.    
    . \3 I4 P. s( ?/ g
  82.     workPlane1->SetGridColor(130);% @1 N3 @# x; S
  83. }
复制代码

& P+ R% o1 l0 n% n! ~0 W! E0 r& `- Z8 y0 E4 M& X

+ ]! H" g+ t+ Y5 a: f* d9 i" g
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了