|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
3 z8 K6 \* O/ u+ r
Teamcenter二次开发源码分享:判断对象是否存在在数据库中
+ G$ \/ @0 ?& U. X. w% l
; c; j+ @$ [' `5 X9 `7 s#include <TC/tc_startup.h>" {( R1 x# F; a- B r. ]+ R5 {
#include <pom/pom/pom.h>
' `7 M; b0 E% u9 _, J#include <ITK/mem.h>7 X" A. Y, E/ A
#include <tccore/workspaceobject.h>& N S; z$ ^/ c* [7 I% o" R
- c9 `% E+ k) Y; w7 v
logical is_instance_in_database(char *variable_name, tag_t object)
5 _; F) K) J" u. V0 ]{
2 V ]/ `) F ~1 U logical exists_in_db = FALSE;
8 C0 ]- e4 w' \: G s. { if(object == NULLTAG) ECHO("\t %s: NULLTAG \n", variable_name);
% n. I7 `' s' G else% P& l2 h' p* L' s( a! s
{; F: P/ g2 N% t, t% ~
char *uid = NULL;
2 m4 C4 I& D3 @; V& R# r4 g+ }* J ITK__convert_tag_to_uid(object, &uid);9 q& |9 o( |) B8 w0 a. z" B
POM_instance_exists(object, &exists_in_db);
3 t; h2 ?/ b2 ]7 C) d: { if(exists_in_db == TRUE)& n2 r0 C9 |$ h
{
! H1 u1 Q4 @6 Y c& \ if(is_WorkspaceObject(object) )
3 g: ?, F2 P3 J' e5 e9 J: [ {& d. t3 J. `' I
char *object_id = NULL;9 }# T/ H$ q' C! a* J& f
IFERR_REPORT(WSOM_ask_object_id_string(object, &object_id));. {. j9 M7 B/ T
char *object_type = NULL;$ d# P8 b% l6 R8 [# k2 n2 g) m9 G
IFERR_REPORT(WSOM_ask_object_type2(object, &object_type));" c' s9 c/ H5 j$ e: b* M! X
ECHO("\t %s: %s - POM_instance_exists: true %s (%s)\n",
2 o. y6 n3 ]3 s# ^ variable_name, uid, object_id, object_type);/ s, A1 @" H; X8 u6 _1 t- U
if(object_id) MEM_free(object_id);
3 t0 x1 r) i- O# q5 w) z8 o z! L2 z: c if(object_type) MEM_free(object_type);$ s2 F/ W' g5 m8 V
}
& f, n2 t5 [& C v$ Q& X* ]' z& | else ECHO("\t %s: %s - POM_instance_exists: true\n",
5 J9 ^! M! @7 F9 f0 b variable_name, uid);
! m; a2 B1 X/ i0 o3 k- e }9 I. t. d w' Q
else ECHO("\t %s - POM_instance_exists: false \n", variable_name);
$ y. Y' q' c* n/ } if(uid) MEM_free(uid);* J/ a* v9 X( y( c# o5 ~
}4 P& I7 }7 c' z
return (exists_in_db);% x! E( P( k/ Q0 O: h# S, C
}1 }3 n* Y2 `1 X& W
|
|