|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
/*****************************************************************************8 {- q7 m$ X2 H/ k3 F3 j( z' d
**
3 @- Y L4 X! e8 S5 y** test.c$ z5 \( R7 H2 d. P+ R& E
**
3 o. s+ e& g! g** Description:
3 I4 k6 X9 k$ v) S** Contains Unigraphics entry points for the application.. Y; f4 g( S7 l2 u
**+ _8 z! b5 \& i1 c
*****************************************************************************/
% W( |# b$ w+ S5 }* D$ g/* Include files */2 J3 U. m% C, y) }' ?
#include <stdio.h>
- N9 \9 T8 z" F) t#include <uf.h>
# f# b; W! z. L% f9 L6 D; h# i#include <uf_ui.h>) z# E8 @& V; C; }' r% s0 a
#include <uf_modl.h>
3 V. x5 A$ Q) @) c9 j: w#include <uf_curve.h>. s- N+ Z) l9 `( q
#include <uf_part.h>( C7 I* H9 p; t4 j5 W+ ]8 s
#include <uf_modl_types.h>
, O- y& [, d r#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))' S5 p5 J, R$ s6 q0 ?
static int report_error( char *file, int line, char *call, int irc)
! w5 a+ m. q: m1 N" ?{
7 f$ B5 s9 F. H+ X if (irc)) D4 R. z, \) [1 v
{
1 i5 R- s0 L" Q6 r5 c4 B; }* f char err[133],
6 Z7 s6 O7 d4 F. @2 Z* o8 J$ D8 U msg[133];/ E4 Z5 V, D' V! X4 e# Q8 b
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
# V" G! y+ X: C5 V8 S irc, line, file);' p+ ?3 s* q" _; ?1 j
UF_get_fail_message(irc, err);& ?% @ ~: |6 k
UF_print_syslog(msg, FALSE);' w8 w6 b; T3 k7 O
UF_print_syslog(err, FALSE);
9 Q* S' Q, z9 z' c! K; S UF_print_syslog("\n", FALSE);# C* f( v `, q) ^2 O6 t/ l
UF_print_syslog(call, FALSE);$ R% E6 m# u! P( x( o/ Q2 E
UF_print_syslog(";\n", FALSE);
' \1 _1 L& y/ x9 v e6 J3 Y* F. V if (!UF_UI_open_listing_window())! ~* \( ]! Q/ u; S
{: a) A0 B+ E/ j& d" R. w
UF_UI_write_listing_window(msg);
3 @$ k! {2 b, Z" F UF_UI_write_listing_window(err);
8 g. A+ V" D, V' D UF_UI_write_listing_window("\n");1 G' v; s% d& v
UF_UI_write_listing_window(call);
0 u. D* E/ }' z7 p4 T/ o" J5 s5 X UF_UI_write_listing_window(";\n");
4 `' g6 V, u, ~: T% J! Q }
" v% ^2 N8 J2 _, I$ `& Q6 ] }
9 \$ x& v6 v6 O return(irc);8 A1 u+ e! w9 a/ Z2 v( Z4 ?4 T, [
}
- i0 X6 [; f9 o( H: t$ l
' O- B+ \8 c1 {6 M6 g/*****************************************************************************! Z+ E& x! B& i7 v2 ^, q
** Activation Methods
% @' e+ I9 R0 S0 O; E# i4 |8 C) g9 i*****************************************************************************/
4 M! ^: N* H* b& Y! I7 s! K/* Explicit Activation! \8 K1 Y' D0 J& ?8 a! J# q
** This entry point is used to activate the application explicitly, as in( |6 H1 X, j8 M& T- n& M0 H
** "File->Execute UG/Open->User Function..." */4 `/ X1 |. e. r1 K, ~3 K
tag_t part_tag=NULL_TAG;
: O( ], Y% l. i+ Ztag_t tar_tag=NULL_TAG;
9 z) y ~; [8 @double origin[3]={0.0,0.0,0.0};
( q5 n" k b4 s& Kchar *height="30";
' I& b) W) C9 p- Uchar *diam="100";
# T* e) h9 |+ t0 K0 \3 A( B4 ydouble direction[3]={0.0,1.0,0.0};
3 W/ r+ t3 {# k+ \! p' W, i3 xtag_t cylinderfea_tag=NULL_TAG;
( t8 K7 L; B: Y+ j# r2 U5 `" c4 iuf_list_p_t edge_list=NULL;
! {5 _4 K' C4 u% w) F* [9 ~int edge_count;: C# N4 c& O( W8 w$ ^" p, v8 J
char msg[256];, }0 d1 Q" B% G7 f/ s
int i=0;
' b- B( z, T5 ^! {& u' r8 n4 M, _4 {tag_t edge_tag=NULL_TAG;; C' ~' O# x" f) b* B1 C. A
tag_t curve_tag=NULL_TAG;
i# X1 z3 s* T2 v- n* _4 i4 ytag_t point_tag=NULL_TAG;
+ ?5 Q& s8 g# @) Ztag_t line_tag=NULL_TAG;
3 t, R& t# ^9 ^7 ~tag_t point_tag2=NULL_TAG;
; L' w) D4 i$ F' o) [& ?/ tdouble cen[2][3];
" _9 o. M" K0 v( K5 J; g. @. yUF_CURVE_line_t line_coord;//最好不要定义为指针
( g" j+ Q2 \0 Gextern DllExport void ufusr( char *parm, int *returnCode, int rlen )+ F4 u2 P* G, K% B) T
{
! h, S( } ^) r, c3 _ /* Initialize the API environment */9 c9 O- K; a) M9 f
if( UF_CALL(UF_initialize()) )
, M, c' l. @ y$ } {# k. U" H _- Y, @; G: `
/* Failed to initialize */
4 @- N( w6 S/ n4 P' O% c; a5 C: {# u return;
. X/ l' L4 Y" G+ C& l+ e }% O' `: ?/ R7 X9 \: R
: _9 H! H6 z: X7 l R! I/ I2 h( N
/* TODO: Add your application code here */
6 _4 B; R- ]& E" b //1.create a new part$ ^( g2 A$ Q+ w
UF_PART_new("C:\\NX_work\\cylinder.prt",1,&part_tag);
2 k5 s- }* X2 `9 i9 l8 n+ q //2.create a new cylinder1 s& K# w' [/ g# J
UF_MODL_create_cylinder(UF_NULLSIGN,tar_tag,origin,height,diam,direction,&cylinderfea_tag);8 t' J7 O& `9 T5 V* j! a$ L
//3.get the edge list2 A4 L- v! s1 C; o
UF_MODL_ask_feat_edges(cylinderfea_tag,&edge_list);
- l1 f$ Z3 Q( ~" E3 C4 } //4.get the edges
0 `+ f4 Q6 Q# }( R9 l UF_MODL_ask_list_count(edge_list,&edge_count);. {8 o' r/ u! O- X5 w* S. G" x0 U
M: c4 ]4 f: K. t4 J ^5 l //5.get the centers
" N5 J0 M2 r- `& f: q2 O* c for(;i<edge_count;++i){1 h6 D. X' z# Q. U/ O1 V
UF_MODL_ask_list_item(edge_list,i,&edge_tag);1 V3 A" b1 y/ k- F# b) c( {: ~
//UF_MODL_create_curve_from_edge(edge_tag,&curve_tag);( S" }, \4 K1 e# d; E% [& x+ D- i
UF_CURVE_ask_centroid(edge_tag,cen[i]);
1 }: H5 |, E3 s. k5 i5 z }
+ T$ u9 z# x: u% u A1 R //6.create line }/ m3 ?" o+ f! f3 `: B* @
//UF_CURVE_create_point(cen[0],&point_tag);( T2 q8 {& c6 J' \/ G
//UF_CURVE_create_point(cen[1],&point_tag2);
2 B! F0 R' V- j. P line_coord.start_point[0]=cen[0][0];! V, a8 W2 M5 g1 ?% _
line_coord.start_point[1]=cen[0][1];
1 ~( j% z, `* a0 \' z line_coord.start_point[2]=cen[0][2];
' u( S* H8 p- Z line_coord.end_point[0]=cen[1][0];7 r, L( u+ t6 x! q% j) Y& H8 F
line_coord.end_point[1]=cen[1][1];
" a& h' h0 S9 ]3 z: |, R4 O- E8 D line_coord.end_point[2]=cen[1][2];
: k7 O/ h# g+ Y3 P S& j& Z UF_CURVE_create_line(&line_coord,&line_tag);
! ^4 _+ o ]5 z8 ]$ m //UF_MODL_ask_list_item()
% `$ _; P0 z2 X1 V /* Terminate the API environment */
$ d, w/ K0 c, E UF_CALL(UF_terminate());
! U" I' v" O6 i( [! v% v" ^% x}' V7 q& j' Y$ Q5 W2 o; ^
/*****************************************************************************9 x" }& U% c3 d, F3 \) u
** Utilities' t* c8 R; B( [. |" m+ q
*****************************************************************************/
( Q6 f1 Q: J4 O* X4 F: t: \7 n/ Q2 q/* Unload Handler
. U: j+ V; m) F# l- r( X# N** This function specifies when to unload your application from Unigraphics.
k* V) r5 J9 \) q** If your application registers a callback (from a MenuScript item or a
4 x6 M; d0 l) T& e** User Defined Object for example), this function MUST return; O) x' R8 a* q8 W* c
** "UF_UNLOAD_UG_TERMINATE". */8 o1 u' D- X) A4 a2 Z
extern int ufusr_ask_unload( void )
6 c/ V" W0 s/ l1 u8 u{
% P( K. J4 E6 }) j( @: [ return( UF_UNLOAD_IMMEDIATELY );
+ ?3 b: Z4 u/ u: W}
8 Y/ P% W: V8 S. Y+ Q
* x7 B& W6 J; E- u7 C! b; } |
评分
-
查看全部评分
|