|
include <stdio.h>1 A' N4 `1 j5 T; O
#include <uf.h>
2 ?0 ?& C4 Z0 Z# T0 j8 E( v8 t#include <uf_ui.h>5 t2 D$ W/ J- {" p5 v* m! n5 q( W
#include <uf_attr.h>
0 @# S3 y, l+ Y. V @: h#include <uf_modl_utilities.h>' ^/ F5 v5 P8 \
#include <uf_modl.h> V$ f6 \- T4 q; L. k
#include <uf_attr.h>
) I6 M6 F! o' m! I9 N$ R/ W#include "A2.h"( O3 J" q- F$ l
# X. D3 M5 l! ^8 @" `
: \1 ?$ y/ P' o' l
/*****************************************************************************4 k5 I% T" {, P6 B
** Activation Methods
9 Y5 }: `' F' p( z*****************************************************************************/
% F+ x3 U5 D1 Z& p7 X# `8 ?1 h- C( b
- \- u, s7 `( \3 l/* Explicit Activation
! O- A N* K8 |" M! t- ^** This entry point is used to activate the application explicitly, as in
# H/ w N9 w: k3 f5 _. M/ [** "File->Execute ug/Open->User Function..." */
* e" h- t( y9 i; j6 o2 D" Ivoid do_open_api()) R k; b# ?. U- j" U/ y9 `
{
& x% e, S0 q0 {$ z$ A tag_t object=NULL_TAG,feat_tag;4 ~- V7 y/ T+ x
int count=0,found=0,i;
5 `/ g$ f! E3 b8 g uf_list_p_t feature_tag_list;* M: J3 J& T$ \7 [* P: I
char *feat_type,mess[100],sval[100];) ^* b( a0 J4 R4 ?3 n
UF_ATTR_value_t attr_value;# P/ i z/ a9 K9 @# n5 n5 V/ U6 U5 N
$ h. D# x g$ m UF_MODL_ask_object(70,0,&object);
/ D- [# Z# W, } if(object!=NULL_TAG)
+ d. F; w! V( s: F {
6 F5 s9 B0 _3 B+ H# z UF_MODL_create_list(&feature_tag_list);
9 P; X l1 Y, f! j3 O* i/ x0 T, W UF_MODL_ask_body_feats(object,&feature_tag_list);
/ N5 J5 {8 g8 Y1 P2 Y3 p0 X UF_MODL_ask_list_count(feature_tag_list,&count); J# j/ N* q' Y/ [
for(i=0;i<count;i++)) u- s# {! J9 s2 Y7 C6 ?
{
7 F0 w: A4 O/ S UF_MODL_ask_list_item(feature_tag_list,i,&feat_tag);. C: t* `9 ]4 J- F" w
UF_MODL_ask_feat_type(feat_tag,&feat_type);& j' O6 l; |6 y9 X
if(strcmp(feat_type,"SIMPLE HOLE")==0)2 G2 m! T2 K) ~
{& Q3 c! \5 p5 {( n, o2 r
found=1;break;
8 L: Z$ Q& @0 B2 o$ R }
+ s; k) x1 l! U3 u: L3 q }
! J2 n9 g! v/ L/ | }
6 i- C* Q) l3 _+ c$ B% Z if(found)6 Z" e8 L3 v4 [1 C& M$ E5 c
{8 y* s1 q( r6 @6 u
attr_value.value.string=sval;# j3 i y; L6 N. C, x: @
UF_ATTR_read_value(feat_tag,"孔标题",UF_ATTR_string,&attr_value);
+ o0 w% t0 f9 ^ sprintf(mess,"孔标题的属性值为:\n%s",attr_value.value);
c2 W% h( L- G0 E8 L uc1601(mess,1);
K6 P }0 L2 ^& o" t3 [# Q3 ?/ | }% ~" p( z& `4 x2 ?% o
else
: F# P( n7 c) t1 V% j uc1601("没有找到实体或类型为 SIMPLE HOLE 的孔",1);* a$ T1 z* O) Q' n( V
}- @6 N8 l5 k* I
7 ?+ E' [. q2 ~% ^9 L0 i8 N4 ^extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
7 k" Q& p& k8 X! i" f{& I: s, o5 t' h4 e7 P
/* Initialize the API environment */' z& Q) N% `( x. w( ~$ x0 c5 M
int errorCode = UF_initialize();$ X& k/ s' V, W J/ \
/ W3 o7 f! w8 X0 j i if ( 0 == errorCode )
1 \7 d. x# s1 i8 w# z# U {) U$ d! @. [8 J a5 O" x3 R& D$ \
/* TODO: Add your application code here */
; W/ Z- b% d! {2 |# {8 y% |, J do_open_api();
2 [4 _, y l% y! ~ /* Terminate the API environment */
" [4 X% O. L; v7 J9 S% F errorCode = UF_terminate();; B8 N- K& t9 N* t* Q1 V% ^. d
}7 v1 r0 ^+ D& g+ X# r% S$ c
( x. P. D! O4 Y- ~ [7 Q /* Print out any error messages */
6 A( v+ P* F" J' y; X/ a PrintErrorMessage( errorCode );
. s* a/ A* a9 W# `. M4 k% z9 x}
2 K$ z/ V p1 c$ E6 E1 j/*****************************************************************************" ]: f# x! ]+ ?* q
** Utilities3 P4 a1 C4 _) A
*****************************************************************************/& a/ g- k6 X7 E. o- e/ }
1 f9 j4 g2 }1 I! s
/* Unload Handler0 n5 [8 ?: P1 C
** This function specifies when to unload your application from Unigraphics.0 V/ k% q* O% B% r: b: Z5 g4 I
** If your application registers a callback (from a MenuScript item or a9 C0 x. o. F: w0 y
** User Defined Object for example), this function MUST return/ L) J$ \3 o) O7 ]9 q/ |& w9 O
** "UF_UNLOAD_UG_TERMINATE". */: G6 g$ [/ X) K6 W" a- [( S
extern int ufusr_ask_unload( void )
* t- p8 e5 F6 K3 a{& T0 z" _! @+ ]
return( UF_UNLOAD_IMMEDIATELY );3 F0 Q) |; M; E0 p9 U, b
}
e0 t% B& K2 v0 ?& v- ~& d
7 \( I% h1 G. E0 B% P/* PrintErrorMessage3 F7 g+ D# F( D2 W
**
3 O6 B# \; o& E# o! [** Prints error messages to standard error and the Unigraphics status
. q. L3 K1 a8 ?** line. */
$ D$ C* R n: G0 O& H# Tstatic void PrintErrorMessage( int errorCode )( G* u3 J. h. c9 s. V2 j
{
* J& M* o6 u1 {& B0 v/ s+ _ if ( 0 != errorCode )
) a: ^. s/ y, L" y! K# M% a {
2 T5 [( K8 o- Q% D p7 c! k; ` /* Retrieve the associated error message */
$ F0 r$ n0 ?- |8 o+ M+ s1 P char message[133];
! q2 {6 \# }) ?% Q UF_get_fail_message( errorCode, message );
3 ^+ r# y. g/ d# N6 {2 ~
8 @+ V6 n- `% u5 a/ X5 W /* Print out the message */
6 \8 u$ p X4 X9 K% L5 i4 \ UF_UI_set_status( message );
2 l* H$ [6 A. X/ T
; T! C& Z2 Z! H; I8 ~ fprintf( stderr, "%s\n", message );9 }* }$ ?1 O: O( G, F
}, B+ j8 f' m% k+ s( r \8 F; m
}
' p& `% V) f- B% m7 d% U |
|