|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
/*****************************************************************************
$ `1 l& U& ~' e3 Z**
( r- r! w! P# n# D9 D- s6 j+ L) E** test.c
! F! u( q" B+ @9 m+ Y" A+ y**$ B4 `5 k, q1 }
** Description:; I+ w ~. I) ]' H
** Contains Unigraphics entry points for the application.
9 @0 ~. V' v5 p# g**/ Q" A9 k* t1 S* }- }( c
*****************************************************************************/& P8 `9 l9 l' S5 o2 L( S8 e
/* Include files */
. X7 f$ y, Z6 y$ u! N% W8 R$ B- H a#include <stdio.h>
/ Z5 X' O7 F0 }! z: Y3 @3 Q#include <uf.h>
( B; `7 l4 c+ G#include <uf_ui.h>
/ u" _4 P1 s8 j) L# K4 R/ {( q8 q8 F( U#include <uf_modl.h>7 k7 G! L- U x2 J* H8 k; W* g1 O
#include <uf_curve.h>
. V+ V# H+ m0 h. x#include <uf_part.h>4 s5 u9 L1 A8 u
#include <uf_modl_types.h>
& K5 r3 a: B- R4 n2 a/ O#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))5 Y7 D6 g4 P4 r8 M3 C
static int report_error( char *file, int line, char *call, int irc)
; ]5 ^/ ^+ e3 Q& ]! I{
. t3 h- U0 Q5 p2 Y if (irc)9 k& _) U; N5 k3 s2 w6 d3 [* y: {
{) B4 ^4 T1 o3 Z& Z& C3 l! L
char err[133],) N z9 Q, U6 ]$ w8 n
msg[133];* s; ^. `7 m, J
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",# l6 Y* h) z, U9 c, g" s2 B- U
irc, line, file);
6 V- x, r! ^( X UF_get_fail_message(irc, err);
3 y \2 W/ A( Y2 { UF_print_syslog(msg, FALSE);
# j) D+ M5 O' L) m5 s( e& J UF_print_syslog(err, FALSE);0 @# ?6 k( t8 G( W2 h. d
UF_print_syslog("\n", FALSE);
1 l( i1 O. h' M; x0 |" U, f UF_print_syslog(call, FALSE);7 A5 B" z6 g; }% v, f
UF_print_syslog(";\n", FALSE);7 b+ x- F, _ U$ z: G! k
if (!UF_UI_open_listing_window())2 a3 s* z4 L! S$ B
{, V6 T5 \% r6 n4 D
UF_UI_write_listing_window(msg);
+ S4 r5 y- t# z/ S. p7 H UF_UI_write_listing_window(err);2 f! C. w/ U7 h7 C
UF_UI_write_listing_window("\n");
7 F: \+ `( G1 R UF_UI_write_listing_window(call);# P* m2 `3 {2 {- Z3 u( R6 W
UF_UI_write_listing_window(";\n");# Q# {) H% `2 T+ H- u
}; G& j/ g6 ]4 H7 z
}0 {( F' R' C% r; q: S
return(irc);
! R0 _% S5 V/ {, a2 n3 T}
' P' N: K! k( k5 b0 U& Y! K7 s2 Q; {! g2 s. c! ~1 a1 ]4 W. _2 I
/*****************************************************************************
7 V0 C" h, Y& j; O) f** Activation Methods
/ J. Z9 R, Z- d9 ~0 b' X) s2 j, `*****************************************************************************/1 M$ H" S6 n; G& |7 A
/* Explicit Activation* ]1 _$ J& E# y
** This entry point is used to activate the application explicitly, as in4 ^6 ~& h M2 {0 _
** "File->Execute UG/Open->User Function..." */& ?0 [0 _4 h F2 H# p
tag_t part_tag=NULL_TAG;
! V" ` J+ M) e2 Q: T, P! {tag_t tar_tag=NULL_TAG;
# l* D4 ]! S. }double origin[3]={0.0,0.0,0.0};
5 Q; d) |9 ^. O) M. N. G2 |char *height="30";) S, v, k" X* U& y! h4 p+ X
char *diam="100";$ ^0 e0 C8 H2 D( S, R: s
double direction[3]={0.0,1.0,0.0};
- K0 Y( A1 h, J0 d1 ]7 ?- ktag_t cylinderfea_tag=NULL_TAG;! }: y; o+ w( X8 F% X
uf_list_p_t edge_list=NULL;# C2 ~* [6 a- j( A `: @9 a! G$ g
int edge_count;( q6 e N) C4 `( n# X0 }" X V9 w
char msg[256];
% e: M$ M% e. l# Cint i=0;
& N: _- y8 P% |' h# btag_t edge_tag=NULL_TAG;/ a3 f9 P4 ?! `' R/ M9 }9 |
tag_t curve_tag=NULL_TAG;4 V7 {- Y g( `* N
tag_t point_tag=NULL_TAG;
$ I6 ]% r$ K* l2 Z3 Q: d% ], itag_t line_tag=NULL_TAG;
# Y0 D0 C9 o& c( v, P( U; q' ~tag_t point_tag2=NULL_TAG;
, j; K1 i* y! Cdouble cen[2][3];
5 H% v8 ~! j$ @! m* }8 y9 EUF_CURVE_line_t line_coord;//最好不要定义为指针% u' I% G6 P! A4 {; a3 \& v
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
- L( _8 g# q0 |% N{6 C' T# z' N) b6 y; `' A' ?' \
/* Initialize the API environment */0 x! c' X, C1 X2 v1 a
if( UF_CALL(UF_initialize()) )
* z; P1 t1 q( x( C# e {
8 C. ^. y. Y$ P /* Failed to initialize */
9 [, j% R1 ~: e& K. q( z return;
9 r" g/ B$ d+ s+ a }
# R; X- G+ n6 N4 G" w Z# R8 E+ E 1 W9 {: S0 u& y9 N# i
/* TODO: Add your application code here */* {# P/ w4 a- U6 E8 Y: G2 m
//1.create a new part: O) Q7 O" y1 n& Q" a; W
UF_PART_new("C:\\NX_work\\cylinder.prt",1,&part_tag);* [1 e6 \+ s0 `, `2 W) L) s4 |
//2.create a new cylinder
2 I7 G; h: |# p" c* M! G! k2 B) R UF_MODL_create_cylinder(UF_NULLSIGN,tar_tag,origin,height,diam,direction,&cylinderfea_tag);
: m% P8 @9 e% o1 m" g9 P //3.get the edge list
" h) _5 @1 o8 ] h* J, h7 N UF_MODL_ask_feat_edges(cylinderfea_tag,&edge_list);
" `6 T* h0 x# m/ d6 l //4.get the edges
$ w# S7 x; ^) @ Z1 `* r$ u UF_MODL_ask_list_count(edge_list,&edge_count);
. m& ~1 [# g/ \ , r( G4 X$ n" G- S, y2 x1 l
//5.get the centers
W2 R- e3 ~& M* R1 M6 X for(;i<edge_count;++i){
; w6 M2 A4 s, g v UF_MODL_ask_list_item(edge_list,i,&edge_tag);
' |, [% z* M9 \* G! O: D* _ //UF_MODL_create_curve_from_edge(edge_tag,&curve_tag);
& n! h7 s; d6 x' v UF_CURVE_ask_centroid(edge_tag,cen[i]);
. ~9 b$ J, d& I& V2 S }/ w$ f& Z$ t$ Q* _
//6.create line; Q! j& }0 v4 D% E& `/ I
//UF_CURVE_create_point(cen[0],&point_tag);
8 v8 b9 ?$ g* k( ]% E //UF_CURVE_create_point(cen[1],&point_tag2);: Y. m! A- T; E
line_coord.start_point[0]=cen[0][0];+ B7 g7 j6 E4 N# w% [7 \
line_coord.start_point[1]=cen[0][1];, _, ^, T# n3 T M- O
line_coord.start_point[2]=cen[0][2];
2 y# Z1 H7 s% H* C+ n# ^, w' ?6 `+ @ line_coord.end_point[0]=cen[1][0];. k9 G9 S) x' g4 y$ k3 \
line_coord.end_point[1]=cen[1][1];
5 J3 p* @& i# S8 m& q# Q8 z1 n6 L0 T7 s line_coord.end_point[2]=cen[1][2];2 k+ j- z) W" p% }
UF_CURVE_create_line(&line_coord,&line_tag);
/ j' t. p0 D6 U' G+ h' D2 G7 ] //UF_MODL_ask_list_item()7 F1 V3 k* S, Q
/* Terminate the API environment */# h& ~ E- t" G& |) |" Q: ]( G, @
UF_CALL(UF_terminate()); ]) b1 B3 _/ c9 E3 \4 y
}
, P/ V! T+ o( u) M/*****************************************************************************% u2 y. }2 O0 _+ X% M
** Utilities
) \2 \& d* ~2 K; Y) w# U J*****************************************************************************/1 K! p" O' R1 e1 `) o: H2 [
/* Unload Handler
' k- C5 R& ~' e# T+ D5 V n2 q5 f3 o% h** This function specifies when to unload your application from Unigraphics.
" E$ m2 U7 s3 E5 g+ P** If your application registers a callback (from a MenuScript item or a! t1 o" C5 `4 M
** User Defined Object for example), this function MUST return
, N, ?9 E: ]3 E7 Z** "UF_UNLOAD_UG_TERMINATE". */( z+ z4 h1 I) R* ~: ~; z
extern int ufusr_ask_unload( void )
8 I( c5 X: u% O{3 ? j& M ~. @" h* k6 H- f
return( UF_UNLOAD_IMMEDIATELY );
% z7 V- z0 e3 \: _9 T}, O! F2 h1 Z3 ?2 \' R
0 l8 F3 o2 o8 k1 i/ | |
评分
-
查看全部评分
|