|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
/*****************************************************************************
2 M) v: W8 f) a; ?**
! Q) C$ A* U, r) G; t$ s6 h- u' s** test.c
" r# r5 Z% e! P/ M**
0 s9 {8 I P I6 ]! B# [" C** Description:
: V% Z Z% k3 k0 x* C** Contains Unigraphics entry points for the application.
: C0 w; g( D2 \* v- g**, \) k0 y- E/ S
*****************************************************************************/' w X9 a+ e8 w
/* Include files */9 a2 r- L# p1 s1 A0 w9 c
#include <stdio.h>
6 E4 u9 I4 _$ e" y#include <uf.h>
* A; X" C( {) z8 q$ H#include <uf_ui.h>1 K. t9 N3 P! b5 p. a+ D, j- K, u
#include <uf_modl.h>
o( d: w# J- C. w0 w# }#include <uf_curve.h># m- Y# h" c$ l9 L7 P& y
#include <uf_part.h>
$ n# d- L" }/ _+ X4 r7 e#include <uf_modl_types.h>
9 C6 c7 [8 k! v#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
5 O: h2 y1 r; V! e8 t& Estatic int report_error( char *file, int line, char *call, int irc)+ b; k8 a7 {+ s9 B$ @
{
0 y% h2 a4 ]4 T6 J. j0 r if (irc)0 w8 [5 t. O* j% ]( `2 ]8 S
{: k4 [0 Y) v2 _) h2 S; n8 M, {
char err[133],
6 a! _2 W2 y) C& M& a' b% d1 ] msg[133];0 p( s! p3 Y& b& a$ n0 N: ]7 ?
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
4 r3 ?( s; w# E" m irc, line, file);& @: T7 l' |1 B1 S% R4 R
UF_get_fail_message(irc, err);4 z4 m% J4 h; I4 y
UF_print_syslog(msg, FALSE);, w' O: {8 H1 T: m9 L
UF_print_syslog(err, FALSE);- Q8 P8 m& ?2 i. f* ]% y; ?' W$ ]
UF_print_syslog("\n", FALSE);
( h: ]! [9 j6 z UF_print_syslog(call, FALSE);
( }1 e! {& d- F1 F5 i8 B G UF_print_syslog(";\n", FALSE);
8 M# v) p3 h: e3 S if (!UF_UI_open_listing_window())
5 W& T$ \0 s2 |0 q {. m% x& `: E, c; H) Y
UF_UI_write_listing_window(msg);
# A e7 k: @, C8 |& K2 e UF_UI_write_listing_window(err);
, r5 U" F8 B' z, n2 c2 r- d UF_UI_write_listing_window("\n");
% Q: {! K+ C# Y UF_UI_write_listing_window(call);9 `- |" P1 [: W5 ` v$ H" A
UF_UI_write_listing_window(";\n");* K2 ?; y2 c, h) k4 f! {
}3 q- {) u% ]$ Q3 {9 q5 g
}" s; y" e# i2 K$ W0 h
return(irc);
% t+ L" X- E; A! ]}
' {2 S6 w" E0 g5 n1 U) k- A. e# `4 B/ l9 l1 [& B
/*****************************************************************************1 T. ?4 u. O- I# r
** Activation Methods
8 E( J0 G+ ` ^. Y- j+ o# f*****************************************************************************/2 H9 r/ I$ U& y5 m5 D5 z& |* K
/* Explicit Activation0 e1 h% k t! B
** This entry point is used to activate the application explicitly, as in
- a7 g+ r0 H6 f9 A% S! F** "File->Execute UG/Open->User Function..." */
6 I R9 ]% U j- A7 E( dtag_t part_tag=NULL_TAG;; c$ U$ \( ~3 b, c' F4 b
tag_t tar_tag=NULL_TAG;
- q' m$ [6 ^* X# R |/ Q) ndouble origin[3]={0.0,0.0,0.0};
6 h# N4 h( ~; A! jchar *height="30";5 R9 j* y4 T( n% f. W0 Z
char *diam="100";
3 v$ U, `, ]0 i( }8 L Jdouble direction[3]={0.0,1.0,0.0};
- C/ s! l$ [8 ~# x( ?tag_t cylinderfea_tag=NULL_TAG;" _" k0 e& M% L- @1 N* d
uf_list_p_t edge_list=NULL;
# I( o8 H9 M" j( q( d! F, {int edge_count;: e4 P6 _2 j+ F) {3 s/ s: N# |
char msg[256];# ~! {) L8 V- ^# D z
int i=0;+ T: i! Q6 h. X( B) C
tag_t edge_tag=NULL_TAG;
/ k9 Y* O+ t4 E" Z- Q+ Y& K" A& _tag_t curve_tag=NULL_TAG;
6 N( n4 S; q. h4 s: v. s8 rtag_t point_tag=NULL_TAG;
" w( i: |, d6 T+ F$ Ttag_t line_tag=NULL_TAG;
5 R5 {4 D5 g0 |# j( e. n& Ntag_t point_tag2=NULL_TAG;
]+ Q: T, q3 I& `5 s- E8 D7 z/ kdouble cen[2][3];
$ q* t+ h$ R: W7 z1 W6 HUF_CURVE_line_t line_coord;//最好不要定义为指针
& [0 K" P; b! l7 G8 g" b9 w( [* I( nextern DllExport void ufusr( char *parm, int *returnCode, int rlen )5 J, Y* |5 E: h% D, C5 `
{
# r8 X4 M! o6 l" h3 d4 N /* Initialize the API environment */
& u0 o# d2 H' X6 A if( UF_CALL(UF_initialize()) )
5 b4 @3 o+ F0 L4 S" B! B5 V {, ~ Z$ P! u2 o' d
/* Failed to initialize */
1 _! ~8 Z! [' L return;
& @/ Y( M0 ^3 a5 f }
8 i) O4 F5 d: T( i0 _) A) Z$ M0 S
, A j5 Y+ k) L1 w /* TODO: Add your application code here */
" B3 V' d1 t2 I$ `, { //1.create a new part
2 ?6 O8 D$ w& y' R4 N UF_PART_new("C:\\NX_work\\cylinder.prt",1,&part_tag);
9 e3 o; ^" W/ F3 X: }0 o" U //2.create a new cylinder6 ~" T0 t- P0 u* D- ^7 P- t
UF_MODL_create_cylinder(UF_NULLSIGN,tar_tag,origin,height,diam,direction,&cylinderfea_tag);, V3 U/ e! i) n! q
//3.get the edge list
- g2 z+ _% `3 r) E UF_MODL_ask_feat_edges(cylinderfea_tag,&edge_list);
& ^1 U; i8 t3 @) Z6 _ //4.get the edges3 B' F( h* F- O# d# _' \9 u
UF_MODL_ask_list_count(edge_list,&edge_count);3 I, F4 {% X+ W5 K* E
' p3 U6 g' L# E
//5.get the centers
. _, }2 D2 \! C$ n' {" H5 ] for(;i<edge_count;++i){% N# L" ^9 U! M' `& C
UF_MODL_ask_list_item(edge_list,i,&edge_tag);
: Z* q) I5 \0 t e //UF_MODL_create_curve_from_edge(edge_tag,&curve_tag);
, z1 m2 _+ W* B5 } UF_CURVE_ask_centroid(edge_tag,cen[i]);
! [- O4 h9 ^" ~* O$ d5 [8 j }3 _( D# Q2 h' X& b$ z, v
//6.create line* a) V8 J4 G9 b5 H4 o4 R: U
//UF_CURVE_create_point(cen[0],&point_tag);$ ? ?! D4 f) k0 n# u$ A
//UF_CURVE_create_point(cen[1],&point_tag2);7 h @* U8 z0 E3 J! D
line_coord.start_point[0]=cen[0][0];& M* F" c7 w$ a- s
line_coord.start_point[1]=cen[0][1];
- d5 ?. @* {' a) v line_coord.start_point[2]=cen[0][2];
4 V1 G) L" B: H7 P line_coord.end_point[0]=cen[1][0];7 a+ D+ b* p6 @+ l4 \ m+ ], _
line_coord.end_point[1]=cen[1][1];
. {- G' V, h. ~$ _; }" ?+ ? line_coord.end_point[2]=cen[1][2]; ^: i% S* G4 m0 D, F
UF_CURVE_create_line(&line_coord,&line_tag);
$ v' |! I2 [, H8 }; @: | //UF_MODL_ask_list_item()( T. M; K, u* c$ {
/* Terminate the API environment */' d6 u4 g1 }% J% F3 L# o
UF_CALL(UF_terminate());; |5 B( P" Y6 e. ]; h
}4 z2 G6 U0 v* v1 S
/*****************************************************************************% p" @- `' _7 J9 k3 H4 U
** Utilities* f# Z5 O" r" ~) i# t% F' C
*****************************************************************************/
- s& ^* B9 i, y# V( v3 G/* Unload Handler) Y1 e9 |" z7 P9 a5 @: s
** This function specifies when to unload your application from Unigraphics.
H; n1 z/ k" }$ m+ G** If your application registers a callback (from a MenuScript item or a
( F( Z$ y0 @+ j7 I6 N7 [! V) n2 j** User Defined Object for example), this function MUST return
5 b1 @) M% D0 q- ^% U** "UF_UNLOAD_UG_TERMINATE". */
2 q/ h4 {+ h# F9 l! I8 v* s+ }extern int ufusr_ask_unload( void )
+ N! V5 H' R3 |1 p7 P6 K8 B: f1 {# [ ~{
c4 }) O* G6 i return( UF_UNLOAD_IMMEDIATELY );- |# h6 O% r) _( B! D
}- f m& U* m& ~7 I* B; o9 V
1 n. z/ n: R p. h* ` |
评分
-
查看全部评分
|