查看: 3533|回复: 0

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

[复制链接]

6

主题

4

回帖

60

积分

管理员

积分
60
发表于 2014-3-13 11:22:36 | 显示全部楼层 |阅读模式

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

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

×
有关用户设置的使用,如果你想设置一个模版文件,可以通过下列方式:
7 {9 ^7 E, V; a2 |' u. K9 i+ Y4 ?" B2 ?
  1. 4 `9 f. s1 s5 }3 F
  2. #include <uf_defs.h>$ N8 }' R7 G' m1 y  S8 \
  3. #include <NXOpen/NXException.hxx>
    ' v# q% F) P: g1 R
  4. #include <NXOpen/Session.hxx>
    1 T5 w3 P) G4 c* S5 |- ^3 \$ X
  5. #include <NXOpen/Builder.hxx>1 F) |- m4 W8 @; E' M" I9 h/ {
  6. #include <NXOpen/FileNew.hxx>
    2 S6 ^2 ~- n: u& T/ c
  7. #include <NXOpen/NXObject.hxx>) ^3 d& `. i5 @( u+ t
  8. #include <NXOpen/Part.hxx>
    - F, u: q/ W- V
  9. #include <NXOpen/ParTCollection.hxx>
    ( E+ }" u- @3 Y! g2 {
  10. #include <NXOpen/Preferences_PartPreferences.hxx>$ p) j: e0 _6 c- w6 I
  11. #include <NXOpen/Preferences_PartSketch.hxx>5 [7 M/ ]# M+ Z5 v4 S. X6 |0 ~5 q2 y
  12. #include <NXOpen/Preferences_SessionPreferences.hxx>( L& z+ i- d2 v
  13. #include <NXOpen/Preferences_SessionSketch.hxx>& \% d: N; ?2 y% X- }% L( _3 D
  14. #include <NXOpen/Preferences_WorkPlane.hxx>
    . u- f, k7 q. ~+ L1 O
  15. #include <NXOpen/Session.hxx>
    9 C, V3 d% c) v6 D3 |2 Q
  16. using namespace NXOpen;/ ~* Z& J1 I8 P3 n- [

  17. 3 y: H' G, r6 h6 K
  18. extern "C" DllExport int ufusr_ask_unload()% i4 R, F! _2 k
  19. {
    3 {% X1 Y, H6 c! D
  20.     return (int)Session::LibraryUnloadOptionImmediately;
    * @% c$ e; D, P
  21. }
    8 r* H; r1 h, |/ [( Q: Y2 e

  22. 3 G; H2 R) |4 l' x0 P9 V
  23. extern "C" DllExport void ufusr(char *param, int *retCode, int paramLen)
    " }2 w( y- S7 u
  24. {3 ]7 n/ U$ N/ e7 Q5 ?& M
  25.     Session *theSession = Session::GetSession();5 i7 ^/ u, |) h# B, x3 b

  26. 5 A9 Y4 |4 J5 K$ |
  27.     //Creates New Part with name as Preferences.prt, v) X* H3 G) @1 F3 S  r, P) l% f# [
  28.     NXOpen::Part *part1;
      ~3 p. x* r+ |6 g9 J
  29.     part1=theSession->Parts()->NewDisplay("Preferences",Part::UnitsMillimeters);
    9 v/ O9 i. M; a! O1 |0 E
  30.     Part *workPart(theSession->Parts()->Work());; D: J8 F! J$ ^8 J. _
  31.     Part *displayPart(theSession->Parts()->Display());   {7 i" K! S) h# Y8 X2 i) }7 l3 z
  32. 0 w. M2 T8 ?3 J: _* x7 a
  33. $ H* j& w1 Q' \! F) Y

  34. / M; K0 @  z$ p
  35.     // ----------------------------------------------
    * A  T2 v/ G! v# B
  36.     //  Changing Sketch Prefix names* V; p2 y" ^( d6 ~9 i1 F
  37.     // ----------------------------------------------   
    " ]  N2 o9 D3 f9 L
  38.       6 x+ p1 B, z1 P; z2 c9 e5 d5 {6 n
  39.     theSession->Preferences()->Sketch()->SetDefaultSketchNamePrefix("SKT_");$ X$ l% I4 Z( J( y  z2 w

  40. ' Q. e. }" n7 l
  41.     theSession->Preferences()->Sketch()->SetDefaultVertexNamePrefix("VRT_");5 w2 W  z% F/ F7 r3 J

  42. + \- V$ D6 m; r8 O
  43.     theSession->Preferences()->Sketch()->SetDefaultLineNamePrefix("LIN_");& D" Z: M8 l4 B$ h

  44. 9 i; e& {' Z3 n& o
  45.     theSession->Preferences()->Sketch()->SetDefaultArcNamePrefix("ARC_");
    4 O/ t- A! c3 j/ b0 t& _0 J& t5 D
  46. 6 X  P6 Q( D% E) R
  47.     theSession->Preferences()->Sketch()->SetDefaultConicNamePrefix("CON_");
    + R$ _$ w& j: h: r

  48. 5 \0 E2 s9 `; E8 d4 D5 O. y8 W' p8 V
  49.     theSession->Preferences()->Sketch()->SetDefaultSplineNamePrefix("SPL_");      
    - E! ?* V6 n0 @9 c2 g7 C
  50.    + I* O/ e7 @4 c- j# M$ c4 D
  51.    
    6 W/ e. ?0 S3 x% N: w
  52.     // ----------------------------------------------. V$ }4 ~4 [! Q4 P- E, n, b8 }. c6 C
  53.     //  Changing Grid values
    & T* }) c" X% S0 {+ c* t, i
  54.     // ----------------------------------------------  
    ! u. b' P1 ], a/ o8 a4 L) T
  55.     + `1 m6 Z- a2 k9 n  n
  56.     Preferences::WorkPlane *workPlane1;  g' z$ b( B" F& ~
  57.     workPlane1 = workPart->Preferences()->Workplane();7 n& y% s# S: W2 S8 [
  58.     0 t* P+ R' u& I+ v: ^
  59.     workPlane1->SetGridType(Preferences::WorkPlane::GridPolar);% M, Z+ P5 e1 A' X3 w& }
  60.    
    ( ?7 h. b, L0 S* M
  61.     Preferences::WorkPlane::PolarGridSize polarGridSize1;
    - ^9 }: W+ @5 {- b2 }
  62.     polarGridSize1.RadialGridSize.MajorGridSpacing = 75.0;- E5 K. ~4 F% d( C- {% J+ ?
  63.     polarGridSize1.RadialGridSize.MinorLinesPerMajor = 3;
    4 E( L- D. J2 Z9 R  v) y
  64.     polarGridSize1.RadialGridSize.SnapPointsPerMinor = 5;7 z6 g2 T7 p: E- I
  65.     polarGridSize1.AngularGridSize.MajorGridSpacing = 45.0;
      Q. D  ]% H5 @& j& u8 n! h& X
  66.     polarGridSize1.AngularGridSize.MinorLinesPerMajor = 4;' i5 A0 F1 K+ U+ @* v4 y/ h( p0 Q
  67.     polarGridSize1.AngularGridSize.SnapPointsPerMinor = 2;# Y  n, _  ]' K  a8 H
  68.     workPlane1->SetPolarGridSize(polarGridSize1);
    ; v$ ]' o8 p! i7 m' j
  69.    
    1 l/ c. a* g6 m* Z
  70.     workPlane1->SetShowGrid(true);
    " K- S. H) F- h. D$ B- `
  71.     / q  W& u" u1 A3 G! a9 c; ^% g" w
  72.     workPlane1->SetShowLabels(false);
    7 l, }  p8 ?: z# _1 e
  73.    
    + W; D8 a1 U- W. L
  74.     workPlane1->SetSnapToGrid(false);- Q2 o* f1 e0 P
  75.     . Z, f1 a6 @+ C' N
  76.     workPlane1->SetGridOnTop(false);
    ) r/ e; e# s0 n2 L: K
  77.    
    , w, d% ~. [: \+ ?& M
  78.     workPlane1->SetRectangularShowMajorLines(false);, ^7 p# `7 R2 z4 t
  79.    
    % O1 F& j2 _( y" p
  80.     workPlane1->SetPolarShowMajorLines(true);8 g5 m. t' q) Y
  81.    
    / {" i8 ?0 ~* ]2 h2 R: P. @! t
  82.     workPlane1->SetGridColor(130);
    " s! L% U: N! q6 H! N
  83. }
复制代码
1 ~& Q; {8 N9 k9 d! ]0 G7 D
2 q9 `; ~7 G- U7 t
! t/ b0 |: J7 X& f8 q+ c+ K
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

在本版发帖
关注公众号
QQ客服返回顶部