|
include <stdio.h>- y/ T' `; f( }' b' y
#include <uf.h>
7 T& {8 r+ W. B( W& J$ w9 b#include <uf_ui.h>
! k* @$ H; E/ V, O* A) G#include <uf_attr.h>
2 Z5 @6 ? A6 c2 s2 a0 u: g#include <uf_modl_utilities.h>
6 l% I( k% z. }% \' e$ n#include <uf_modl.h>3 Y# G6 [! D; o3 m
#include <uf_attr.h>6 ]) s9 p, e6 I$ j; {- i
#include "A2.h"; I2 ]4 p7 J+ n) m( X. s, B1 F# _8 T
" q# b8 P3 ]5 W) m* P
6 @5 g' z7 }% X$ h) i3 Y
/*****************************************************************************0 O r" a9 a- u6 T- C
** Activation Methods1 {, c$ e: w r7 X6 j5 o0 N9 S
*****************************************************************************/
% G+ q5 L) |. u- Z9 B
f4 X1 B* x0 @, V5 b2 M) n/* Explicit Activation
5 Y7 E3 [; \" k, M/ `! F** This entry point is used to activate the application explicitly, as in
# b2 d$ d. w3 j H! r2 ]** "File->Execute ug/Open->User Function..." */9 q! B+ e. F( e) ?* ~9 D) l0 p
void do_open_api()
6 [: Q# Y5 H3 q2 Q& U7 U9 F% V{' r" X! Y# j2 k+ f) n$ _9 c6 D
tag_t object=NULL_TAG,feat_tag;/ ^7 C# s1 j2 C: r1 _$ W f
int count=0,found=0,i;
- L7 I, b' G. A7 W uf_list_p_t feature_tag_list;& B! B! ?4 y$ G( I) N
char *feat_type,mess[100],sval[100];
" I3 [5 c+ Z# e' ^ UF_ATTR_value_t attr_value;0 E5 z6 ?) B4 g, X
/ M5 x+ N0 K3 r' y, f k! y' A9 \ UF_MODL_ask_object(70,0,&object);+ V6 }7 L6 u( G q) H6 y. h; R
if(object!=NULL_TAG)0 n/ W+ o' c9 b2 ?
{
) a g* v; M, V3 z2 N UF_MODL_create_list(&feature_tag_list);# P5 [* l8 ^- e0 J
UF_MODL_ask_body_feats(object,&feature_tag_list);
3 m' a x% m( s UF_MODL_ask_list_count(feature_tag_list,&count);8 y% B6 R! H/ \( W% \
for(i=0;i<count;i++)) K6 x* C# B: o# k, H$ F) W a
{* l3 e: Z9 Q% R
UF_MODL_ask_list_item(feature_tag_list,i,&feat_tag);
9 {5 _8 S, v, }. L UF_MODL_ask_feat_type(feat_tag,&feat_type);
7 V( ~8 i4 C' J1 E if(strcmp(feat_type,"SIMPLE HOLE")==0)
0 d2 n" B5 v6 x7 O! i+ {9 F# Y {
% p2 E8 @* t* h& \" @- j, J found=1;break;2 Q7 a& }! e) Z Q; P5 v
}
; Z& r: M. m" e7 |: w- l7 a }7 x$ i1 ]3 l/ A9 u+ ^1 @
}7 a* D7 c7 X0 n7 G8 _
if(found)4 r" X( V- ?% o+ W0 o% h
{1 b+ _8 W4 F4 F% b" e: ]
attr_value.value.string=sval; G( E& k' s* G: R9 ]( S
UF_ATTR_read_value(feat_tag,"孔标题",UF_ATTR_string,&attr_value);
& U$ @$ X& }- E' z sprintf(mess,"孔标题的属性值为:\n%s",attr_value.value);7 U% b' o& A" |; j* X$ i
uc1601(mess,1);6 }" |% N- k; s( d: p
}
. A( K5 X5 b a6 n else
1 |+ t; O% Y0 F" C uc1601("没有找到实体或类型为 SIMPLE HOLE 的孔",1);
3 |+ N6 M# O" ~! Y/ K' v8 O$ s}- T% l; N, B. Y7 V+ a+ ]3 U1 n8 ?; g
3 W0 K1 x" {2 j. R
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )& f4 a4 I) T- p8 J$ ^& f- F
{
. D' ]; [( O- @ /* Initialize the API environment */
; S, r7 ^+ ?' ~% c. a M int errorCode = UF_initialize();
* k0 a9 R9 F o3 h2 Z
; s# [ x3 f* J- D4 ` if ( 0 == errorCode ), Z( P( q- y" E8 \
{ ]- W. H+ S& R5 I3 G
/* TODO: Add your application code here */
a) V2 l: U) U: h5 g do_open_api();
' k6 z5 M9 \ x! ]2 P* E /* Terminate the API environment */
8 n/ c2 X& Y9 D- H( { errorCode = UF_terminate();/ {) _& I9 H& h' P6 I5 K
}
L2 f- [- m1 G6 R$ ?
! ~: X! q, A3 @ /* Print out any error messages */4 x' _/ I+ A7 r
PrintErrorMessage( errorCode );4 n$ i2 w: Y9 l8 D0 ^8 J# |5 z$ ^1 `
}
. O) I$ H/ B9 _- B/*****************************************************************************
2 R q, T4 @0 \** Utilities
' z8 n$ ~+ |0 s. J: p*****************************************************************************/! o% r7 o$ b1 c/ p: m9 A3 G0 c
3 M0 k R# g5 Z/ K$ {
/* Unload Handler
5 I% C$ y2 l' z( x4 N** This function specifies when to unload your application from Unigraphics.7 _: ?' X1 [0 ` r' i
** If your application registers a callback (from a MenuScript item or a, F) g+ `7 T5 t
** User Defined Object for example), this function MUST return/ J7 h/ r0 u. H$ k8 b: j" y* a
** "UF_UNLOAD_UG_TERMINATE". */, `$ U! T1 D8 f; z8 T
extern int ufusr_ask_unload( void )
# z* _9 y( p% m/ P5 Y& I! V{
6 D% B1 c6 ~1 o return( UF_UNLOAD_IMMEDIATELY );& ?; w/ }) F% r2 {3 |
}
0 B$ V7 w6 P9 t, ^, q' V& T$ b7 ^# d3 ]/ W0 K9 {
/* PrintErrorMessage
6 h' [& v* n/ H7 X" d**" C# ~ _0 J0 U6 B: j
** Prints error messages to standard error and the Unigraphics status
% P2 a( B( {9 N- w t, N/ q** line. */3 H0 Y3 i3 ^; E! Y
static void PrintErrorMessage( int errorCode )
) g4 o. j) G. p) m{
% ^' r+ B& c M+ N6 c if ( 0 != errorCode )* Q7 S* d2 r6 q
{( J( c- k) Z. b2 O& O" n
/* Retrieve the associated error message */! q9 z) d# j% R# y9 S& T3 k3 b& j
char message[133];
" H1 W& @! I" R UF_get_fail_message( errorCode, message );) R2 o; x/ ?0 d4 W
# i$ x1 Z4 i& i# ^7 I
/* Print out the message */+ l8 f' ^; d+ [
UF_UI_set_status( message );- Q6 R5 C( X8 J# \/ ~9 R
" u9 X: V& c) o' K# V- [( x5 g fprintf( stderr, "%s\n", message );+ c: n( R* i8 z
}
/ f& w6 u" p- E- n}
6 u: s3 ]$ U2 o/ W7 G6 r! E |
|