|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
+ U; H, e/ b1 g; {Teamcenter ITK二次开发源码分享:创建测量单位unit of measures! p4 S* Z6 H3 ?& P- G9 \
# [; A0 v9 q: M1 j
- #include <stdlib.h>! e% u; D( ?5 W$ F- R
- #include <TC/tc.h>
+ w2 W" r- z9 K7 V8 f2 `2 R - #include <sa/tcfile.h>' }' S7 _* u! Q7 c& ~! r$ W$ b
- #include <tccore/workspaceobject.h>
* _) F; d! I; j+ M3 V - #include <ae/ae.h>6 G% u' S0 E' q
- #include <tccore/item.h>: N j* n/ R7 t- X* B* |
- Y# Z3 ~: ?# Y9 m+ u' d5 j- #define ITK_CALL(x) { \
- N5 Y8 y7 M% ^; A _ - int stat; \
1 N% c0 W0 p/ V! w& u% t) T - char *err_string; \
. S* A/ N/ v, l" Y. O - if( (stat = (x)) != ITK_ok) \ K1 n+ m# r1 D( ]; K$ n- {/ r
- { \
5 ^0 L! W& {+ g' _* [ - EMH_get_error_string (NULLTAG, stat, &err_string); \
, ?8 ^3 G- n3 @; ~5 R# }, o! K0 z - printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string); \9 G7 Q1 Z5 c: b3 T
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
$ I' r1 z& v/ U* I5 G& ^+ E X8 @ - if(err_string) MEM_free(err_string); \
+ S# a! u# a2 m/ S8 _& K, j - exit (EXIT_FAILURE); \ Y0 F" S1 W7 h0 z7 V4 c( f
- } \
6 R8 J: D! \$ n: A% ?3 u( \ - }
4 l' e# Q' g7 q, r - #define EXIT_FAILURE 1 4 y9 i! ]1 p- M o5 j
-
$ I; P A7 n. }. |5 B* ^ - static void do_it(void)
6 Q- R0 B7 s0 Q S" Y+ G) Y - {& }# D4 D% E( f2 f
- int
# m6 ?- v2 V' k% r! D0 |) ~- F - n_uom,
; m& J. y2 S0 V5 A; e/ ^ - ii;8 R+ Z+ q6 H7 q. ?4 f
- char
7 I% B9 O8 V# ]9 l - *name;
+ U1 U+ I2 n' T8 s8 Z/ K' c+ s* u - tag_t
; `5 D7 v" C% |9 [ - *uoms,5 u1 l" V) v! d; w: c# I2 a
- new_uom;
5 D* A; u9 q: F( e) {% ~ -
1 z' c6 y, _6 k* S( a9 J - printf("Before UOM was created...\n"); 3 L" d6 S# ~0 P ?# ^) \: C
- ITK_CALL(UOM_extent(&n_uom, &uoms));$ n3 P! {+ D9 S% Q
- for (ii = 0; ii < n_uom; ii++)
& r4 l( Y/ R6 }! N, N1 |+ | - {* W9 t( j6 |- Y3 G7 f5 r
- ITK_CALL(AOM_ask_name(uoms[ii], &name));- C. l- O$ \5 y! t7 j6 _( {
- printf("\t%s\n", name);
) N$ g+ Q/ h a4 X. v, c3 h - if (name) MEM_free(name);
4 y* X' }6 t1 y' t* J) W - }
4 g: Q: @; ?( q& R k - if (uoms) MEM_free(uoms);
/ O- u$ P8 l g! ^" Q -
9 @. U' B. P" C, s! O2 z% c - ITK_CALL(UOM_create("inches", "in", &new_uom));
1 q/ w+ V, G3 I1 k) T& c1 x - ITK_CALL(AOM_save(new_uom));9 U8 E* W% h* F
- I( D) @) |3 t( A6 C; V
- printf("\nAfter UOM was created...\n"); 9 Q% H. u0 e8 }+ d
- ITK_CALL(UOM_extent(&n_uom, &uoms));
6 V! z/ G3 E/ c7 N" U, E' B3 b - for (ii = 0; ii < n_uom; ii++)! L/ Y. G- B7 U: X1 R# |$ ~# y1 j% U
- {* E0 T: P+ b" _
- ITK_CALL(AOM_ask_name(uoms[ii], &name))
$ u4 h! h) ]9 i) R' j% R - printf("\t%s\n", name);
1 \* I/ y0 j# T2 n7 |# w C - if (name) MEM_free(name);( l/ u: C1 j2 g
- }
' u' C8 c: J. L F& ]# V) J4 a$ s- b - if (uoms) MEM_free(uoms);
4 M" v% {4 n8 D2 g' Y - }
" R% w8 G: `0 z; H - / f6 Q+ U/ `+ h; H0 ]$ K
- int ITK_user_main(int argc, char* argv[])
: | {" t$ W" a6 M% y8 }$ m* Y$ j# }; G" p - {
1 ` v- }# h! s0 o0 O$ ^9 w+ k - int
1 J. d- C5 R# U |- S+ \ - status = 0;
2 v% k% \% [. A3 @ - char
3 Z2 I" z; B/ E! [# e) ^2 p0 j, R - *message;
( d) O7 O6 e. C5 q+ Z" ]. i" t - ( W1 q4 D8 e; r2 ^
- ITK_initialize_text_services( 0 );: v4 p% ^1 \8 `8 E9 J! r& H
- status = ITK_auto_login();
1 B0 D) Y, o. l! p' w* a) g - * k2 u# p" C, T) m" A. F8 L& f5 W: n
- if ( (status != ITK_ok)) printf("iMAN login NOT successful.\n");% K7 d2 n" C8 g! }! S+ ~
- else
; b5 m3 L7 s+ S9 @- Y v+ h% @3 u2 v - {
9 b8 w' L& O1 h v& t3 X - printf("iMAN login successful.\n");
6 f% S9 h$ f+ N& x - ITK_set_journalling(TRUE);
) @8 A; Q4 o& C. h+ y+ l - do_it();: I# {, x# Q) w9 }! i- t$ e2 t
- }
3 ^% ~: M; ]; |& v3 y m - ITK_exit_module(TRUE);
2 O: F& r2 x3 N3 B6 D - return status;
\$ P6 o* x8 B3 K \' l - }
复制代码
$ P z+ C6 ~, g0 z6 a1 E% t) Y; y% h, j( H. r) O
I% g. Q' v# Z8 t1 B* j$ _8 ? |
|