|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
& E2 u0 s/ f" o. DTeamcenter二次开发源码分享:判断对象是否存在在数据库中3 ]- v* X. A% I3 \5 z
6 E1 P5 q# p0 d! B#include <TC/tc_startup.h>7 O9 {3 O# r5 w" w q
#include <pom/pom/pom.h>
! e7 N: k T& A; G#include <ITK/mem.h>
, E) U+ z$ q' N! {& i2 n3 h' M#include <tccore/workspaceobject.h>
! j. y3 r; p% X4 C p: ~8 o& p$ m/ c% f% \ k- |
logical is_instance_in_database(char *variable_name, tag_t object)
' r* g( H- u9 P& b4 G ?1 u# @{
+ b1 N" G7 _+ D6 z+ ?) C2 ~' A, K logical exists_in_db = FALSE;
* w5 _0 n0 Y. `! M5 M' | if(object == NULLTAG) ECHO("\t %s: NULLTAG \n", variable_name);
+ G, S3 W* S6 J& |* V) q, R else" G- `% S! U, _9 F) ~
{
: P3 u$ f- R8 g" {$ c/ I+ b char *uid = NULL;
: w- t0 P- N, c% v" f- q2 Z: z ITK__convert_tag_to_uid(object, &uid);
, t) _: R4 _! |, J, v, r* e7 D POM_instance_exists(object, &exists_in_db);
! w* T, @& w r5 B1 n& ` if(exists_in_db == TRUE)' b5 M* e# g, R/ r2 B" O
{
4 N: y7 L# m, T) X if(is_WorkspaceObject(object) ) U4 A/ S M6 w2 ^0 f
{' B9 i: U( W' @
char *object_id = NULL;) T6 L+ D0 e! z4 |7 r/ y+ O! P
IFERR_REPORT(WSOM_ask_object_id_string(object, &object_id));
1 s7 r% @1 S; B9 i6 j4 q& o8 q+ B char *object_type = NULL;
1 X7 J2 U. [ f% ? IFERR_REPORT(WSOM_ask_object_type2(object, &object_type));0 w5 J/ L2 h- A3 o8 j
ECHO("\t %s: %s - POM_instance_exists: true %s (%s)\n", S3 @! H/ Q% b4 F
variable_name, uid, object_id, object_type);
6 `, l. u) n" U7 d P. q if(object_id) MEM_free(object_id);
: v" D/ F" K, e8 \/ W; |8 e if(object_type) MEM_free(object_type);' l K* ?5 {" d: m; a- A
}
/ J9 \* g$ [% l, O7 }- h4 K else ECHO("\t %s: %s - POM_instance_exists: true\n", ) Z3 j3 |9 _: u& h! `! f1 B
variable_name, uid);6 }) V0 }, a/ o! `
}
$ s0 Q+ x; |# U+ ^' J, I3 q else ECHO("\t %s - POM_instance_exists: false \n", variable_name);/ w& U3 a# g0 {( Y$ ]
if(uid) MEM_free(uid);1 Z( s" k0 o& m2 J
}1 W7 w3 U( b; l O' t
return (exists_in_db);
2 G$ i: T& {+ c% m* m}" ~: \3 m* Y6 C! Q4 f
|
|