PLM之家PLMHome-工业软件践行者

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

[复制链接]

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

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

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

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

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

x
有关用户设置的使用,如果你想设置一个模版文件,可以通过下列方式:+ H3 G. c; ~. w" X( n
: [- m0 `- ?  \( e# t& B
  1. . J+ B! b3 L  B! w" a
  2. #include <uf_defs.h>$ r, s4 N4 o; L7 l4 A6 ]
  3. #include <NXOpen/NXException.hxx>! h, k& P+ b2 l& ]2 |+ ]  C* r2 a
  4. #include <NXOpen/Session.hxx>
    0 w1 f) W9 }. j$ I& S, T, Q+ k
  5. #include <NXOpen/Builder.hxx>9 x0 q+ A( k- ]5 K& A7 ~: k
  6. #include <NXOpen/FileNew.hxx>
    * Y# Z3 b# t/ ]* q" X% f" z
  7. #include <NXOpen/NXObject.hxx>
    " }* u! {$ z! l
  8. #include <NXOpen/Part.hxx>
    3 t, B( P; `+ K' E( @* d. m
  9. #include <NXOpen/ParTCollection.hxx>
    4 }6 k1 x# ~$ n% b9 \2 g
  10. #include <NXOpen/Preferences_PartPreferences.hxx>
    4 f: `, f( ^6 c
  11. #include <NXOpen/Preferences_PartSketch.hxx>, @1 L) K$ K3 O$ T8 k4 v
  12. #include <NXOpen/Preferences_SessionPreferences.hxx>0 U3 M. ^3 M) b5 G/ m, Q) b
  13. #include <NXOpen/Preferences_SessionSketch.hxx>  t4 {1 m) N9 @* U( _$ a" a
  14. #include <NXOpen/Preferences_WorkPlane.hxx>
    ! F( N' a( b% z
  15. #include <NXOpen/Session.hxx>/ a0 S: ^# q" {; ?0 ]) G& G) ?
  16. using namespace NXOpen;6 t  K) S0 n5 r" n. ]3 q9 O) c3 `

  17. / P/ O; j) L6 b/ ^% v' m
  18. extern "C" DllExport int ufusr_ask_unload()
    1 ]$ A7 t% A' |- C7 x( t
  19. {0 F, n$ F0 ~8 C
  20.     return (int)Session::LibraryUnloadOptionImmediately;, Z* e9 [  q1 P! U! a6 [
  21. }
    ) C$ a; o8 `: Y) i8 Z8 G, G* J
  22. 0 `- t- j2 J4 c% @! \1 V
  23. extern "C" DllExport void ufusr(char *param, int *retCode, int paramLen)
    7 z5 U, u% @" E( g: I) W
  24. {# k, x  W. b' v. U3 r, J; G6 M
  25.     Session *theSession = Session::GetSession();% `8 c! Y6 {) _0 x6 N+ Q' e

  26.   F6 W' R5 Y. J' W# M+ |
  27.     //Creates New Part with name as Preferences.prt
    2 E* t5 K. C3 d. W" Q) Y' q1 T
  28.     NXOpen::Part *part1;
    4 A6 p% T, _6 ]- y1 Y' U& r
  29.     part1=theSession->Parts()->NewDisplay("Preferences",Part::UnitsMillimeters);
    , d" r  b( c8 Z4 w) y
  30.     Part *workPart(theSession->Parts()->Work());/ Z) v) O8 Y, n: ^5 X0 O8 T7 w, h
  31.     Part *displayPart(theSession->Parts()->Display()); / J. t  P( |& B/ m
  32. 1 m1 L5 i, f4 R- o1 [* {/ y: w' w* m
  33. 3 G3 c6 J3 y! z
  34. , [0 ?) ^( E+ K! a! A# V6 P
  35.     // ----------------------------------------------
    . r; b- _5 i3 i5 K
  36.     //  Changing Sketch Prefix names. u" q$ _5 w# F5 ]" G3 o5 }
  37.     // ----------------------------------------------   
    6 J9 M' `9 Q6 N; T  U/ p" M8 L; t
  38.       
    ; l* G: X# q% I. S. d/ d/ s: Q* z
  39.     theSession->Preferences()->Sketch()->SetDefaultSketchNamePrefix("SKT_");0 p9 K) l; M3 c

  40. , v) K  D: z) s3 N6 T
  41.     theSession->Preferences()->Sketch()->SetDefaultVertexNamePrefix("VRT_");
    + t, K# _0 x* f! ?

  42. " e# W1 ?( W, u; l: j* B3 C
  43.     theSession->Preferences()->Sketch()->SetDefaultLineNamePrefix("LIN_");1 ]% j  K% \4 @; E  d' c' ?7 M" V' c

  44. * z, ?, l5 {- [% `8 B; ^
  45.     theSession->Preferences()->Sketch()->SetDefaultArcNamePrefix("ARC_");
    & o. J" m/ e& _" N& R

  46. : [; h" D# y9 m" O" m( m
  47.     theSession->Preferences()->Sketch()->SetDefaultConicNamePrefix("CON_");
    . l# O$ V; R$ W: y! K

  48. % m5 ?' `4 Q& |) S7 j7 C
  49.     theSession->Preferences()->Sketch()->SetDefaultSplineNamePrefix("SPL_");      
    4 ?3 q. Q6 y: B: v2 q
  50.    
    ! O: I5 }! t7 o1 b) t
  51.     ; }! T; S" D. h  I! ~( r" n
  52.     // ----------------------------------------------+ h+ P0 D, J! `: [, \. y
  53.     //  Changing Grid values- m& N. v1 e* q3 E, i
  54.     // ----------------------------------------------  - K& W3 h& h9 C. y$ O# |( Z
  55.    
    ; p/ U0 W- l2 i
  56.     Preferences::WorkPlane *workPlane1;
    4 t2 V( q( `( F) t/ B* z
  57.     workPlane1 = workPart->Preferences()->Workplane();/ N2 i$ |( J3 @5 s) a
  58.    
    8 S2 c0 q6 A/ ^
  59.     workPlane1->SetGridType(Preferences::WorkPlane::GridPolar);
    2 B, O+ @, p+ N' o/ D+ x% L9 K
  60.    
    . p# b/ m5 F2 L" M* ~0 W& j& c, p
  61.     Preferences::WorkPlane::PolarGridSize polarGridSize1;7 b/ M  R6 [  X4 P0 U9 X9 M
  62.     polarGridSize1.RadialGridSize.MajorGridSpacing = 75.0;
    0 h; R; D: J8 W5 \' B+ g
  63.     polarGridSize1.RadialGridSize.MinorLinesPerMajor = 3;
    8 p/ J0 g/ x" c4 R
  64.     polarGridSize1.RadialGridSize.SnapPointsPerMinor = 5;, V. E' N$ X. q; N/ [$ z; N0 R
  65.     polarGridSize1.AngularGridSize.MajorGridSpacing = 45.0;* H+ v) ^  P$ {+ u6 n; X# O) |9 i. Q/ Y+ ~
  66.     polarGridSize1.AngularGridSize.MinorLinesPerMajor = 4;
    7 \5 {$ `' \1 z, u4 w# U! o
  67.     polarGridSize1.AngularGridSize.SnapPointsPerMinor = 2;
    ( q9 x' q! J1 d/ l2 y& a5 m2 ^
  68.     workPlane1->SetPolarGridSize(polarGridSize1);
    ; k: f8 u) ?! B2 V4 \0 M$ z
  69.     . l# {2 d3 v0 c- |! M
  70.     workPlane1->SetShowGrid(true);
    $ Q/ ]8 N. T! c3 [3 h0 W
  71.    
    7 x' c6 s# S5 a3 q5 U
  72.     workPlane1->SetShowLabels(false);& m1 E* ?, ?; V! j! n
  73.     - A5 Z' |" v" N# ^# w' X; e
  74.     workPlane1->SetSnapToGrid(false);9 b& |" d, t! {
  75.    
    # A* K; G8 U- x* V1 ?/ I
  76.     workPlane1->SetGridOnTop(false);
    6 q) Y1 i  q, u/ y* Z! E& K6 K
  77.     2 d! a; }  z3 J$ Z1 W- j: |
  78.     workPlane1->SetRectangularShowMajorLines(false);
    # l- O7 u! l# C
  79.     4 t/ b( z+ e. U8 X6 r
  80.     workPlane1->SetPolarShowMajorLines(true);+ e% }3 j8 G6 w. s4 e4 s! R
  81.    
    ) g1 ~  _7 {: O2 f0 C( |8 b5 x
  82.     workPlane1->SetGridColor(130);# V* s# Z8 p" H
  83. }
复制代码
7 q' @7 ^8 c; J) w% r8 S5 s

1 |) B- k$ \, Y% f" n
3 s) D/ Q% M2 e3 p! s3 R, _% B
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了