|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
; e3 O# ^/ S) O* ^* V9 J S
Teamcenter二次开发源码分享:判断对象是否存在在数据库中
% u5 A& b0 h, v4 l) `. W9 T" F: l* i7 R8 u& ]' K5 q
#include <TC/tc_startup.h>
4 [0 R! h# R6 j" P#include <pom/pom/pom.h>
6 M' q; H t& }. C, @' [#include <ITK/mem.h>
; r4 L% w6 H7 k/ I: [#include <tccore/workspaceobject.h>
" t' T' m1 m) C, {
+ K+ P) u8 N' ?/ r. q% Glogical is_instance_in_database(char *variable_name, tag_t object)* N4 e! b! J, C$ t3 Z6 @
{
2 Y1 i& z+ F) A! c logical exists_in_db = FALSE;' m( z! p( D$ |1 n1 A0 Q
if(object == NULLTAG) ECHO("\t %s: NULLTAG \n", variable_name);% ]7 O; u- w9 l- c5 y; a, b% J& w8 S! }
else1 c- v8 A% A! r8 R) y6 w: T
{/ x, @1 q, x/ ?( Q0 A B
char *uid = NULL;% d' Y1 r3 H# @! j- o
ITK__convert_tag_to_uid(object, &uid);# c* P7 `. t+ K* g& M: B- T. p
POM_instance_exists(object, &exists_in_db);' _9 c0 y* p* G: W# @- ^* {
if(exists_in_db == TRUE)/ Q, U, M0 }1 A$ s/ q6 u
{$ }4 F/ } s1 C2 y' h) h) z
if(is_WorkspaceObject(object) )
, z: Q" {% N4 @1 i% Y% q; p: T {% N( h9 P8 a% q4 d- J
char *object_id = NULL;
P1 |/ j! _- ~8 S* b0 t# r' z IFERR_REPORT(WSOM_ask_object_id_string(object, &object_id));
4 z: i# N: w/ g5 v* k3 t: J% P) u5 V0 b char *object_type = NULL;
9 D* F6 p; [$ M! ? A5 R IFERR_REPORT(WSOM_ask_object_type2(object, &object_type));; P6 L1 w3 |8 u+ o* {3 P4 O4 I
ECHO("\t %s: %s - POM_instance_exists: true %s (%s)\n", ! c) c7 I1 g( A* ?3 b
variable_name, uid, object_id, object_type);1 q! H* |' ]" @% p8 }2 X! t$ x% v# o& v
if(object_id) MEM_free(object_id);) S, G; U! V/ Z5 L8 e
if(object_type) MEM_free(object_type);
7 Y6 ^. O K! a: j8 ~* S9 l }7 t- h. a* M- S# L% f
else ECHO("\t %s: %s - POM_instance_exists: true\n",
9 z+ E; m2 Q; K variable_name, uid);
) l" ~# b/ \) f, a( t& H }; E$ g( G5 t, Z+ C) f/ ]
else ECHO("\t %s - POM_instance_exists: false \n", variable_name);
( p( O5 {: `1 u) Y if(uid) MEM_free(uid);
( ~; w1 K+ l% R2 f4 O% O0 Q N }$ y. L, k# Z7 ~# o [ |
return (exists_in_db);
! k* Y9 m' C a; p}
6 |7 f; j! O+ g+ _' A4 @ |
|