|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
. U% b R) U+ ^- y. YTeamcenter二次开发源码分享:判断对象是否存在在数据库中9 v( x! Z# |! S
. X$ K8 ^& t9 l: x- d! j* O& ^#include <TC/tc_startup.h>
. G% y3 o1 [7 i) v#include <pom/pom/pom.h>
3 m+ @7 a9 Z) ?; j) ^7 e#include <ITK/mem.h>: S& J- L0 t: K4 q- b) U) P6 m9 s
#include <tccore/workspaceobject.h>. y9 T) e# ~: d! j* \1 Q% [$ A5 ^
% B1 g, d4 O/ U) O! t. _ p
logical is_instance_in_database(char *variable_name, tag_t object)
0 q, L) @" v. l# |{
% P7 e) U$ Y8 K, d1 E& R logical exists_in_db = FALSE;
4 Q8 b; R- r; x3 O/ m% c if(object == NULLTAG) ECHO("\t %s: NULLTAG \n", variable_name);( K7 E p+ S( {! ?7 s4 e
else
, M7 `! i* [# t {
. p* Z) V/ z' \3 H4 b! K char *uid = NULL;
8 A8 Y' r9 w0 L( j+ t ITK__convert_tag_to_uid(object, &uid);8 w7 Q7 Q! `$ q1 c4 h
POM_instance_exists(object, &exists_in_db);
0 X D F/ Q2 D! u if(exists_in_db == TRUE)- V7 C' d5 M/ A0 C
{9 g& x4 v1 {: { f
if(is_WorkspaceObject(object) )1 L" k/ x: g, h) H% B
{/ u6 J i5 d- }2 X& @
char *object_id = NULL;) @: m6 o5 Z9 f$ U
IFERR_REPORT(WSOM_ask_object_id_string(object, &object_id));
9 C) _4 ?; C/ P* j' A5 @6 V char *object_type = NULL;
5 l: e& }) q& c5 X" [/ f) D IFERR_REPORT(WSOM_ask_object_type2(object, &object_type));
5 A5 x) [ o, L: A8 C$ }$ z ECHO("\t %s: %s - POM_instance_exists: true %s (%s)\n",
( J: X, _ p7 L' b variable_name, uid, object_id, object_type);6 a# h1 z" f9 B
if(object_id) MEM_free(object_id);
0 K$ ]" g( y# f* }0 Y0 W if(object_type) MEM_free(object_type);
# I" {6 L1 p: S9 p3 b }" w( r/ J8 C; T
else ECHO("\t %s: %s - POM_instance_exists: true\n", \. @1 X, o! [2 _) f/ c
variable_name, uid);1 Z+ V) i; s( a
}
0 g! N( E, Z3 L+ N7 D8 W else ECHO("\t %s - POM_instance_exists: false \n", variable_name);5 o: P. G2 [* X
if(uid) MEM_free(uid);. H4 |5 d1 X0 Q9 z7 P
}2 R( p: x( |& M4 K& m0 T# r. }
return (exists_in_db);" \4 o9 g5 o; R6 e8 w/ n ~5 B9 ?
}/ @" R7 C2 ?$ P. F8 h
|
|