|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
* U2 d' v. c p) ?& [. _- q
Teamcenter ITK二次开发源码分享:创建测量单位unit of measures1 {! d3 A2 B" a z/ t# U* n
0 r7 P& Y* T& f- #include <stdlib.h># q( Y" ~9 G. Y+ G4 k* l3 q
- #include <TC/tc.h>5 k# T; K$ d. T+ G6 H
- #include <sa/tcfile.h>
* G# h% r4 E* }9 {. `7 N7 l - #include <tccore/workspaceobject.h>
! J7 d+ k+ W8 e& a! n0 a0 P, l - #include <ae/ae.h>8 P8 j" K4 H- ? {
- #include <tccore/item.h>
9 u. j% L" k- o( ^( t4 D+ U
# e% q) h% i* Y8 @8 e2 ~- #define ITK_CALL(x) { \
5 J! U. u* A |, u B! v - int stat; \
5 W1 I% ^8 v6 o1 x: ]* f - char *err_string; \
; K# b& [8 Q4 p$ K* Q! R - if( (stat = (x)) != ITK_ok) \
8 P$ W8 j! h& }& Z3 M! k - { \
- @4 b* F1 H/ G/ c" ^ - EMH_get_error_string (NULLTAG, stat, &err_string); \3 w% B9 p+ ~& K0 U' D( I) r
- printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string); \
: ?& ?* c+ Y' L ^: o9 R - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
$ Y7 L4 b& b8 A) o$ N7 p; {# A - if(err_string) MEM_free(err_string); \4 ^) w) u* K. O1 `5 d0 r
- exit (EXIT_FAILURE); \
& m, \/ ~- D. z* z/ z1 p - } \
/ v6 w% \: S4 N' s& b - }
/ c( n+ k/ M0 b( W7 A% V - #define EXIT_FAILURE 1 / r1 l, X9 T; |; ^2 x
-
* f' ?4 d% o* p/ H: y - static void do_it(void); Z" r# i& J* R! I; l6 c- F9 L
- {
4 h/ S" b1 X! K5 ^ - int3 ~( u9 Y% ^1 o! i6 {9 q" O
- n_uom,
) E( ? x4 }" n5 Y/ t - ii;0 q, f% u( y" ~3 j( H* e: g
- char/ L8 X( g' f0 h4 D, i Q z
- *name;
! n9 g3 Y3 F7 C. v6 r, m+ E9 M - tag_t0 S9 A6 ~* H5 y( x% L! }- L' @
- *uoms,! y3 Z% T: l1 b# @
- new_uom;
- G$ a# N; T8 ? -
8 }- q- p$ P% f3 g! B - printf("Before UOM was created...\n");
& B, B. V( Q5 H$ e - ITK_CALL(UOM_extent(&n_uom, &uoms));
4 E k( P& _9 \% I& t - for (ii = 0; ii < n_uom; ii++)8 c" q, D) u: i! z4 h
- {% k( D7 H, ^: [0 F$ s) }4 n- F3 A3 J) e
- ITK_CALL(AOM_ask_name(uoms[ii], &name));
5 q* r% }4 s; @( P# b - printf("\t%s\n", name);, p0 O P2 ?+ A% Y) W
- if (name) MEM_free(name);
) I, R. ~7 P: F" v, r- _ - }
2 e. I4 D3 V. R# w1 `# A - if (uoms) MEM_free(uoms);
3 S! a1 d0 @4 r9 J" \ - 1 k+ Y; Y7 _* _. O* p& w
- ITK_CALL(UOM_create("inches", "in", &new_uom));
5 Q ~. E# o8 ~1 B - ITK_CALL(AOM_save(new_uom));
; y; o+ s, q2 _9 S - $ Y q8 `- Z" I8 l6 E) @
- printf("\nAfter UOM was created...\n");
3 @; H4 d% Q' j+ `. n7 n - ITK_CALL(UOM_extent(&n_uom, &uoms));
' y: o6 I5 P' ` - for (ii = 0; ii < n_uom; ii++)3 Q& q1 l# F0 g/ F) Q$ {3 n
- {
* Y2 y0 p! [+ u& O1 w( K - ITK_CALL(AOM_ask_name(uoms[ii], &name))
3 T' Q. F9 u5 E4 N* j5 Y - printf("\t%s\n", name);
}3 T1 y$ W/ e$ [$ g3 ?4 d - if (name) MEM_free(name);; G7 \2 i6 F+ I) H9 ~% m
- }5 Z% C% I) F" {* F6 N
- if (uoms) MEM_free(uoms);
F2 r7 K7 H. A8 d: |' B - }2 c3 i+ ^8 y4 V7 E0 z
4 d0 p( S% F7 e2 F, Q% A- int ITK_user_main(int argc, char* argv[])
/ `# d/ E5 g. N' i, `) v - {
- ^. w7 s) s) G3 W. w - int$ [' p+ V! d6 W# s2 Z
- status = 0;
7 G8 z/ z# ~7 l7 g$ x6 y - char( G4 u# m% T" e% L; \
- *message;" M2 v- a; T( @# Y3 N2 ?! i$ P
- - u- Y; j1 U# S" S% w/ f" a* z
- ITK_initialize_text_services( 0 );
5 V* Z4 p* ]4 j+ V8 i - status = ITK_auto_login(); K$ |. y* v% t, \2 R- U
- * i2 W U+ g y! [# u! Y0 L2 R3 D
- if ( (status != ITK_ok)) printf("iMAN login NOT successful.\n");
) W' y3 m. N4 N! M' A - else0 { K) L, i+ I" G
- {0 @& W `, k: F! v& R
- printf("iMAN login successful.\n");
9 A# v' a: A; C. S; D - ITK_set_journalling(TRUE);; ^$ }* H; d1 F/ j
- do_it();
9 ?. p6 \: h4 X* Q - }9 N+ ~. N" l, p2 F4 V7 f
- ITK_exit_module(TRUE);
0 \& L* E6 \6 o+ ^% U3 l - return status;
( V0 ^' |( g* q - }
复制代码
3 @* G6 s$ }. u4 ]. \8 R1 S
, m4 k% l: y; v* e( S3 H5 J. d& ~2 u0 [8 E6 U3 _4 X
|
|