|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
) w9 ~( l1 L$ h! S* w
Teamcenter ITK二次开发源码分享:创建测量单位unit of measures
! E( _+ S7 Q7 R* B. z% @ V: ]# \4 ^$ g9 V
- #include <stdlib.h>
, U9 }! }! r1 `" t) F- e+ x. g; _1 U - #include <TC/tc.h>
! n9 P; C8 ?" d; L# w - #include <sa/tcfile.h>8 z$ u, E3 B* t6 y* E! }( E
- #include <tccore/workspaceobject.h>
% w0 s/ ^! R6 [! T% ` - #include <ae/ae.h>5 W# B* L) T; z Y* ]
- #include <tccore/item.h>
u! v5 S" m0 k$ B/ O - # J( g1 v0 h5 f0 {; H
- #define ITK_CALL(x) { \
/ z8 I+ E" R- M% D' a - int stat; \- r/ n. g9 W: K q5 Z6 ?# R
- char *err_string; \
/ r. S7 h( K/ Q - if( (stat = (x)) != ITK_ok) \ i7 `# \& S' ~7 \
- { \( M: B; l, I# U% y* T% g5 H' b0 A
- EMH_get_error_string (NULLTAG, stat, &err_string); \5 v" ?" @" O- B
- printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string); \4 d c6 y+ c. Q9 {
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
- e; q( O% d8 s' H0 R9 I7 V, n5 v - if(err_string) MEM_free(err_string); \% F8 C; { Q! B3 R; r. G1 N8 X
- exit (EXIT_FAILURE); \
# j% |& N$ R1 ^+ M - } \7 m5 [6 p( |( S) d3 ?. x- F
- }
* s( ]7 r. m# x. g - #define EXIT_FAILURE 1 ' I& X! U v" O. `. P: B, @+ c; |
- 8 b9 l- U) Y/ r6 w
- static void do_it(void)
' S) { L$ A4 N' o: z3 [! Y - {
T, g3 B3 I7 b - int! Y4 ^# H6 t# ]; G' `6 j/ X
- n_uom,
) c4 c+ U* q- g0 g3 i4 @ - ii;
- i3 }0 t! B- k: i' f - char( M: G/ I$ U6 w+ r9 W
- *name;
" v0 {. m# |) {9 L4 p, c! G" _; x) J - tag_t& P8 E0 v6 c; u3 r
- *uoms,2 P2 P3 V. U5 d0 Q# x/ l
- new_uom;
8 |( ^ h& S! D. O o) t! R4 B -
; j y# W. G+ P, W - printf("Before UOM was created...\n"); 5 d( ]* i h$ N; S" I
- ITK_CALL(UOM_extent(&n_uom, &uoms));
: g0 v: m9 U5 i) r- j9 |8 N7 l6 G7 l - for (ii = 0; ii < n_uom; ii++)& } j2 {' R: U+ ~& C6 ^
- {- A6 O% Y" Z# U) b4 O
- ITK_CALL(AOM_ask_name(uoms[ii], &name));- X5 U% M! D3 |9 y6 C8 l' w/ }* ?
- printf("\t%s\n", name);- I: x& d: s6 ?1 o; L# I
- if (name) MEM_free(name);
" h M: t9 A, e1 C) } - }! A* ]0 Z- E# z) c+ H# p. E
- if (uoms) MEM_free(uoms);
2 x1 o$ s( n& l4 B- e -
" }0 a7 h2 f; j$ |2 \- E - ITK_CALL(UOM_create("inches", "in", &new_uom));3 O) s h% I1 ?( e4 \" f
- ITK_CALL(AOM_save(new_uom));8 S) _9 }/ K# D3 m
- ' e, M3 H+ n4 d! m( v9 }
- printf("\nAfter UOM was created...\n"); 6 }4 Z* c# s4 l2 P
- ITK_CALL(UOM_extent(&n_uom, &uoms));% J+ b* [! Q A: h E" B. u* w
- for (ii = 0; ii < n_uom; ii++)
6 i3 V& S/ B* h# L, g - {/ e1 D& ~! y) k3 s
- ITK_CALL(AOM_ask_name(uoms[ii], &name)); P4 `# R7 B2 O! u: V
- printf("\t%s\n", name);
. I' |* f f9 V' D3 O3 V* \ - if (name) MEM_free(name);7 G( s: u2 Y. j/ v* t, f
- }8 T% _: `0 t; O" P3 c
- if (uoms) MEM_free(uoms);
. a4 `" |0 X0 x0 `& N - }7 c7 B7 m% ^5 M2 b
7 Z' w5 U4 J4 I' U6 J( n- int ITK_user_main(int argc, char* argv[])
, ~8 D }' Z& W6 w/ f4 ? - {0 }. M8 d2 |7 v/ C. P/ r
- int6 k# P" n7 m3 z2 @# c
- status = 0; $ g1 O! E2 J, d6 Y
- char9 J, V7 C$ H' v
- *message;1 E3 w" P. [' p4 g
-
7 H8 c$ {( {" c - ITK_initialize_text_services( 0 );' B( P6 e) t* M: `2 e
- status = ITK_auto_login();
! e5 ~& B t0 c# b; J* f - # C" ^- s ?6 M. S. `% A! ~( T
- if ( (status != ITK_ok)) printf("iMAN login NOT successful.\n");
% m( U ]* p. s2 P1 P& u0 M( y - else" e, S0 d) s$ W9 y
- {
, j6 k- U$ g# O: T: J& @ - printf("iMAN login successful.\n"); Y% } T7 e. Z: e: Q0 \6 G
- ITK_set_journalling(TRUE);
2 \4 `: t4 S" I2 z% q - do_it();
9 [5 `7 y5 f3 o1 _. }6 Q" q. | - }
9 l0 P) R B- b. ` - ITK_exit_module(TRUE);! a1 L1 z8 W$ H& s t) L
- return status;
: g, z6 F& e7 O2 Q, U& J* I2 n - }
复制代码
! R/ q+ W: O: p. q; t& n3 V$ [0 y9 l, o6 K) M" @. u2 | ~
' K+ i; _1 J4 T9 J( l: F- |! e5 G |
|