|
include <stdio.h>( C; ~* H5 @2 h& H9 f* Y
#include <uf.h>
1 `8 l; m, J3 w4 l- d#include <uf_ui.h>
, X9 Y4 E8 n! }+ I4 T3 b2 t4 P0 T#include <uf_attr.h>
% f, F2 a% B" g" X- m0 A( c#include <uf_modl_utilities.h>. {! N, ^. L# G: C
#include <uf_modl.h>/ s$ R' z k4 F
#include <uf_attr.h>
2 S# J/ M- l2 z1 `8 ]8 V#include "A2.h"
& B, v# V; K* W7 ]; |, O p# U4 F
1 E6 c/ G2 s$ C1 J# ^% u- _( f
' t& A! I! c; l* e( L/*****************************************************************************) r+ B8 e8 Z# ?9 t
** Activation Methods b8 R v3 v* B) m8 t$ O; R
*****************************************************************************/
/ c7 ~' |2 y3 O. p$ e4 Q/ G; v. n- ]* Z: m7 U0 Q
/* Explicit Activation4 l z; {0 h3 T6 h% Y
** This entry point is used to activate the application explicitly, as in
1 T1 C- D2 i+ g V4 v' Q** "File->Execute ug/Open->User Function..." */ W/ B$ H0 ~: D0 J, w5 @" }, B: J
void do_open_api()
# Q' p$ n. r# G) I: U% C- s{( p* {0 n e4 z% V
tag_t object=NULL_TAG,feat_tag;
+ A/ c2 x5 w2 {& U/ ?5 d int count=0,found=0,i;
- k0 s0 {' q4 K; a& C) q5 E; W uf_list_p_t feature_tag_list;
+ O: c( p5 u4 `8 n# C% U' y5 s( } char *feat_type,mess[100],sval[100];( |6 C8 ~2 L( d- O% d+ i7 x
UF_ATTR_value_t attr_value;
/ K, B! q6 B1 |7 ~2 Q+ |$ S6 ?( ~; a1 F* |
UF_MODL_ask_object(70,0,&object);, Q* k# {& U8 m' f( d* Y9 V
if(object!=NULL_TAG)% c0 Z1 h3 N' K" s
{
. N0 j4 G% x* ^* ]) J" T9 ` UF_MODL_create_list(&feature_tag_list);5 O9 Z) F8 ~" p4 h
UF_MODL_ask_body_feats(object,&feature_tag_list);5 P$ h) H) b. |/ ?. U4 h8 P5 c
UF_MODL_ask_list_count(feature_tag_list,&count);
* j& m O) u5 L+ m% k1 i/ P6 } for(i=0;i<count;i++)
0 Q) U5 F* X( V, v4 ` {/ C, U* d2 G7 |: q: j& ?
UF_MODL_ask_list_item(feature_tag_list,i,&feat_tag);6 r% b. R! q8 H" q/ [7 n
UF_MODL_ask_feat_type(feat_tag,&feat_type);( n& n) R/ C) S! ?0 r
if(strcmp(feat_type,"SIMPLE HOLE")==0)
8 L) D- t1 c% r c: y( y {3 y4 G% `) y* z5 x
found=1;break;
7 \' z4 H$ n/ d# f7 A }) T+ m3 }7 U6 ~% v
}2 D, Y; q+ q) }
}6 _' j% l% e7 q# }
if(found)
# z+ f1 w, J6 b {
/ O+ d( y) |# y: T attr_value.value.string=sval;. I# u" T2 |9 L# q. z$ y
UF_ATTR_read_value(feat_tag,"孔标题",UF_ATTR_string,&attr_value);. n! s% T' B: D. _/ L. m c3 w
sprintf(mess,"孔标题的属性值为:\n%s",attr_value.value);
: l" k$ U9 D, B5 u: h, H6 X uc1601(mess,1);
2 S" ?9 }* \9 |( A) [9 ^* R }
% k, d8 U: N7 e4 ~6 m else
d2 J, d# G; T# E9 V uc1601("没有找到实体或类型为 SIMPLE HOLE 的孔",1);
/ b+ P& M0 D5 N! k}
% M }* A! N, u4 f* ]5 ]8 A
6 u3 l5 [" S7 V5 x. iextern DllExport void ufusr( char *parm, int *returnCode, int rlen )
e2 ?! Q @$ j5 f W6 m' Y{1 Y" |7 S- i6 E: n( B
/* Initialize the API environment */! E2 g8 y7 f: Y: }2 f+ b
int errorCode = UF_initialize();
+ f: K5 y& i. x$ v3 V t7 g
: O! O5 e0 I9 G) X9 o; Y( H0 G7 p if ( 0 == errorCode )5 \& f7 G$ T# L
{
7 Z; Z9 B0 `# X2 A% v0 D5 N' a/ k/ S /* TODO: Add your application code here */) i% r- n4 p* J8 w* N
do_open_api();
# K9 Q3 V) N+ t /* Terminate the API environment */2 u% r. t. Y/ s$ L7 I+ n
errorCode = UF_terminate();9 t0 Z7 I5 F) o- x% f. h5 x
}5 W& E& s+ O6 `$ C; \0 D8 C
; i7 B. g, m3 u! N. Y h1 }9 \ /* Print out any error messages */
8 K" }* \& o) ?1 }; i1 q PrintErrorMessage( errorCode );
& i j& C7 ]! K1 Q6 A$ |}9 j8 C+ X$ \" h% v' A* L
/****************************************************************************** }1 E0 R4 x# d( L7 E U
** Utilities
$ _8 N* c( P. F7 A" H*****************************************************************************/4 H: \2 ?; b2 B* }8 M b- g
: j3 f3 I9 _( X2 u6 I/* Unload Handler1 F5 U6 R6 y& k; z1 S) u
** This function specifies when to unload your application from Unigraphics.
1 I7 t: j) T# V* D% w** If your application registers a callback (from a MenuScript item or a
1 w8 ~6 v; H) A** User Defined Object for example), this function MUST return
$ Z" m9 Q m+ Q0 f' Q2 r; k** "UF_UNLOAD_UG_TERMINATE". */
6 U H) s& F3 B4 I0 `+ Sextern int ufusr_ask_unload( void )
4 B! ^- b* F( Z% k# z# E5 o3 e{
) Q5 y7 X* j! h: z2 k1 @: J return( UF_UNLOAD_IMMEDIATELY );
1 I' i7 \: Q4 {# K) j3 D}
' ~" J, Y7 ]* ?6 M; A9 ^( ?7 D, i3 `$ K3 i0 K
/* PrintErrorMessage# O+ _7 B+ Y3 I
**1 x" n: z% E9 Y4 ^
** Prints error messages to standard error and the Unigraphics status
" N7 j" i9 v: J: y1 K# R** line. */2 J' k% t. j# O- e0 ?+ r! v8 J
static void PrintErrorMessage( int errorCode )
% E1 `: o7 F a' X6 S5 O$ w{. \9 ?; W) @8 Y! q! o4 ~
if ( 0 != errorCode )7 F- [7 M" b9 Z8 N' L9 X
{" h. V/ g7 w/ U
/* Retrieve the associated error message */
& l! W: J6 R% p- N0 m# t" |- | char message[133];
2 Z' {$ x! I, T/ d& g0 p4 D UF_get_fail_message( errorCode, message );
7 m7 _) e, }7 ?& f9 T" f4 ]* x( E7 ]; \( m5 a
/* Print out the message */
& f, N' i. f- Q! |& p3 P UF_UI_set_status( message );
! H) `- |" o5 w7 Q' {( X) w
" g7 p" j" c5 F4 Q0 V fprintf( stderr, "%s\n", message );
( L6 C$ f9 r- ^4 F# N2 K }
, d' t5 P0 N6 v( R} b: o( y' e& k. S- K1 T T' k
|
|