|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
2 [( Q! J% S, P
Teamcenter ITK二次开发源码分享:创建测量单位unit of measures& n" U! J& K) Y6 V- X" H
1 ^6 m9 g: I/ s4 ^& p' I6 b; o' d
- #include <stdlib.h>8 I8 C+ L7 V; E+ }5 `0 O
- #include <TC/tc.h># P% a) _7 {/ F! e1 E5 C+ A. U
- #include <sa/tcfile.h>
: S% `) m- b2 U; w: W - #include <tccore/workspaceobject.h>6 \" m+ S, T! ]/ v- s% t# d: U9 Q/ d
- #include <ae/ae.h>+ E5 B, ]$ f5 ?5 ?
- #include <tccore/item.h>. K& P' p! ]2 q$ X
- 1 s6 J8 L/ U `5 A' M; A
- #define ITK_CALL(x) { \8 h. B6 L# d c
- int stat; \2 ~: [7 N' G; v* U) _# X( C7 L
- char *err_string; \2 [' Y. e/ V8 @' ^2 ~/ W9 p1 f: c
- if( (stat = (x)) != ITK_ok) \3 f3 V; K- w$ J4 |5 I! [( ^8 c
- { \( ~; i3 T1 t7 ^* [5 K7 ?
- EMH_get_error_string (NULLTAG, stat, &err_string); \
6 |5 _% \' }3 |5 K* r& O - printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string); \
6 K1 d8 _* n6 n9 ~) j* |# i - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \6 p2 ?. O# O6 [# @ G
- if(err_string) MEM_free(err_string); \
0 j) D" }$ O4 K1 B8 I - exit (EXIT_FAILURE); \
U- ?0 P! ?: s - } \( E0 {) L( _+ D/ p5 ~$ r2 v# q
- } o( K5 R$ O0 O% X' ?. O
- #define EXIT_FAILURE 1 7 u0 \# y7 d* S5 P% S% x
- ) U) b- w" u2 S5 A0 g0 M
- static void do_it(void)
9 } ~$ q u9 K+ _2 ~0 ^2 w+ w - {/ ?6 X& R6 @; Y C V) L, O5 N! ^
- int
# Z4 e9 t6 G8 b# U8 k2 ? - n_uom,- K5 M8 M6 c6 }( T" N; r
- ii;
! p0 W4 q0 l+ U6 n - char
: Z0 K. W' N( {8 t. x - *name;
5 }; K- F r4 L, G# w+ A- c - tag_t3 A4 {3 u# h& M' b! [3 H+ t
- *uoms," z5 B6 ?! U- Z3 a; B6 |$ N
- new_uom;: s. {4 ~1 h. @7 a3 |6 ^5 G0 U
-
, |5 p" U; S1 E0 J: r M - printf("Before UOM was created...\n");
9 d. b d% h/ F; ?: K9 e" q - ITK_CALL(UOM_extent(&n_uom, &uoms));
7 k$ J/ K# G5 o) y* | - for (ii = 0; ii < n_uom; ii++)9 z# P$ h4 _2 q L" r- k6 B G* D
- {* R+ E' k" z" x/ ^/ H: K4 `' r! l
- ITK_CALL(AOM_ask_name(uoms[ii], &name));0 r: H# h% S8 v
- printf("\t%s\n", name);+ @' I8 k& [/ H1 N6 f
- if (name) MEM_free(name);
. x2 n/ a8 ^- ^( x7 K4 i - }
1 L/ {" |3 l" u - if (uoms) MEM_free(uoms);
' I' l9 C9 L+ P" U' S -
- d, c2 c$ u U3 i- d! q& B' _6 c - ITK_CALL(UOM_create("inches", "in", &new_uom));
7 U2 a5 B/ I0 ~. u P; h2 Q - ITK_CALL(AOM_save(new_uom));
- a$ v$ E8 \6 C - & J' z# N3 O" K" b7 R7 K
- printf("\nAfter UOM was created...\n");
7 g$ c; u- E) u9 H - ITK_CALL(UOM_extent(&n_uom, &uoms));
W" F/ d) o7 S) U1 l) m - for (ii = 0; ii < n_uom; ii++)
, L Z1 b3 p6 @+ @5 Z* C' [ - {
N0 m4 u& H, |" d; D - ITK_CALL(AOM_ask_name(uoms[ii], &name))% W1 F( {/ t$ W
- printf("\t%s\n", name);
, `- {- F* p0 f, t& t! k - if (name) MEM_free(name);
+ w/ [* l0 M2 W, N2 } - }* B" z. } K& [. F, c8 R c
- if (uoms) MEM_free(uoms);
! T5 X& `8 ?8 o - }. p2 u# |3 N( E/ G9 [
- 2 Q/ {7 N) O7 f
- int ITK_user_main(int argc, char* argv[])
* T0 \8 G6 l: t1 }0 h - {
8 H( D9 }3 ]7 K( U% Q - int- W+ f$ [. L# j: G% z: s
- status = 0; 9 I. i* ?* f' E1 I
- char* x8 N& B) A2 T& Q7 j1 E7 j
- *message;7 C. U" E" x7 W3 A. X, G% [: u
-
6 r+ y0 D* k; Z& e% P - ITK_initialize_text_services( 0 );0 V( y& w$ y ^) W$ D
- status = ITK_auto_login();* G& F& @& A% @
- % s. z5 j" U. K+ y2 q/ c7 O% ] l
- if ( (status != ITK_ok)) printf("iMAN login NOT successful.\n");
7 u m4 X4 W8 X L1 r! Q - else8 y+ ?: t. S- N4 e0 K4 b
- {1 m! r, |& N% @( E
- printf("iMAN login successful.\n");
( m' n4 P0 ]* M) y7 S( ^- `4 b9 k/ P - ITK_set_journalling(TRUE);
6 D- c, O4 h7 Z5 O - do_it();
& F" W- p$ t( J4 f2 N9 [! | - }
. Y6 ^1 V" f0 X, y8 m5 I, Z( Z - ITK_exit_module(TRUE);
. }2 B" c. j5 _% p9 H; s$ b# P) j - return status;8 W5 Z2 u5 P" p2 r- l4 r
- }
复制代码
& Z. _3 L- z, s0 {* K
" y3 d9 _) p+ ^/ |$ ]* _9 B; j$ i: {2 R, h
|
|