|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
6 M C% J9 |2 ] c3 ]& B9 u. BTeamcenter ITK二次开发源码分享:创建测量单位unit of measures/ ?5 J% p. c P1 Y: b- R
% B9 d2 M; M- k9 b% Q% i/ [3 Z; Y- #include <stdlib.h>1 e2 M5 Z' L" e% F) Z% C
- #include <TC/tc.h>6 N h6 z' P+ {( p% g
- #include <sa/tcfile.h># r9 L4 w, \. h2 v) K, b/ G
- #include <tccore/workspaceobject.h>
1 n# {& g* }* [: M& o6 \ - #include <ae/ae.h>
: B& t( H8 g* H$ |6 Q/ A - #include <tccore/item.h>6 b. P0 k( j {1 v
- : G5 x6 c/ T2 Y' x% P5 j7 J
- #define ITK_CALL(x) { \ J! i: \, R2 w5 P
- int stat; \
0 V: c8 l6 B/ ?: G; a. Y" G# s - char *err_string; \
8 y$ }4 ^) \/ X8 e- E - if( (stat = (x)) != ITK_ok) \5 w, y& N: R! ~1 \& \( R" k
- { \
, v N& w& t- C: K$ b9 a - EMH_get_error_string (NULLTAG, stat, &err_string); \
% R3 C7 ]! @- P7 ~" O! y4 | - printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string); \
# i9 G, }& W7 C4 r2 v - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
' O' K1 X' L3 p q" E* ~ - if(err_string) MEM_free(err_string); \
9 y& ~& P( H2 T+ m9 d# {: }# D$ I - exit (EXIT_FAILURE); \# ]1 A% o: C- {) d
- } \
; c- ~7 I! I2 o) O - }- ], z, `! |+ X6 C [
- #define EXIT_FAILURE 1
x r1 U- G& A; ?6 d0 g5 O" j( ^$ _ -
. O, ?9 L9 ^" G+ V* ?+ Q! J- f# T - static void do_it(void)1 n* ^# `2 n, g: V/ A
- {+ u) Q/ H* I' h$ V9 J/ G- I
- int3 V. l% ^ P: S, l1 T
- n_uom,
; H, W" c2 ~" b - ii; H+ O. `. Z& I& H" J: O) ^
- char
; A w& s5 L9 ]6 B! n; B- V - *name;
* S N" \, i# ]/ z8 A9 H - tag_t
( i5 j' _% ^$ { - *uoms,
; P, b0 m/ g3 ?" c" I" t& Y - new_uom;. h: o% v6 S; y
-
* F+ }0 x/ |/ S/ `9 R - printf("Before UOM was created...\n"); U0 i4 e( M+ k- B5 H9 A' {
- ITK_CALL(UOM_extent(&n_uom, &uoms)); D `, {; a. W: D5 O
- for (ii = 0; ii < n_uom; ii++)6 P$ g3 A2 m) d' @2 E
- {
( r0 I! B) k) m$ V - ITK_CALL(AOM_ask_name(uoms[ii], &name));
, N; Z' V5 X! t+ d- R. w6 x - printf("\t%s\n", name);
; Z# ~; j. b4 I, \5 g6 j - if (name) MEM_free(name);
# j1 _) k* p6 ` - }0 O v2 |2 D# e6 K: R8 W
- if (uoms) MEM_free(uoms);" H* n# c4 a1 Q, x
- 6 m/ a3 o' i* G$ Y$ {
- ITK_CALL(UOM_create("inches", "in", &new_uom));/ [3 \+ i9 Z, ? }# D7 f/ d
- ITK_CALL(AOM_save(new_uom)); [( T; K. q: `- C3 i
- 8 i5 k8 |/ P7 Y7 Q2 v
- printf("\nAfter UOM was created...\n");
, d) n# t* S, U; V* X - ITK_CALL(UOM_extent(&n_uom, &uoms));1 n$ ^7 d5 m! a4 v+ y
- for (ii = 0; ii < n_uom; ii++)
p8 z: U) S0 _: F! I% G* G - {
6 R0 Q$ n1 f. n; L - ITK_CALL(AOM_ask_name(uoms[ii], &name))
3 X4 s$ ^ k8 A6 s! C$ b* W# | - printf("\t%s\n", name);' F; O5 s* S# } @: S z
- if (name) MEM_free(name);2 Z8 x! {% F! ~# g0 n: u. }
- }( P& h) y5 c4 e0 |
- if (uoms) MEM_free(uoms);
, \2 M: M( m$ x& C - }% Z* |3 j: m$ b: \- G4 k
/ F$ B6 [& D F- int ITK_user_main(int argc, char* argv[])
" t3 C5 G& r3 \' Z( t# W$ }& u - {0 Y. y( O8 Q8 Y; b6 w* }
- int+ Y# N# K) K! a" s
- status = 0; : m; Q- m" b& p
- char: E4 S- Q/ n& t6 _# s5 Q' G9 Z
- *message;6 e5 }0 n8 T5 ]) n }
-
4 j2 b, D( s2 s3 _- m - ITK_initialize_text_services( 0 );
; y, l( |' Q! C7 F6 ? - status = ITK_auto_login();" F# c& I5 |. W, N. J
-
% I E' H5 G, g# G9 x1 | - if ( (status != ITK_ok)) printf("iMAN login NOT successful.\n");+ _( C5 D4 H% m3 g
- else9 q# ]6 h. z2 I$ r) r7 T# s% p
- {
" F/ l2 Q* K" ?2 Q, x+ y- | - printf("iMAN login successful.\n");
+ @) r: ^0 @6 m0 G - ITK_set_journalling(TRUE);
: N) ^$ ^- G1 J+ U# m - do_it();" w( Q) S% P3 Y7 } _0 j) F
- }1 @1 H) i2 {; P, G, d. w: o
- ITK_exit_module(TRUE);: y: z, F) Y5 f, B
- return status;, `4 I$ ]1 k9 @
- }
复制代码 ( y6 f) [* l" I8 h
* L" l* ]* h: h7 a" ~9 t( _% `
0 r' q) b, k6 Q5 {& \% c& A) u |
|