|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
8 a) ~; j: j& {5 w. ^
Teamcenter二次开发源码分享:判断对象是否存在在数据库中
$ F* K! M1 C& V: H6 r: `& S* l3 L2 G: q3 B2 Y$ O% B" U0 o( b
#include <TC/tc_startup.h>
: G- {) ^8 a% v9 ?#include <pom/pom/pom.h>
- n, h# `7 e- d Z7 y3 Z#include <ITK/mem.h>6 P$ M- ^ ^ Q( Y
#include <tccore/workspaceobject.h>
M) d2 T+ B9 w, x5 `% e. E* G) R' z9 L/ c
logical is_instance_in_database(char *variable_name, tag_t object)/ M7 \5 R3 c' |. W
{
* f: Y$ a5 \* N logical exists_in_db = FALSE;
+ p2 s! |: r3 y, K) k if(object == NULLTAG) ECHO("\t %s: NULLTAG \n", variable_name);
8 F7 X2 B$ b7 m8 E+ t& U else
9 U4 C! J: w. H$ P {
, v# }6 g, _- ` char *uid = NULL;
4 H" m; c7 Q/ J- ]$ P ITK__convert_tag_to_uid(object, &uid);% w* `+ T( t! I# t ?5 P7 f
POM_instance_exists(object, &exists_in_db);
- A# ?$ D# W) [2 z& i7 e7 O if(exists_in_db == TRUE)/ _) E# C. |! ~9 L8 J
{* v, I/ Z% g2 _' i7 `7 v
if(is_WorkspaceObject(object) )
, G2 r) ^1 ^6 { {( n o6 M9 t4 _8 L% m
char *object_id = NULL;
" o1 U9 k% |. ?: v IFERR_REPORT(WSOM_ask_object_id_string(object, &object_id));
N) Z g- \3 ~* i: P char *object_type = NULL;0 A" ?( a7 J7 F+ p! ^
IFERR_REPORT(WSOM_ask_object_type2(object, &object_type));
% ^0 a* g9 s* _6 J ECHO("\t %s: %s - POM_instance_exists: true %s (%s)\n",
" T4 k' O5 s$ n/ K$ [8 {4 U variable_name, uid, object_id, object_type);
6 p* M4 i9 A+ B* y) a# w8 ?% ~0 K if(object_id) MEM_free(object_id);5 i& \: s1 N1 x
if(object_type) MEM_free(object_type);- A$ [6 J8 C& x
}
& e6 K$ A- P2 |9 z else ECHO("\t %s: %s - POM_instance_exists: true\n",
9 C5 Y$ y5 \/ T. r/ u variable_name, uid);
4 F9 I1 w5 j* }: H& e# k }
c, e6 x; t4 T6 r2 S% h/ V else ECHO("\t %s - POM_instance_exists: false \n", variable_name);8 ]0 }" e9 ^; s/ j# N
if(uid) MEM_free(uid);
% s( i0 p8 y5 o& n" |2 o! l; T& _* S: { }
" d. W$ `$ d) W3 I return (exists_in_db);+ L3 {4 T. N1 e6 K
}
7 J; \% N) o7 ^7 M' {6 |% B; R |
|