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

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

[复制链接]

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

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

admin 楼主

2014-3-13 11:22:36

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

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

x
有关用户设置的使用,如果你想设置一个模版文件,可以通过下列方式:) {% q  h. e. [) T
" Z" M$ {7 a* V3 B0 K
  1. . l5 X4 ^% @5 D  h$ e
  2. #include <uf_defs.h>: N+ i' e: r) ~
  3. #include <NXOpen/NXException.hxx>7 t3 p6 e& k, B$ H
  4. #include <NXOpen/Session.hxx>
    0 L2 B2 C' X0 n! M; Y' H3 v0 g: L
  5. #include <NXOpen/Builder.hxx># f$ N: H; Q% w
  6. #include <NXOpen/FileNew.hxx>
    % ?5 w- d9 r- E/ Q
  7. #include <NXOpen/NXObject.hxx>
    5 }9 B4 t6 |# J6 v8 \, R
  8. #include <NXOpen/Part.hxx>: x0 s/ n' p; W* @
  9. #include <NXOpen/ParTCollection.hxx>
    6 \# Q3 B! W. s. i2 ]+ O2 J
  10. #include <NXOpen/Preferences_PartPreferences.hxx>
    $ q$ ]# x  r5 i- m5 j. B! a7 |
  11. #include <NXOpen/Preferences_PartSketch.hxx>
    & x7 a) F- L8 s/ E# B4 P, ~. {% {
  12. #include <NXOpen/Preferences_SessionPreferences.hxx>
    9 H) {% H! S7 u8 T7 G9 l
  13. #include <NXOpen/Preferences_SessionSketch.hxx>
    . J$ q( i1 X* Q) x9 x$ ~
  14. #include <NXOpen/Preferences_WorkPlane.hxx># R5 |* O) h$ P- i1 t
  15. #include <NXOpen/Session.hxx>/ ^1 S  I" h# n' E/ H: N% g
  16. using namespace NXOpen;" B  S# Z- R1 e$ w: b, k0 @) @! J
  17. $ i2 p  I5 s6 z. F
  18. extern "C" DllExport int ufusr_ask_unload()( j8 @; B  Q2 G4 S
  19. {' e4 U7 v; z; n8 O/ b
  20.     return (int)Session::LibraryUnloadOptionImmediately;
    0 u  o! y. Y4 e* V9 P, `3 l( M7 q
  21. }
    % Z2 Y* O' ]) ]3 A9 i1 k: `# ^3 `

  22.   {5 n$ p( J9 B) Z# F: n# T$ }
  23. extern "C" DllExport void ufusr(char *param, int *retCode, int paramLen)9 {9 G2 I4 L5 c
  24. {' q# d: J$ L/ R9 ^& F' M
  25.     Session *theSession = Session::GetSession();% ?$ V9 A5 L5 B8 K0 ?9 A( o

  26. 9 d$ s7 I+ f/ _
  27.     //Creates New Part with name as Preferences.prt
    ' b4 ^4 J( _) Z% f# j
  28.     NXOpen::Part *part1;
    # \: o0 Y- l" \# E" _
  29.     part1=theSession->Parts()->NewDisplay("Preferences",Part::UnitsMillimeters);
    ) E' i# V% i- e! ?1 r: P  N
  30.     Part *workPart(theSession->Parts()->Work());
    8 j- k! H2 i9 m2 r$ \) W
  31.     Part *displayPart(theSession->Parts()->Display());
    0 v$ ]$ Q& z- U3 p" i2 r5 t. j

  32. ( p/ H: D1 @5 z% C. o

  33. * b4 B9 a3 z6 I

  34. & i* l) D" ~8 Y- M( A9 s* \
  35.     // ----------------------------------------------
    0 ^3 a$ F' u+ Z! C5 N
  36.     //  Changing Sketch Prefix names
      T$ s7 h% B) {+ a  @2 v8 g2 L
  37.     // ----------------------------------------------   
    ' f; l5 m- B, K. C
  38.         X: B; l# }1 |
  39.     theSession->Preferences()->Sketch()->SetDefaultSketchNamePrefix("SKT_");3 h+ r6 K8 h9 g) w. M
  40. ) f' l8 O, g3 K$ t% ~
  41.     theSession->Preferences()->Sketch()->SetDefaultVertexNamePrefix("VRT_");
    3 Q$ j7 k3 Y1 [2 n) b0 v( O& X

  42. , a- S6 [% ]0 Z0 w
  43.     theSession->Preferences()->Sketch()->SetDefaultLineNamePrefix("LIN_");
    * d5 [7 }- r  p- ~! Q

  44. . l/ G, o) G/ W' w+ l0 ^" c- }
  45.     theSession->Preferences()->Sketch()->SetDefaultArcNamePrefix("ARC_");
    5 B8 I7 f/ N+ b

  46. , L$ |8 f1 g7 ^! Y
  47.     theSession->Preferences()->Sketch()->SetDefaultConicNamePrefix("CON_");
    6 a( N; P  v5 |! K" s+ p2 b' h

  48. - e" j2 s5 F1 ^
  49.     theSession->Preferences()->Sketch()->SetDefaultSplineNamePrefix("SPL_");       ' W; S& X. ~- G
  50.    
    , _/ x+ H1 y3 Q" l9 }
  51.     8 o! B: ]& J6 v8 N
  52.     // ----------------------------------------------
    , T% H3 W& i9 s. R" Z3 C9 V* r
  53.     //  Changing Grid values8 d" |' ]! ?: ^$ L6 J5 a# B: V
  54.     // ----------------------------------------------  + Y' J7 `$ p/ t% o% R! X9 {
  55.     6 E% [3 |6 m( H, V7 M4 A' V; {4 Y9 e
  56.     Preferences::WorkPlane *workPlane1;
    * \6 W; _) P* T7 X" I, D
  57.     workPlane1 = workPart->Preferences()->Workplane();
    1 D1 X9 r+ k4 t' H! U
  58.    
    ' P( Y/ J& H8 o4 C4 I' Y& v7 K* h
  59.     workPlane1->SetGridType(Preferences::WorkPlane::GridPolar);
    ) M. M4 }9 K3 }4 P* L, ^
  60.     : N% w/ k0 a7 f: f+ ?
  61.     Preferences::WorkPlane::PolarGridSize polarGridSize1;' l5 u& ^8 v/ t. i# `+ B8 h9 G8 w
  62.     polarGridSize1.RadialGridSize.MajorGridSpacing = 75.0;& u, `9 Y; u' u3 {3 I
  63.     polarGridSize1.RadialGridSize.MinorLinesPerMajor = 3;
    0 `5 R7 L9 R: o, E9 y( f
  64.     polarGridSize1.RadialGridSize.SnapPointsPerMinor = 5;7 T" m2 q% a& p% d) \# s$ n
  65.     polarGridSize1.AngularGridSize.MajorGridSpacing = 45.0;4 t# l% U- G$ T+ C: j* G% a
  66.     polarGridSize1.AngularGridSize.MinorLinesPerMajor = 4;
    / ~- ?1 z  T# ^3 u+ E
  67.     polarGridSize1.AngularGridSize.SnapPointsPerMinor = 2;1 Z! R! F/ I0 R4 z5 i
  68.     workPlane1->SetPolarGridSize(polarGridSize1);
    6 K8 o5 y" C$ @: L
  69.     ) [" c/ ^3 H- R! F4 B: r% t- A
  70.     workPlane1->SetShowGrid(true);# A9 W( ]+ w7 B; I
  71.    
    0 F) F6 H# E; U, j& x% l7 y
  72.     workPlane1->SetShowLabels(false);
    6 r0 L6 }: z8 w! c# \1 W
  73.    
    + y$ ^$ D, [4 A5 I6 P
  74.     workPlane1->SetSnapToGrid(false);, g' n5 Q' R5 v0 j* ]4 G
  75.    
    5 J  n2 ]: X+ a# u  D5 T
  76.     workPlane1->SetGridOnTop(false);; O" ?. f" p. d' a6 ^# X
  77.     . b4 }/ ?% V% H8 \: s8 j( @( h
  78.     workPlane1->SetRectangularShowMajorLines(false);$ e" H$ C9 n3 B/ E9 l. ~
  79.     2 @6 v/ {+ \9 g2 G
  80.     workPlane1->SetPolarShowMajorLines(true);" b- H4 `( t$ D- ^* @0 C) T
  81.     $ F5 S0 g3 i" U) G8 `  @
  82.     workPlane1->SetGridColor(130);
    ' Q, z! [% Y4 P% \! {
  83. }
复制代码
8 R( I0 N' f9 d3 x! y
1 q( a# P, X7 d0 [# ~( |) k5 c

" N  [4 i1 Y- z" F% {: \. 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二次开发专题模块培训报名开始啦

    我知道了