|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
( e: D8 }6 I9 MTeamcenter ITK二次开发源码分享:创建测量单位unit of measures
% Z3 _+ O$ u& P5 {' i
6 y) f8 c; T# K' Q* z- #include <stdlib.h>& W' k$ @; w, h9 M
- #include <TC/tc.h>$ N% b$ \' z2 i0 z5 O0 r: `
- #include <sa/tcfile.h>
0 G5 b3 F. _" k2 H: V - #include <tccore/workspaceobject.h>6 f {4 S' q l+ ]( \+ i2 k) y
- #include <ae/ae.h>
x- e9 [/ _- `1 B+ b - #include <tccore/item.h>3 E6 i3 a. G7 Q* S. @8 S9 S; z7 u
- . q# B: T! e* x: x- N" J
- #define ITK_CALL(x) { \. ]7 Q, @1 z# t) {' r9 F( u
- int stat; \7 o' e6 `/ z+ _" u
- char *err_string; \. |( _* K% P$ S# _$ K6 t
- if( (stat = (x)) != ITK_ok) \
) T" R+ D) V, J - { \- q, ~# q' Z( A7 _
- EMH_get_error_string (NULLTAG, stat, &err_string); \ e4 {& Y9 k2 Z; `
- printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string); \
( q- T& K* Y" K - printf ("FUNCTION: %s\nFILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
9 d1 z- z# \! M% n' D5 G - if(err_string) MEM_free(err_string); \
( b* U8 ~- z7 v/ v$ }, T* B5 }) S - exit (EXIT_FAILURE); \
8 ^1 u- s! B2 Y" a5 ^ - } \. _# g5 }& u# Q: i+ k4 q6 L0 S: S
- }. z" ~9 E* {5 e% Q
- #define EXIT_FAILURE 1
; t, j# b9 @0 v1 m) o$ Z @3 ? -
$ {5 ~2 R4 H4 C9 g! E' ~1 Q' b - static void do_it(void)
' O# B1 t: `: y. }, B - {
1 G- `- W) _3 Z' R1 G( N - int" g# C2 g# K8 t) h. }0 l
- n_uom,$ } a& e& Q7 T, @: m
- ii;
2 `. e' N$ W l6 e/ } - char
9 `( s- k* o! `$ X0 s4 A - *name;0 ^/ W6 c+ r* f P6 r. ~; }
- tag_t8 p: n( K2 M# O! T) H
- *uoms,* x9 F7 e, U" g+ q& B7 B) d" W/ @
- new_uom;
$ ~1 L9 [1 C8 b* n! R6 E2 E& s -
, _0 b) k8 K4 Z: u/ U - printf("Before UOM was created...\n");
: \2 w! C7 `: X& a5 Z - ITK_CALL(UOM_extent(&n_uom, &uoms));# o3 V$ x2 ]+ g L$ s" V! Z
- for (ii = 0; ii < n_uom; ii++)) [$ O" Q6 o: Z
- {
( O2 P: z; m; q& c' `! D, u% A - ITK_CALL(AOM_ask_name(uoms[ii], &name));& i2 h; u( N5 R |3 D
- printf("\t%s\n", name);
4 V! x$ s" v: b2 [0 i - if (name) MEM_free(name);9 Z( X/ e" ]7 l" a
- }
. W# u: N/ M% [' Y5 F; Y - if (uoms) MEM_free(uoms);
6 f7 ? t5 P" W -
1 A& Q6 i% ]- H( c2 H' X6 j - ITK_CALL(UOM_create("inches", "in", &new_uom));5 O$ t3 |: r+ p9 _! F6 D
- ITK_CALL(AOM_save(new_uom));
7 {' e' |; H# a5 | - / |9 w2 o6 u/ n; Z) m
- printf("\nAfter UOM was created...\n");
I/ O; L9 C9 U0 ]' W1 d1 B1 A; j - ITK_CALL(UOM_extent(&n_uom, &uoms));
" C, D X- p$ t6 J# l - for (ii = 0; ii < n_uom; ii++): J( J, _% n" T0 i1 v0 V
- {0 e2 |7 q& E( j6 F- |( u0 \0 s) X0 A
- ITK_CALL(AOM_ask_name(uoms[ii], &name))% [; G- t3 t- q$ {3 D% Y
- printf("\t%s\n", name);
& z6 Z& D) V! {+ \ - if (name) MEM_free(name);
: r/ @! T W, H" w6 A) H1 R - }
& Z% W; C* e4 i" G0 f( y. r8 E8 ^ - if (uoms) MEM_free(uoms);$ s9 l4 N* E5 Z% l* s* x' ]
- }
2 l+ X ^% a: b! C; E, D: c8 Q
( Q% k4 F1 Y {6 H5 n" l: J- int ITK_user_main(int argc, char* argv[])% K; i) A8 w. Y; y1 v
- {
% w) B: }2 d; r5 X - int
+ F9 {% z, {' P2 q8 p% q - status = 0;
6 c5 b4 o* P1 R0 r - char: n% Q6 a. H: }9 `0 T7 `8 j
- *message;7 {% e' w! {& [+ r. _9 Q# Q3 N4 e
- ]( e! G3 B2 \/ I( {: r+ C
- ITK_initialize_text_services( 0 );; k9 j" h. D& @6 C/ F9 A
- status = ITK_auto_login();7 R' t& F0 ?. [$ j/ f" G# f
-
8 m- y h+ M! ~0 o) R) m* m - if ( (status != ITK_ok)) printf("iMAN login NOT successful.\n");
% k" o! y- \4 m: l% s - else
+ H) ]. h# d, ^, K - {" A9 o) _7 |& M3 S4 i
- printf("iMAN login successful.\n");
% N8 H9 D( T! D0 _, l7 m) ^ - ITK_set_journalling(TRUE);$ {; o5 ^/ V+ ~- u9 N
- do_it();: Y0 o# t% p7 ~4 E- M
- }, _* X# t8 w) n) l4 e
- ITK_exit_module(TRUE);6 G$ O4 x8 X8 A2 a1 t
- return status;
- i. B3 t l$ M$ a - }
复制代码 6 g G5 ]# H0 f$ X
& L* q0 Z5 e) A8 ?0 R
6 H8 r, j n) W& ^. M9 {8 F& j |
|