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

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

[复制链接]

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

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

admin 楼主

2014-3-13 11:22:36

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

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

x
有关用户设置的使用,如果你想设置一个模版文件,可以通过下列方式:
6 G8 E: t3 |" I% v: A4 X2 s& H' y5 N5 h" I9 ~

  1. , ?5 M2 a2 I* ~2 J
  2. #include <uf_defs.h>( R  Y  M3 x$ R/ G5 h  n! v' `/ n
  3. #include <NXOpen/NXException.hxx>
    - U9 x9 E- q8 U$ u7 e9 f
  4. #include <NXOpen/Session.hxx>% r. Z1 G  k$ ]8 C
  5. #include <NXOpen/Builder.hxx>: b2 G* M2 M" T
  6. #include <NXOpen/FileNew.hxx>
    * c! R. Q( G8 T+ Q! O, t$ |
  7. #include <NXOpen/NXObject.hxx>
    4 P3 V( ?5 O3 }2 O# c' ~& r2 U  ]" x
  8. #include <NXOpen/Part.hxx>3 S2 f$ ~0 m/ w
  9. #include <NXOpen/ParTCollection.hxx>
    ) s4 H1 J$ l2 H) E. y3 T
  10. #include <NXOpen/Preferences_PartPreferences.hxx>
    ' G' y- ?0 J& P; A6 G; H
  11. #include <NXOpen/Preferences_PartSketch.hxx>
    * A; P% I7 q9 ?: _
  12. #include <NXOpen/Preferences_SessionPreferences.hxx>! Y0 b& E$ |7 Z) m1 X$ c7 O
  13. #include <NXOpen/Preferences_SessionSketch.hxx>
    : h6 C( `9 D, i8 E* l- w" q' b
  14. #include <NXOpen/Preferences_WorkPlane.hxx># B: k; @0 [$ h7 d
  15. #include <NXOpen/Session.hxx>
    + t8 |1 L% r$ L4 c% P. p, f+ a1 N  A; d* f- P
  16. using namespace NXOpen;5 k' [0 f9 ~+ a/ w
  17. 8 i) v; H/ Z! E9 a. ~
  18. extern "C" DllExport int ufusr_ask_unload()& T/ O2 @. [) C
  19. {
    / d/ O/ E/ k$ M+ `
  20.     return (int)Session::LibraryUnloadOptionImmediately;
    9 W5 J$ b3 i) I, W( C) i, R
  21. }
    , p  M. [" K9 `; i" r* K' U
  22. 9 h) V  Z% K* Q6 _( k
  23. extern "C" DllExport void ufusr(char *param, int *retCode, int paramLen)
    7 x. n5 u7 c+ v9 m& h9 Y, w
  24. {* }0 {3 F4 E% X" F! K
  25.     Session *theSession = Session::GetSession();
    6 `' u+ Z5 g1 C6 q

  26. 8 E* |" m* @, v5 B4 i
  27.     //Creates New Part with name as Preferences.prt! Q. d. d5 S+ K/ k7 j$ S  M
  28.     NXOpen::Part *part1;
    1 Q; e- G5 F1 d  F7 Q# J
  29.     part1=theSession->Parts()->NewDisplay("Preferences",Part::UnitsMillimeters); $ K/ v% C' O1 O0 j
  30.     Part *workPart(theSession->Parts()->Work());
    9 e$ o! Q' H, l7 Y8 [
  31.     Part *displayPart(theSession->Parts()->Display()); ' Y& D# X7 d$ |, b: z- F4 S

  32. 0 Y/ D% U3 g- ^: t1 b) L
  33. % w% T0 M) g6 P# n- B4 D5 L$ v

  34. 8 _+ H. X! I2 \; g7 h$ b2 I1 v- J6 ?: \
  35.     // ----------------------------------------------- E4 X' g, c9 F  o! Z# @, U
  36.     //  Changing Sketch Prefix names
    ) D: u" M/ }% |; u4 w! j5 \% ^* \
  37.     // ----------------------------------------------   % G9 ]' T0 x6 N+ V, O7 l; K& Q
  38.       
    6 j5 o9 T* p, B
  39.     theSession->Preferences()->Sketch()->SetDefaultSketchNamePrefix("SKT_");; ?3 y+ i/ N3 v
  40. " T/ Y$ [* q) g
  41.     theSession->Preferences()->Sketch()->SetDefaultVertexNamePrefix("VRT_");3 N$ B8 {0 h( N

  42. 1 T6 B1 A: r1 |* e4 J: l
  43.     theSession->Preferences()->Sketch()->SetDefaultLineNamePrefix("LIN_");% z: j0 V+ @6 \* }; w

  44. # [  V% {& ?. Y: y9 t$ Y" S) o
  45.     theSession->Preferences()->Sketch()->SetDefaultArcNamePrefix("ARC_");# I( o$ ?7 U. t3 u- A- f
  46. : a$ X# h' P/ ^6 [
  47.     theSession->Preferences()->Sketch()->SetDefaultConicNamePrefix("CON_");, t+ b: S0 C* m3 \, W
  48. 9 G3 e% e6 U; }
  49.     theSession->Preferences()->Sketch()->SetDefaultSplineNamePrefix("SPL_");       * [: w3 n8 N1 z5 }: X
  50.    " K& V8 }/ g1 ?) _; v
  51.     / ~. P( G) ~8 a" ]/ T5 G+ s3 `
  52.     // ----------------------------------------------+ O1 R1 G; v8 A, S8 i
  53.     //  Changing Grid values) r/ l% d9 r' l3 _. N( j
  54.     // ----------------------------------------------  0 h# W9 j& A8 X8 L  W" w
  55.    
    * U% L0 F. d2 @# X1 `8 ^
  56.     Preferences::WorkPlane *workPlane1;
    4 d. m) G; v# X! q
  57.     workPlane1 = workPart->Preferences()->Workplane();' K/ u0 S+ @& c# }) Q$ p& h
  58.     ' L" ~' n. @3 f9 i% W% R
  59.     workPlane1->SetGridType(Preferences::WorkPlane::GridPolar);: w5 b1 r, F1 E: r3 c* p# l
  60.    
    1 b5 n. V" |% {' y8 ?5 o! x' b# Y
  61.     Preferences::WorkPlane::PolarGridSize polarGridSize1;
    ) o4 f6 m% Q" M3 w$ N9 o# ^- x4 @
  62.     polarGridSize1.RadialGridSize.MajorGridSpacing = 75.0;  k# }( }- }, O0 @9 N
  63.     polarGridSize1.RadialGridSize.MinorLinesPerMajor = 3;
    ' V, I8 x) H: s% x7 z) D
  64.     polarGridSize1.RadialGridSize.SnapPointsPerMinor = 5;5 d! Z: n6 d0 `6 E
  65.     polarGridSize1.AngularGridSize.MajorGridSpacing = 45.0;
    0 m# Y; _& Y# Z% ~# u
  66.     polarGridSize1.AngularGridSize.MinorLinesPerMajor = 4;7 a) Q2 O$ q$ Q' b. j/ Q
  67.     polarGridSize1.AngularGridSize.SnapPointsPerMinor = 2;
    0 z& t) i; U- `" i7 K* C) l0 R
  68.     workPlane1->SetPolarGridSize(polarGridSize1);
    8 V8 |4 B" Y7 y  |: n: H$ D0 n/ k
  69.     0 I, ^1 t/ q& U2 s/ u
  70.     workPlane1->SetShowGrid(true);
    & V- ^: C3 w  d( @- {5 B
  71.    
    : F1 N0 ?0 g0 m. n) h
  72.     workPlane1->SetShowLabels(false);
    # o8 ?8 _. S# i6 V, ?+ J0 y
  73.     # l" C& m$ U' o% ^
  74.     workPlane1->SetSnapToGrid(false);) o5 \" @2 |+ a0 ?+ a+ S1 u  R
  75.     ; d% X) ^8 {9 k
  76.     workPlane1->SetGridOnTop(false);
    6 y% Q% T/ Z5 I2 W8 r  Q$ P* C
  77.    
    " q7 h7 X) ]& N
  78.     workPlane1->SetRectangularShowMajorLines(false);# D5 u  M5 g  F0 P# W9 D) e
  79.     % E% {" K; ?: n( F) r* M% C
  80.     workPlane1->SetPolarShowMajorLines(true);/ P' E  Z+ C- D7 ^
  81.    
    # d& x" a% w+ j( Z6 m$ ]- o- y
  82.     workPlane1->SetGridColor(130);7 w$ W3 `1 M5 `2 s6 b
  83. }
复制代码
* w5 x. @8 C- U
$ c) _9 \' O0 A7 {/ y/ Q

" p  f6 c) h6 Y" u
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了