|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
2 y4 S- {& Z0 f* c/ I
Teamcenter二次开发源码分享:判断对象是否存在在数据库中' m; M! Y+ a1 n1 J; ?! e$ W; W" n8 v
8 B' b) c# _7 ^, P
#include <TC/tc_startup.h>$ U( C" G( [9 V* [
#include <pom/pom/pom.h>
& ?' v* p' C% z7 z0 s d#include <ITK/mem.h>
/ f$ U& @4 }2 d+ o: W6 a! e#include <tccore/workspaceobject.h>
# D. W: d/ { C, U: {6 f
: u _1 X3 O! V& E0 f( zlogical is_instance_in_database(char *variable_name, tag_t object)2 }3 F) I& S$ ]8 d5 w' j8 ?# F
{
/ J/ I, d2 H3 U% R" Q+ h9 n logical exists_in_db = FALSE;
" x. x9 {% D, Q! s4 Z ? if(object == NULLTAG) ECHO("\t %s: NULLTAG \n", variable_name);. Z/ L, ~ f; t0 K
else
* m0 c- w- F I8 H2 \5 ?, Q! X {. l" Z. {. d$ k( Y* Y h4 A
char *uid = NULL;
, B: O$ x2 g: Z) ]6 f ITK__convert_tag_to_uid(object, &uid);
1 A; `* m* N' i1 N& m+ f* `, M' V POM_instance_exists(object, &exists_in_db);
( z9 P1 S \# C% H if(exists_in_db == TRUE)
3 T h2 _" l( ? w5 P {
( y% y) Z% z7 c, r if(is_WorkspaceObject(object) )
4 \1 B* e4 j$ n& t. a {, X. D4 p0 \4 ^6 U
char *object_id = NULL;
8 e$ h1 W; I) W- B& p3 j IFERR_REPORT(WSOM_ask_object_id_string(object, &object_id));$ Y; F" d6 k f0 N" Z( Q
char *object_type = NULL;9 W" F2 A O) t9 e e
IFERR_REPORT(WSOM_ask_object_type2(object, &object_type));3 Q, h2 H+ f$ f* K0 x
ECHO("\t %s: %s - POM_instance_exists: true %s (%s)\n",
' a2 _/ E: E3 P! l: Q C variable_name, uid, object_id, object_type);. M" h+ Q6 a: k
if(object_id) MEM_free(object_id);
6 Q% r9 h6 M% B+ S) a+ u if(object_type) MEM_free(object_type);- l8 s( a" {! c9 P; K. L
}
( P) q$ @- ?) {, ^0 C5 o else ECHO("\t %s: %s - POM_instance_exists: true\n",
/ h1 T- }( L* | variable_name, uid);0 y( G4 C) o" [7 b7 u
}% I6 X- H3 U1 N1 O, i
else ECHO("\t %s - POM_instance_exists: false \n", variable_name);
: e8 Y1 S j3 v( a0 m0 t! Q if(uid) MEM_free(uid); E" Q! g) P5 A9 R5 W
}
) S% J$ c% j5 w# P return (exists_in_db);; }: v1 j2 d* K7 _6 B/ g
}" v' B1 D+ r$ J. M3 s
|
|