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

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

[复制链接]

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

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

admin 楼主

2014-3-13 11:22:36

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

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

x
有关用户设置的使用,如果你想设置一个模版文件,可以通过下列方式:2 C9 e: f' m8 B. [: J

( f' C% s% P+ d* m: I4 `
  1. / ^% ?% i9 ?; q) i6 H
  2. #include <uf_defs.h>
    & {) ?9 }1 n7 R! \8 ?1 N% o$ x
  3. #include <NXOpen/NXException.hxx>. y# p, h; L* B) M  T0 o8 n
  4. #include <NXOpen/Session.hxx>
    3 @# N& x3 l% ~0 C$ {2 }% Y5 s- L
  5. #include <NXOpen/Builder.hxx>3 A( H2 Y5 \3 x, G: L. |9 x/ \
  6. #include <NXOpen/FileNew.hxx>: Z& T& P% c& M" N
  7. #include <NXOpen/NXObject.hxx>
    8 j& ^+ q8 k5 N+ a
  8. #include <NXOpen/Part.hxx>3 f" R/ X/ y4 b
  9. #include <NXOpen/ParTCollection.hxx>! A+ |3 u2 `7 ~( _
  10. #include <NXOpen/Preferences_PartPreferences.hxx>
    8 q" i) j1 R. t7 K4 i
  11. #include <NXOpen/Preferences_PartSketch.hxx>& Q3 a% ^# c( U: @
  12. #include <NXOpen/Preferences_SessionPreferences.hxx>/ f9 \- i$ C* X+ B; q9 O
  13. #include <NXOpen/Preferences_SessionSketch.hxx>( W- X& G& l' m; W" y# r0 K
  14. #include <NXOpen/Preferences_WorkPlane.hxx>
    # f! h2 @4 p, S, X# Y+ \1 l% d
  15. #include <NXOpen/Session.hxx>. C( }( g  a3 U0 z
  16. using namespace NXOpen;
    6 t& r7 G7 j; `; ^7 k, d

  17. 9 j: t4 b+ q, m7 t4 y) F$ L& D! T
  18. extern "C" DllExport int ufusr_ask_unload()5 Z$ c3 K$ W$ h0 J2 w
  19. {- `1 P+ n9 y/ E  E9 @& h! G
  20.     return (int)Session::LibraryUnloadOptionImmediately;  _$ G# I7 f9 K2 a) i8 l& h
  21. }( ]8 u0 K. x1 ~" e* L, e$ L3 L

  22. 4 {% C: P8 X2 X! o
  23. extern "C" DllExport void ufusr(char *param, int *retCode, int paramLen)  V: M( y) V& `" U
  24. {
    - x2 W7 f6 r- n( l0 r! R$ G; M
  25.     Session *theSession = Session::GetSession();
    4 Y  v1 T  W; u2 q6 o! _+ P( @
  26. ! k0 x0 X6 ^5 g) s% @! `
  27.     //Creates New Part with name as Preferences.prt
    * Q4 s3 e  |2 a- n' Z2 c9 I, X, E  B
  28.     NXOpen::Part *part1;) i" A5 |3 S) s
  29.     part1=theSession->Parts()->NewDisplay("Preferences",Part::UnitsMillimeters);
    , z# e$ |+ g( d( o9 W, ^7 M
  30.     Part *workPart(theSession->Parts()->Work());1 {1 W' n! U8 U* k7 q' E
  31.     Part *displayPart(theSession->Parts()->Display()); , k0 o+ \6 N, o1 w+ D
  32. , _. \+ o2 X) X5 B

  33. . t% a' X( v- B7 s1 z4 }
  34. / c/ F" u0 N( v5 {( u2 N
  35.     // ----------------------------------------------
    4 y! m3 |  d! ~7 G' X
  36.     //  Changing Sketch Prefix names+ ~  o+ ]& ]/ t! Q6 T6 H6 n
  37.     // ----------------------------------------------   9 F5 b3 u( c  T( z
  38.       
    ( ?$ D& Q  G  X, n% U1 T7 ^! k) d
  39.     theSession->Preferences()->Sketch()->SetDefaultSketchNamePrefix("SKT_");! n1 s5 \  w1 f0 w1 L0 M

  40. 4 [) C( d& I' w" ]) e: u/ o
  41.     theSession->Preferences()->Sketch()->SetDefaultVertexNamePrefix("VRT_");, @9 \9 i' Q, c0 ?& @8 {

  42. ) x/ ?7 e: N! i
  43.     theSession->Preferences()->Sketch()->SetDefaultLineNamePrefix("LIN_");  t6 m+ [& O% q, g  G

  44. ( h* v9 D6 ?+ o" W& F
  45.     theSession->Preferences()->Sketch()->SetDefaultArcNamePrefix("ARC_");
    1 @- m7 i# i3 `9 D# r
  46. " t6 D! |5 P! H8 n, g; w' n# t
  47.     theSession->Preferences()->Sketch()->SetDefaultConicNamePrefix("CON_");
    5 B0 v7 ]# w, D: c

  48. ) |. ]6 V& p" s# h5 a4 r
  49.     theSession->Preferences()->Sketch()->SetDefaultSplineNamePrefix("SPL_");      
    4 }  C9 u) N; I' ~$ n
  50.    
    6 n/ ?4 m9 r, Y( M3 a: Y/ J- Z
  51.     ( z, T, r% _+ Q* s
  52.     // ----------------------------------------------- `" P$ S7 Q7 F& q1 C- D
  53.     //  Changing Grid values
    ; |# z5 H, n( \
  54.     // ----------------------------------------------  
    : v& Z; t, x$ F# g- G; Y
  55.     ( W. c! x- y, F& O; j! a8 ^! c
  56.     Preferences::WorkPlane *workPlane1;
    4 K& W( j* w1 v' `. G, ], Q) S
  57.     workPlane1 = workPart->Preferences()->Workplane();; B, h( I; q: Z2 o7 `: `0 z
  58.    
    $ o7 X! N  _6 g, C2 z9 |
  59.     workPlane1->SetGridType(Preferences::WorkPlane::GridPolar);+ g) }4 d# u3 P: U7 x* Y! d
  60.    
    % Z6 P" u$ i& Q* }& Q
  61.     Preferences::WorkPlane::PolarGridSize polarGridSize1;" r1 q$ n' d; j8 D8 V
  62.     polarGridSize1.RadialGridSize.MajorGridSpacing = 75.0;
    . O( N! H4 _( J" g! U
  63.     polarGridSize1.RadialGridSize.MinorLinesPerMajor = 3;
    ! u& x8 X2 t$ J5 @1 j3 f* w
  64.     polarGridSize1.RadialGridSize.SnapPointsPerMinor = 5;6 {  w  G5 R; N; L' F
  65.     polarGridSize1.AngularGridSize.MajorGridSpacing = 45.0;
      I0 L, R; e  _3 s
  66.     polarGridSize1.AngularGridSize.MinorLinesPerMajor = 4;" K; `0 z+ q( m7 ~& a* F9 d# a
  67.     polarGridSize1.AngularGridSize.SnapPointsPerMinor = 2;. K5 T; X# T5 R
  68.     workPlane1->SetPolarGridSize(polarGridSize1);! x1 X8 k1 r1 Q4 Y/ D% `
  69.     $ C& o( v: n6 F, }
  70.     workPlane1->SetShowGrid(true);
    ; N. ~/ y! k' E8 \+ m/ m9 r- ?
  71.     5 u' {8 [9 [# E% Z7 N1 l6 n$ k7 x. {/ n
  72.     workPlane1->SetShowLabels(false);$ d7 u4 w; [  t: h( x- V  \& |
  73.    
    . h3 K  k# @$ Q
  74.     workPlane1->SetSnapToGrid(false);; M4 c6 M. l3 y2 @0 R8 b( t' X4 Z
  75.     - V5 y. H; H* e! X6 H+ ?. W
  76.     workPlane1->SetGridOnTop(false);0 X) y2 J9 I& \7 ?( `5 ~
  77.     # d0 e7 c9 k2 ^1 t" e$ ?1 w' s8 `
  78.     workPlane1->SetRectangularShowMajorLines(false);
    ! Y% f+ @5 Y& s3 H% U. T* }
  79.     - U' e! R* s5 e3 ?* o- S% D6 O! H+ Z8 b
  80.     workPlane1->SetPolarShowMajorLines(true);2 j. T: o0 Q8 H1 ^0 `0 e( G
  81.    
    7 N% t% t( m8 e3 U  e) d5 n
  82.     workPlane1->SetGridColor(130);
    ! J4 D6 g0 G- X( d, ~* a
  83. }
复制代码

7 ], E7 s2 A9 v+ `' P+ j. g
0 g4 t2 v- t! v+ b
$ o% L% r+ k( c, }* 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二次开发专题模块培训报名开始啦

    我知道了