|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
9 P- F5 C6 v! B* R
Teamcenter二次开发源码分享:判断对象是否存在在数据库中, r: x9 }6 Y0 l7 C! e0 w3 K
, p( G9 C# ]7 s" t#include <TC/tc_startup.h>0 y$ [4 ~5 m9 y8 X: [" Z
#include <pom/pom/pom.h>
. H% ]( r) x4 t& i3 w#include <ITK/mem.h>$ C" I8 d% d# v8 s2 a/ o9 b% D2 J
#include <tccore/workspaceobject.h>: k; v! V# P; w8 L! }; L! u
% C% q, q0 [6 P# I1 t2 T. o
logical is_instance_in_database(char *variable_name, tag_t object)
) |$ {9 g% v. q{
9 C' ~$ c; k% T2 [6 P logical exists_in_db = FALSE;
" c1 M! U& y& J9 J$ g, o9 u if(object == NULLTAG) ECHO("\t %s: NULLTAG \n", variable_name);
- C# b8 U) f$ _4 h: r: e7 w else
1 X$ M) i: b3 M* Z7 C" j9 S' t: L2 Z {
* A' B! D; H" s% ^% `9 L char *uid = NULL;
3 _) z! ` b+ f; u ITK__convert_tag_to_uid(object, &uid);; k" o# c( G. x0 y
POM_instance_exists(object, &exists_in_db);
6 ]3 U: S) Y2 Q O8 u2 t4 p if(exists_in_db == TRUE)/ w6 j b! F7 q4 Y, B3 b7 M5 U
{# w3 r: P0 T7 Z
if(is_WorkspaceObject(object) )4 y5 N% g$ S; x. d* J
{8 N# W4 r3 n3 u0 g
char *object_id = NULL;0 h# u( l' A9 A; W: c3 a9 \6 B
IFERR_REPORT(WSOM_ask_object_id_string(object, &object_id));, `& R) K; f$ U( {& T5 s' Z
char *object_type = NULL;. z% v; g* y# c& d4 F: k
IFERR_REPORT(WSOM_ask_object_type2(object, &object_type));0 Q' {. O, p6 p, }' A
ECHO("\t %s: %s - POM_instance_exists: true %s (%s)\n", 8 v( O- j" Q3 A0 {4 b
variable_name, uid, object_id, object_type);
0 c2 D1 ~! K; j/ _ u& L2 T/ H& | if(object_id) MEM_free(object_id);
I3 E. \1 O2 N if(object_type) MEM_free(object_type);
4 w7 D) W9 }! v E5 T* G2 X# [8 C" V }/ T3 s2 b" S8 o* a/ ~
else ECHO("\t %s: %s - POM_instance_exists: true\n", $ P4 O3 I3 W$ l+ d. D
variable_name, uid);
: o% K% g8 G7 l) U6 z A) P+ c3 | }
4 X* A t# [& Z5 D( R else ECHO("\t %s - POM_instance_exists: false \n", variable_name);1 D6 g, `% `5 n1 P
if(uid) MEM_free(uid);
8 L/ h: e- \( h' u5 E }% D' r) X# d0 h
return (exists_in_db);9 H2 }7 k( w9 I+ I7 h `, H; a. J4 O
}
8 g) g4 b' ~5 V6 Z9 _ |
|