|
include <stdio.h>) A: {4 v- ]3 Y
#include <uf.h>$ ^: h" O: \' _$ h
#include <uf_ui.h>4 e! |1 H; J& `9 ~" T
#include <uf_attr.h>9 H/ [* s5 @; d) |5 m; B5 W
#include <uf_modl_utilities.h>
; O5 M3 d/ W: _: @, v: l8 a#include <uf_modl.h>* U! S% p+ | `7 q+ n5 A! n, b& j( D& j
#include <uf_attr.h>% ^1 t) I! |; M) w
#include "A2.h"
5 f3 C9 Q, w) ^2 V, m+ e7 g7 M3 Q) Q- ~8 ^4 @# D4 u- A3 |8 E
( m. D% R8 b+ x1 u: F/*****************************************************************************; t/ f$ e9 R5 p; \
** Activation Methods/ A: K L2 h: q, ^' r6 L* u
*****************************************************************************/
; O" K4 L8 v7 J8 d7 J, z6 H. Y
( k8 c9 S, r6 G/* Explicit Activation0 T: Q, w. R. o3 J
** This entry point is used to activate the application explicitly, as in
( e' M/ w7 a3 Z2 C2 Q) {** "File->Execute ug/Open->User Function..." */+ A- o5 C8 O9 {. M$ Z9 W
void do_open_api()
* \2 b; D& }+ `% y" c3 M) e{9 r# k1 r' L: M0 }3 b
tag_t object=NULL_TAG,feat_tag;$ h, X) ] F" v8 L
int count=0,found=0,i;- ^* o+ r/ l" D3 J; d$ L! m d3 `
uf_list_p_t feature_tag_list;
, F. Z9 W) b6 I2 }6 {% k% ?4 d/ q char *feat_type,mess[100],sval[100];
% ]1 `5 I3 H3 B. }1 [* Q UF_ATTR_value_t attr_value;9 b) g( o# I! N, V
+ F+ F: ?1 }6 D( P' y/ W( j5 y
UF_MODL_ask_object(70,0,&object);
) T, A' b* a$ p9 U2 s if(object!=NULL_TAG)9 y( n4 ~0 v6 X1 E* ]
{
0 ]/ k' V7 I3 C UF_MODL_create_list(&feature_tag_list);, ^8 J4 C4 Q$ \( G" Z: E; d" ?7 t
UF_MODL_ask_body_feats(object,&feature_tag_list);) E+ C9 Q) T. |
UF_MODL_ask_list_count(feature_tag_list,&count);
# O T- F' \7 r( |* _! {+ X# U: { for(i=0;i<count;i++)
8 w I. a( j1 |, Z! ]; P$ N, W {& l8 g( r( h# n6 M1 g' T# r5 I, [
UF_MODL_ask_list_item(feature_tag_list,i,&feat_tag);
' J* U) m4 q/ R9 c UF_MODL_ask_feat_type(feat_tag,&feat_type);) k9 V. ~; _& _% p" p' q7 z7 e
if(strcmp(feat_type,"SIMPLE HOLE")==0)- z$ C0 f& x. w8 f& k! x5 |
{9 T6 `+ P6 U) b% U, S7 h0 |
found=1;break;6 y3 ^% [% ?6 v$ a- b/ `
}( V: l4 n4 X3 s9 a+ s7 b: C
}) D j6 k$ q% `" k8 ~% w* g0 E4 ]; Y
}3 h4 i- n2 U$ Z3 y0 k! C. S+ g
if(found)6 b7 i8 \# \6 o3 V4 A
{
s- b% V# j3 i attr_value.value.string=sval;( P4 A7 }: ^ ~- c [
UF_ATTR_read_value(feat_tag,"孔标题",UF_ATTR_string,&attr_value);
/ j1 a0 @7 [) G" _ H& { sprintf(mess,"孔标题的属性值为:\n%s",attr_value.value);
! e) m" d: n# U1 Q uc1601(mess,1);
4 S/ D* M/ n4 u }( E6 ^0 V# M$ A, c; E
else8 t* J! s/ c! Y4 y$ G- V
uc1601("没有找到实体或类型为 SIMPLE HOLE 的孔",1);
2 G" ?" l4 s r5 Y# w% P0 d3 K}, K/ d, w: d6 X( z% m+ U
0 | L; t, s3 B; ?extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
) F4 ^1 J* f8 ]* q: O" |$ T{
2 l& c/ y! E0 |. [ B* ~ /* Initialize the API environment */
: M" A) p5 Q1 Q! j$ \ int errorCode = UF_initialize();
. |7 V6 h% E H! R, c/ n' j$ R% i0 n+ i1 g3 ]* O" X
if ( 0 == errorCode )! l1 a6 b+ p) t. ^/ G0 V
{6 P' t3 s6 t; H1 ]! x8 Y) @% X
/* TODO: Add your application code here */* Y2 a6 d3 A/ w4 C
do_open_api();+ }4 d9 d( z3 P2 U1 t8 v6 X0 b3 j& j
/* Terminate the API environment */
! f$ M& c5 \# b |( r8 w) u errorCode = UF_terminate();
4 R5 a S# T4 H. r% \3 w4 H }" O/ M4 r# x; C3 _) p
: \) y; a% W: ?$ z0 w/ V W* L/ x
/* Print out any error messages */
) r4 j% ?6 V' M PrintErrorMessage( errorCode );
@* {3 g5 g9 S5 E# ^- N0 g}
3 F* @. A: w) W( X/*****************************************************************************. ^: ~7 U, `) h. b. k) W T
** Utilities7 F; h' t8 i1 V/ T! i- M
*****************************************************************************/
& r7 X) M N y. P4 S2 L# h
% `" h2 c) l/ l" K9 i" `" h/* Unload Handler
7 _' P. G8 _4 U1 V# q4 A/ A# w** This function specifies when to unload your application from Unigraphics.
& E$ H& j' n3 L- i) c6 L+ g** If your application registers a callback (from a MenuScript item or a3 p' q3 q, B2 ^. G* F9 U4 y3 ?" y
** User Defined Object for example), this function MUST return
; r. @) c6 e1 {1 T$ J2 W. r** "UF_UNLOAD_UG_TERMINATE". */0 B# F H8 _3 J6 }
extern int ufusr_ask_unload( void )
, |2 `) P' a+ L5 |+ E{
4 k, i; Y/ n/ J) K/ u return( UF_UNLOAD_IMMEDIATELY );/ U; |) G4 a' _8 F4 N
}* Y+ `' o* E$ I7 F6 v7 W' l
1 \7 C! E6 T) v7 t. p
/* PrintErrorMessage
" e* s! u6 T( c( {9 G+ @# p**1 ?; `$ ? n+ w
** Prints error messages to standard error and the Unigraphics status
0 b1 q3 A' j j1 l+ W** line. */
% E9 l! M5 h) g; D$ tstatic void PrintErrorMessage( int errorCode )* A/ P2 C' T0 x, N! P6 H
{0 w5 i% C8 x. y: j
if ( 0 != errorCode )6 I+ J+ i7 r' v" ]
{8 O% B G( H3 z; i# N6 Y
/* Retrieve the associated error message */" [* k2 x8 [. P+ e2 e2 @/ Q
char message[133];
7 e5 a$ C/ D7 K. ^1 e2 h! w4 s+ p UF_get_fail_message( errorCode, message );
1 }2 d" n1 r, _0 c) y! s( G! O- ^, |, q" C" Z2 X
/* Print out the message */
' D M( B+ t* U4 M7 U" u UF_UI_set_status( message );
4 o6 C6 t2 v4 k0 |, e; M( `) R" Y/ }! [+ @# g. R
fprintf( stderr, "%s\n", message );
" @! n0 E2 X- `0 P3 A d3 V }4 z2 l7 i) R3 z. h7 B$ N
}, a6 Z9 u$ z8 ^0 ^0 v
|
|