|
include <stdio.h>9 K5 B- ^2 |; z
#include <uf.h>8 M# }! N* ?6 \
#include <uf_ui.h>- s" \- r3 N: a% I1 Z1 p
#include <uf_attr.h>4 U/ y$ I& `5 |
#include <uf_modl_utilities.h>
- M- k M3 A! b) J#include <uf_modl.h>$ y: M0 q% I6 f* [/ J$ w
#include <uf_attr.h>2 K! D) G- ^- e2 M2 |9 w; @
#include "A2.h"# ?2 l( a) n( `) ~/ o- t
+ e- h6 q3 u9 `0 k1 S
% B" k. x6 N& k/ e# Y- `1 p8 g/ H/*****************************************************************************
8 {9 D+ R5 I. i' ]" n k** Activation Methods. P; F4 y" k8 W0 M& @ \/ Z0 B8 `
*****************************************************************************/
( D* F3 Z/ b3 R0 Z, v
5 {4 }* n/ N3 r7 q1 ]5 O0 j, B/* Explicit Activation% q+ y% O8 @) H3 a3 r
** This entry point is used to activate the application explicitly, as in
2 M& T$ x4 @# J1 P% u** "File->Execute ug/Open->User Function..." */9 I/ D; L7 s; Y j" ~9 ~
void do_open_api()! Y9 d9 c5 z, G# y8 p; s- h; R5 c
{
% i7 S- s3 ?. I1 u, z& ~ tag_t object=NULL_TAG,feat_tag;
' s* P3 }. `( G/ s- x$ a2 U# Q g int count=0,found=0,i;2 d0 a; `, V7 L4 E# y3 U
uf_list_p_t feature_tag_list;
( W3 ]* q9 I7 i4 y3 L/ B+ M7 ^ char *feat_type,mess[100],sval[100];
3 N: X5 w5 Y, n$ s2 a* m. q UF_ATTR_value_t attr_value;
2 X! l) B$ |# U1 W$ K, ~: h; K( }3 x5 l& U: N
UF_MODL_ask_object(70,0,&object);
6 ^; M3 m9 G; [; b0 K7 c: g4 s if(object!=NULL_TAG) `. I7 S! i7 U3 O* a/ u, K5 f
{
7 y& J9 @4 b \; `$ j# e UF_MODL_create_list(&feature_tag_list);, d3 A+ T( j* P
UF_MODL_ask_body_feats(object,&feature_tag_list);
( r- G, Z( v S+ z' K5 K. \ UF_MODL_ask_list_count(feature_tag_list,&count);- y, ]0 y/ Y5 @0 \/ l
for(i=0;i<count;i++): t% |' T4 B! o D& l
{
3 L S% Y3 z8 D+ |" n UF_MODL_ask_list_item(feature_tag_list,i,&feat_tag);: h9 u! N# L* g l" c% s
UF_MODL_ask_feat_type(feat_tag,&feat_type);3 W2 V, g4 n* t
if(strcmp(feat_type,"SIMPLE HOLE")==0)2 L8 [0 r( K5 ~
{* Q- C/ r, G; T! X
found=1;break;" r. ~- _. t9 r* S4 x
}
' G; O1 K3 E2 Q5 L; {6 q0 W }
7 J* v: {0 w, E& r/ ~ }4 w6 @; _" t: {* E' n
if(found)
. j8 E3 V9 \/ r9 P* M1 h) \, j {
' E3 z9 N* b; t8 q5 ]5 ` attr_value.value.string=sval;" J5 o* `# A/ R
UF_ATTR_read_value(feat_tag,"孔标题",UF_ATTR_string,&attr_value);: O/ \, a; Q: \
sprintf(mess,"孔标题的属性值为:\n%s",attr_value.value);
1 V+ K# P9 }/ ^3 ?, a5 e, n+ ^ uc1601(mess,1);5 E" O, m# P5 ?* M, Z
}
: w& Q! J0 u# V9 ~ M else+ {, V7 d/ s& }+ K- t
uc1601("没有找到实体或类型为 SIMPLE HOLE 的孔",1);
/ B( h7 {3 J, y& q, Y( F- d7 T}/ K8 i7 L' }1 B
+ A4 o3 r5 z% X3 J7 ]
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )' T L3 q2 D# M
{% |1 s/ r7 d; h1 `; ?* J$ z4 `
/* Initialize the API environment *// ]9 p5 q# e9 L+ B$ t# U3 o
int errorCode = UF_initialize();
1 t4 C' ?2 ?! K5 C) a( e, ~% H+ w9 a* r3 T" m+ M6 X- ^
if ( 0 == errorCode )
; w- W2 U! \5 {, K# m {, y) ~; ]( {$ g0 \% X! g% ]
/* TODO: Add your application code here */$ v- `2 V2 y R2 K4 w8 K' O
do_open_api();# P" }8 X) u# @9 D5 B: G W5 a
/* Terminate the API environment */
+ T6 s# p c$ ]+ R/ _ B errorCode = UF_terminate();
P) b, |$ p4 S1 j) [* j: Z8 V }
0 q- I7 u l7 q5 G3 ]. W
& {& N3 ~/ u% l8 p /* Print out any error messages */
# V; M7 i: \2 _1 Z }9 Y PrintErrorMessage( errorCode );8 g9 Y7 M$ D. V G; w2 i
}' N0 P- t M2 N
/*****************************************************************************" B) {1 i" j X: i& {7 v
** Utilities( Z- E6 ]0 w) B2 b- S
*****************************************************************************/, C, D, T& {( [7 E! L# K7 b T
6 l/ O3 y5 C$ V( B# U/* Unload Handler+ v0 c2 t0 X; U7 U
** This function specifies when to unload your application from Unigraphics.
( l) [1 Q- x( ]5 @1 Z, N** If your application registers a callback (from a MenuScript item or a4 R: }" v! _. c7 o! m
** User Defined Object for example), this function MUST return
8 W: F ^( A" C+ J! P" ]! b3 Y. V" u** "UF_UNLOAD_UG_TERMINATE". */8 [3 ~6 O! c g6 p3 Z1 m3 K5 u
extern int ufusr_ask_unload( void )
, A! }+ ?+ T, \+ k{' k {2 Q/ D0 Q; T# [
return( UF_UNLOAD_IMMEDIATELY );8 T( z: \8 w6 c# t5 A
}$ v# | Q2 @* Z! z! M1 m. t
7 Z! J+ N# h9 A
/* PrintErrorMessage: H# v/ ?, M9 i, x
**( H+ z" @; W# P
** Prints error messages to standard error and the Unigraphics status0 c. ?, M; N$ h; b$ n1 M' ?# d; `0 \
** line. */
9 O- ?! L4 Q6 k+ t* a0 T. ystatic void PrintErrorMessage( int errorCode )
7 t5 y3 j7 S* m" h, x% ?# Y{
7 R' p, f1 U3 y' Q2 C9 M if ( 0 != errorCode ); } Q- X, |/ ?# F4 f( \
{% ?) p1 T( D2 g6 n! S/ @8 t0 g
/* Retrieve the associated error message */
6 |7 }5 B7 Y) s9 s/ X& j. o2 a char message[133];
& T' Y. c3 I- K0 x) l UF_get_fail_message( errorCode, message );6 v& ]8 K% k3 m! d0 d5 g* l
7 ?, U9 I) o' R/ C
/* Print out the message */3 E: b1 H+ |( D C& l& ~
UF_UI_set_status( message );
* z8 J, T8 g! m* l$ P, `5 M( A# \' R( L( V* d
fprintf( stderr, "%s\n", message );
6 U( p K9 m+ ]% c1 b# U" ?" Z }
1 W9 B7 l" f) \}
& c& H6 o$ k+ { o# B5 ] |
|