|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
y; E7 r$ D9 m0 s4 W+ _: l6 E
Teamcenter ITK二次开发源码分享:创建测量单位unit of measures' j( r% e+ e! T, Z+ D
2 N0 T' l* o1 [1 I9 K- #include <stdlib.h>' }, L7 t: T1 P' }4 M* o
- #include <TC/tc.h>! ~9 h# @- J0 u, h1 C* I3 G
- #include <sa/tcfile.h># n8 l3 G9 K1 H- L: P B6 Q
- #include <tccore/workspaceobject.h>
+ `! `( k) r0 Y9 I6 V - #include <ae/ae.h>
) w6 y: U: _; b- h+ K: g! }2 k - #include <tccore/item.h>( X! B- i$ e! e, y; H: f# g
0 W7 w% M. T+ R1 i. }- #define ITK_CALL(x) { \3 n6 c7 h) Q) g2 T
- int stat; \
, E& Z' J! y( l - char *err_string; \
6 \. c- s: }0 `: H - if( (stat = (x)) != ITK_ok) \! O8 s8 {+ ?3 ^3 ~2 c& T. ?5 K
- { \9 x, g& B! D6 f; C* J1 I
- EMH_get_error_string (NULLTAG, stat, &err_string); \, c7 Q( k5 ]$ C9 }7 [# }
- printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string); \. w% M& j# y1 `7 ?/ [
- printf ("FUNCTION: %s\nFILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
9 m N0 s% X3 d& o9 x u7 W; B - if(err_string) MEM_free(err_string); \6 g. ?6 x, b8 E5 c
- exit (EXIT_FAILURE); \
n6 S6 t) e. W - } \
2 U' Q ^6 }' F/ G5 H) m( M2 W - }
8 S# i& Y9 S9 u) }3 _ - #define EXIT_FAILURE 1 . P0 ]* n- u: `/ v
- ( L) V4 u" {4 ?5 E" n3 W
- static void do_it(void)
& m2 y" Z! f6 G- T; b% a; `+ X& O - {
8 R2 a6 O, J, W# K; Q - int
* A$ V# I# H2 Z6 P1 S0 B( ]9 T - n_uom,5 O( {* d' Q, b5 c3 u
- ii;9 G+ t$ l" p: K! @& a1 F5 s6 ]
- char( d# Y2 L7 C5 ]2 w) _8 ~
- *name;# q0 G) C) W4 _5 l7 v% j
- tag_t
& B3 s R$ e: s+ L# J( \ x/ ` - *uoms,. ^9 |9 X9 z# ~7 y$ V4 w( W
- new_uom;! N$ _$ E. y9 S8 @/ |. X8 i2 [
- ) f# d; X5 V- [& }9 b: e1 w4 [
- printf("Before UOM was created...\n");
8 {1 ]6 Q* [3 n8 F1 F* Y - ITK_CALL(UOM_extent(&n_uom, &uoms));1 O3 n' a4 J9 U2 X; W+ V
- for (ii = 0; ii < n_uom; ii++)' l5 ~8 s9 ~5 I( ?* {" B0 w( K8 p# p
- {
* p: C" ?7 T- @ C; s/ B$ X% J - ITK_CALL(AOM_ask_name(uoms[ii], &name));
1 F& ?% ], \3 p P/ V - printf("\t%s\n", name);
0 U, P' n- [& L; Z$ H - if (name) MEM_free(name);
! ^# T2 f7 U p3 Q, Q5 |% V5 N$ ~$ u - }' g; a! b: v8 ~2 @7 C# @3 Y3 i
- if (uoms) MEM_free(uoms);
, N& y$ z5 G: V& v - * n5 A6 w, O9 l0 m2 U. z& e) S
- ITK_CALL(UOM_create("inches", "in", &new_uom));5 h1 i2 K7 \: T& D
- ITK_CALL(AOM_save(new_uom));
% [* F0 C i2 T! G7 D - 1 z! \ c9 B! E
- printf("\nAfter UOM was created...\n");
7 {" j+ k2 n( U2 m- h6 e, d - ITK_CALL(UOM_extent(&n_uom, &uoms));8 g3 G4 V6 [4 b& l* Q: p
- for (ii = 0; ii < n_uom; ii++)) B. n6 M# a; Y! Y% h R
- {
' k3 _" ~$ f5 I [" c. D4 M( p: l - ITK_CALL(AOM_ask_name(uoms[ii], &name))
& M/ n, }6 o+ Q - printf("\t%s\n", name);$ b0 B9 R/ G+ y4 V$ x, z& g
- if (name) MEM_free(name);
% j, i' h5 n |0 E7 d - }5 I, H8 H$ a! a) F
- if (uoms) MEM_free(uoms);
+ J+ a! g" r' k0 e4 r - }" O$ N9 S9 ]+ T, s5 }3 S" V# Y5 ]
- ! p3 {2 x+ s" S7 a1 |- C0 F
- int ITK_user_main(int argc, char* argv[])
( {, B: p) R' W9 |7 V0 F' y - {
+ L7 s2 t" m; m. V b - int
: R; w! R7 Q6 b: K% M5 M$ U - status = 0;
) U1 Y5 o' `: x" Z - char
0 H. x" K+ O( I* J4 g - *message;
! _6 S+ N+ W. A& R) c1 z9 _ -
7 r, N& `: u& Z - ITK_initialize_text_services( 0 );0 i4 m( o M) G% u& b! C
- status = ITK_auto_login();0 t7 E* B$ y0 K$ B4 Z9 ~
-
( ^ f! F: A4 [- {# S: K/ ~ - if ( (status != ITK_ok)) printf("iMAN login NOT successful.\n");
# A& o" {+ Y" p- F- ? - else
5 D0 g6 T/ ~% U( k( K$ W: D; [ - {/ N: |3 L# L- W& V& E
- printf("iMAN login successful.\n");% N# o( B* z, U5 V; Q7 W6 k! T4 |% v
- ITK_set_journalling(TRUE);( U9 B* i$ P0 O B
- do_it();
) A' N- i. M1 x6 {$ J/ U- K6 H: B% U1 L - }
& o/ n2 A+ |0 U% M* i6 Z; S$ h - ITK_exit_module(TRUE);7 ] a9 j. h8 O* f
- return status;
# x$ q0 |, Z# c4 p: V - }
复制代码
* D" }. i. d: @& F
6 s( A0 ]0 Y* o' V, Z( \2 e. B, v* \. C
|
|