PLM之家PLMHome-工业软件与AI结合践行者

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

[复制链接]

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

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

admin 楼主

2014-3-13 11:22:36

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

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

x
有关用户设置的使用,如果你想设置一个模版文件,可以通过下列方式:/ f* d5 c# b4 u, P& U- _
# h, h% t2 ]$ T+ ~, [2 A
  1. 0 U1 O" ?: q& R- L6 Q
  2. #include <uf_defs.h>: v" |* s" S3 K  Y' s
  3. #include <NXOpen/NXException.hxx>  V- R$ K* z& H5 u( p
  4. #include <NXOpen/Session.hxx>' v0 b6 t' ~6 M$ s% X
  5. #include <NXOpen/Builder.hxx>
    & d. }0 u9 R0 s3 d+ k3 H; W* K) q
  6. #include <NXOpen/FileNew.hxx>- M) n4 R4 W( G1 K* S4 P
  7. #include <NXOpen/NXObject.hxx>4 N; \, V8 |" M& `
  8. #include <NXOpen/Part.hxx>
    2 z* E" ]8 T4 w+ h% l' ^9 p" y% a
  9. #include <NXOpen/ParTCollection.hxx>
    , y1 {0 N5 u* O) [7 Q0 ~/ {
  10. #include <NXOpen/Preferences_PartPreferences.hxx>+ Z! D+ L# @1 n1 R  R4 E( C0 V
  11. #include <NXOpen/Preferences_PartSketch.hxx>
      u8 \" Q- `; t8 m3 d
  12. #include <NXOpen/Preferences_SessionPreferences.hxx>
    4 X  O$ B! t9 a' }" d
  13. #include <NXOpen/Preferences_SessionSketch.hxx>7 Q5 s4 a( n5 p1 r
  14. #include <NXOpen/Preferences_WorkPlane.hxx>- Q. m. j& I- Q9 s& L
  15. #include <NXOpen/Session.hxx>/ R' }: J8 G+ Z5 I5 x' S9 Q
  16. using namespace NXOpen;6 T, M5 q) f( s/ S+ i- q
  17. ; d. x; k9 K- O
  18. extern "C" DllExport int ufusr_ask_unload()/ ^5 x5 H7 U+ C3 A3 {; n! d) p
  19. {" \7 E+ H' _3 k9 p$ |
  20.     return (int)Session::LibraryUnloadOptionImmediately;
    " g% }6 O" F# B- d2 g
  21. }, O$ r; Z! Y) \
  22.   Y5 O5 x' S! y# P+ p
  23. extern "C" DllExport void ufusr(char *param, int *retCode, int paramLen)' X9 N3 D) d; V
  24. {
      l; c& L- N2 U5 i
  25.     Session *theSession = Session::GetSession();
    6 C6 Q: [* R2 P4 `* [, R: Q

  26. & a0 a" m5 A: B- f+ k4 }
  27.     //Creates New Part with name as Preferences.prt+ e" _* @( \% E7 ?* P
  28.     NXOpen::Part *part1;
      f! |% B( r9 O$ h
  29.     part1=theSession->Parts()->NewDisplay("Preferences",Part::UnitsMillimeters);   D% A; h( [9 \3 v+ q* v. _
  30.     Part *workPart(theSession->Parts()->Work());. Q9 u5 C. u( U1 y" C( ^
  31.     Part *displayPart(theSession->Parts()->Display()); 8 L1 C. y: T! ?3 x( u& e' ?5 I
  32. 0 N( H4 |# ~5 a. d8 n3 E4 H4 q
  33. , x1 t3 B% e! Y+ T  c6 [

  34. 8 a2 }& R4 A; l
  35.     // ----------------------------------------------/ s( z* I3 ]* _
  36.     //  Changing Sketch Prefix names( w3 ]+ C/ x5 ]: L: G: t7 a4 J
  37.     // ----------------------------------------------   7 L3 _% d9 }+ y. k0 ~! B$ \( g
  38.       
    , ?% u- e  U- r" B$ N9 {  A8 x9 h
  39.     theSession->Preferences()->Sketch()->SetDefaultSketchNamePrefix("SKT_");1 G* Q' }% M/ r8 y! ]# q+ o

  40. 1 I0 Q4 Q" X: I) p8 h
  41.     theSession->Preferences()->Sketch()->SetDefaultVertexNamePrefix("VRT_");$ w# y; I+ @6 ^

  42. : N1 e, G3 E" K
  43.     theSession->Preferences()->Sketch()->SetDefaultLineNamePrefix("LIN_");
    ) d2 T! y* Y" e. Y- F. p' X) ~0 {
  44.   W9 @2 [. U) p) J; w# \+ V
  45.     theSession->Preferences()->Sketch()->SetDefaultArcNamePrefix("ARC_");
    ; L. D* ~+ \* g. }/ |
  46. . `! D9 @) n% h9 U, ^7 P9 ^6 t
  47.     theSession->Preferences()->Sketch()->SetDefaultConicNamePrefix("CON_");
    ; q! {+ }9 D( K3 b2 D
  48. " Z$ s( Z( L! d; D" P1 k
  49.     theSession->Preferences()->Sketch()->SetDefaultSplineNamePrefix("SPL_");       & P1 B" s8 V$ {& k1 G3 q
  50.    
    9 N2 A) ]# ?- R& l1 d
  51.    
    4 T& [7 V; W5 ]% s& X$ o' r
  52.     // ----------------------------------------------' D) |6 W9 [$ K) m. @6 z
  53.     //  Changing Grid values
    " w) f: n) I9 D
  54.     // ----------------------------------------------  2 W% ^3 j4 c5 W
  55.     0 X$ U2 p+ Z3 @& r* `+ B' r: @
  56.     Preferences::WorkPlane *workPlane1;2 ?# f$ j* o' l
  57.     workPlane1 = workPart->Preferences()->Workplane();# z3 N! X2 Z7 ]  L( R* {4 M* |7 Z
  58.    
    * j- `# z, b4 ^9 d
  59.     workPlane1->SetGridType(Preferences::WorkPlane::GridPolar);, D! M6 @1 U+ j1 ~! @0 }1 b/ J+ W
  60.    
    , _$ I& \7 Y3 J6 }0 o. @
  61.     Preferences::WorkPlane::PolarGridSize polarGridSize1;
    3 W' L; ]* G/ b0 w! \/ i/ }5 I
  62.     polarGridSize1.RadialGridSize.MajorGridSpacing = 75.0;: X: S1 {0 e/ F' ^
  63.     polarGridSize1.RadialGridSize.MinorLinesPerMajor = 3;
    1 w! Y9 o- b- N( K! I) a
  64.     polarGridSize1.RadialGridSize.SnapPointsPerMinor = 5;, U4 |. u2 h# S2 a6 m: v  I
  65.     polarGridSize1.AngularGridSize.MajorGridSpacing = 45.0;2 s( R9 Y8 L2 ^( y9 t
  66.     polarGridSize1.AngularGridSize.MinorLinesPerMajor = 4;9 K# F" i  E5 v7 W1 Z
  67.     polarGridSize1.AngularGridSize.SnapPointsPerMinor = 2;
    ; F0 z6 B7 \8 K- Z0 h- l3 }5 }
  68.     workPlane1->SetPolarGridSize(polarGridSize1);
    & O8 X  o5 ~* t' h
  69.    
    ; y/ v7 o6 u) p3 i1 a/ I
  70.     workPlane1->SetShowGrid(true);
    2 c$ p5 s4 }8 K9 L+ `( `) z
  71.     - V; u0 `$ Y3 Q; M5 Y! K, a5 a
  72.     workPlane1->SetShowLabels(false);$ ~- [6 k# @/ Z- s0 o4 ^6 p
  73.    
    ! O* m7 t/ s5 O( ?1 c/ G
  74.     workPlane1->SetSnapToGrid(false);
    7 n( g! X8 |! `  q: w  C6 p
  75.     $ x8 d9 U* _* l: ^
  76.     workPlane1->SetGridOnTop(false);' r6 H& Y9 K6 I, R- e
  77.    
      G6 s* T' ~3 h$ U1 e7 k
  78.     workPlane1->SetRectangularShowMajorLines(false);
    4 ^, L; Q$ K9 f5 Y; p  I
  79.    
    $ ^1 g$ g$ u( M6 q
  80.     workPlane1->SetPolarShowMajorLines(true);
    7 x" ]0 L* ~. f7 W* U
  81.     4 ^( G3 Y' \) Y  \* l0 M' ~
  82.     workPlane1->SetGridColor(130);
    4 e$ g" {* [. u/ {/ D
  83. }
复制代码

- W& |& D; K) t2 I, n" S% ^: i( X% T" \4 z4 t" |
4 _# x; P- B- q/ H
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了