|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
7 @/ l8 j3 Z. S7 x1 d7 O
Teamcenter ITK二次开发源码分享:创建测量单位unit of measures, ^) F5 q1 A1 V6 s
& y3 d& g5 W( c J9 y/ P' Y
- #include <stdlib.h>6 R8 h' y |3 }
- #include <TC/tc.h> H) h+ y$ n: R. h9 c+ M
- #include <sa/tcfile.h>% d# }. V4 r" `: c" d7 u
- #include <tccore/workspaceobject.h>
5 y% N& h8 }2 s* h0 J" L - #include <ae/ae.h>8 _4 S* T- T7 A9 g. }1 F
- #include <tccore/item.h>
( ^* a! }! N. a7 v& R- K
/ m! b$ W3 Y2 {5 Z/ D; T- #define ITK_CALL(x) { \! d W c; R- H& Q; s- g! L9 U3 r
- int stat; \
; _. i% C6 `' M7 @' V% g' U6 } - char *err_string; \ M$ S7 w% @, g0 K/ I0 x( E
- if( (stat = (x)) != ITK_ok) \
3 e' [! Y* o! M4 ~" E s - { \
5 o$ I/ |1 {( z! p - EMH_get_error_string (NULLTAG, stat, &err_string); \
! ~& W& C1 j) R; {5 h - printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string); \
8 g7 x& C5 ?( S; M6 h; a O) p3 F$ W4 q - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
8 E% q' k: J( x4 k, u - if(err_string) MEM_free(err_string); \
' S+ O- o2 c. y6 t - exit (EXIT_FAILURE); \
6 l O3 N2 b6 Q' v4 j- D - } \0 L4 v' ~3 w% H% c$ H, q
- }
# c9 i0 c/ b: q; F; E4 J - #define EXIT_FAILURE 1 4 S+ v8 r4 f5 E. L F
- : l. J; b. b/ U* C6 ^# L. |/ p: K
- static void do_it(void)
4 ^0 a2 S# k, D - {
. A: j( w3 h5 L- F - int
+ s: ~! f/ e, y' R3 A - n_uom,
; |, m7 n3 v4 y6 ]/ W* ?, @ - ii;! C4 ]) l5 x8 r1 _9 Z# p8 \, T
- char
) q N0 b* ?. J4 ]# S5 O - *name;/ s2 t( H) W* Q# A, b2 T) B
- tag_t
: ]& X4 ]; V3 j: F! [5 L7 X - *uoms,+ V7 Y# b4 G2 E! [ c
- new_uom;/ K# ~# t1 t4 t1 V! K0 s
-
0 @ f5 I _) x) b8 ^5 z - printf("Before UOM was created...\n"); 2 f k- x' b/ a7 V5 ^9 G
- ITK_CALL(UOM_extent(&n_uom, &uoms));% M, z' ~( n. p0 I Y3 |
- for (ii = 0; ii < n_uom; ii++)
! N0 @0 B! g5 V4 l: ~) N - {5 ~0 D# i h0 [
- ITK_CALL(AOM_ask_name(uoms[ii], &name));
: Z U9 s( _* y) w3 C, R - printf("\t%s\n", name);
( g$ a, k# W1 z7 g: `* @ - if (name) MEM_free(name);
a% T/ _7 F! F: ~ - }# B4 I4 z9 X- ^
- if (uoms) MEM_free(uoms);( S1 |0 Z8 _+ m- i, J
- ; e$ ?+ }7 b$ `" Z0 P& S4 Y3 J( _
- ITK_CALL(UOM_create("inches", "in", &new_uom));
6 ^& w& ^; E* V' F# Z6 S - ITK_CALL(AOM_save(new_uom));3 a- r8 p+ n, B! i& ^
- / e; r5 B( g0 Z1 W0 u
- printf("\nAfter UOM was created...\n");
# ~- `% ?$ G# o, ^+ Z% ` - ITK_CALL(UOM_extent(&n_uom, &uoms));# Z/ W/ g$ I& C9 v3 |% H
- for (ii = 0; ii < n_uom; ii++)8 \" q K# U7 U* W0 x6 B
- {
) P: ?$ e7 }, H+ t" Y - ITK_CALL(AOM_ask_name(uoms[ii], &name))
4 L0 h6 }, p" n - printf("\t%s\n", name);' U5 Q- m3 }* O" k5 n
- if (name) MEM_free(name); V" t2 f$ k8 ?# @7 A4 u
- }# U% J6 x9 M- X9 c8 r9 c
- if (uoms) MEM_free(uoms);
! T4 W6 F* Z+ @3 p5 T - }
* D9 G5 I) h2 q9 {3 J, E
3 y3 c9 c+ C' { g6 W- h- int ITK_user_main(int argc, char* argv[])
% y+ x; T$ U& j4 Y4 h - {0 T7 I w p' `3 u
- int' V* [( J$ _8 a. t" g$ d5 X9 l
- status = 0; & [# L( c6 Z" m. B' c5 M
- char* H( U$ N8 f* r2 Z! o* f5 |
- *message;3 ], h; F! d: x- @5 }# n
- 2 E2 w/ Y6 j% J
- ITK_initialize_text_services( 0 );
. p" i8 c1 C Q+ C* g) _ - status = ITK_auto_login();4 f2 G' }0 g2 L" |2 `0 r) V
-
' n0 J9 V- }8 w9 i L9 u - if ( (status != ITK_ok)) printf("iMAN login NOT successful.\n");( B4 h* N" ]8 z9 k' M& I+ _
- else4 j) W5 S8 E R1 f. ^0 b" G: {
- {
% ~' z# M& H; ~9 ~ - printf("iMAN login successful.\n"); s- H4 X" c) S# E5 ]4 {: u
- ITK_set_journalling(TRUE);1 N, [5 N# e: q8 C4 Y+ |
- do_it();
$ a* b: Z' K' r0 ~. ~ - }; w4 N; M) r8 z/ T5 n1 U4 R; {" `. z
- ITK_exit_module(TRUE);1 e+ M/ \6 r) @8 U' M6 K
- return status;) \+ ~% g9 g s( S/ a& V3 P# U
- }
复制代码
# r# J- k, o7 {. r& G+ `# R3 A6 o! M0 N' g- [
3 S8 W+ V1 ]; n- h |
|