|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
/*****************************************************************************
8 P' }# l! h8 ~* Q1 A7 O0 U2 t**" G; _" t2 ]) a& t) N1 p _
** test.c+ l& z) S% Z. Z+ B
**
& b# F" i- W) b$ }1 g o** Description:
4 Y6 c3 E+ _" G1 b3 f9 @% Q** Contains Unigraphics entry points for the application./ J. ~9 R1 u- E$ o( {) E1 H
**- w, b( H9 u& A0 q( m' K
*****************************************************************************/6 v9 k7 S/ Q; a' z$ G5 R
/* Include files */8 N+ {% J* e1 Z8 H* u1 h
#include <stdio.h>/ U9 j# ^: A) G, G/ n$ \
#include <uf.h>; S2 _1 Y4 x _4 |. D
#include <uf_ui.h>
0 f) f: ?" i! g( a3 ^#include <uf_modl.h>
; w* p I9 g+ M#include <uf_curve.h>- M* [6 `- }) H& [5 t' q& m
#include <uf_part.h>& j1 {8 m1 O2 P1 V3 R# C
#include <uf_modl_types.h>
( i3 a# [( Q" d* Y6 f#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))); D& h% h v' [* \6 Z% a8 L
static int report_error( char *file, int line, char *call, int irc)
9 ^5 R2 l0 {5 r, |{ m9 }1 j; K$ t" R
if (irc)
3 Z' S) d" | n- m& T1 S4 z% B {
8 V8 ], P& d* S char err[133], I3 P$ r1 T1 U) U3 |
msg[133];8 Y, S& W1 X8 p/ _5 ~. J8 |+ a
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
4 ]! |1 z# K0 m7 g& Z7 H irc, line, file);
" n" w7 q* x! h8 v1 }) J. ]1 _ UF_get_fail_message(irc, err);5 \( q' N, N- ^
UF_print_syslog(msg, FALSE);
" U, C$ e6 d U- ?& r. }/ M UF_print_syslog(err, FALSE);
# q1 n* i/ b r" g2 T UF_print_syslog("\n", FALSE); A3 [! R( i5 _
UF_print_syslog(call, FALSE);8 I. j: S4 @" ^
UF_print_syslog(";\n", FALSE);
8 J% ^5 G5 y5 z, e if (!UF_UI_open_listing_window())1 e6 v% f( K% Y: t( Z; w/ `
{
8 P* E/ u4 E6 j% j/ x' p UF_UI_write_listing_window(msg);! J! f8 K& j6 {3 W) I
UF_UI_write_listing_window(err);# C7 N$ d0 i9 ]6 s& K7 ?# m2 v) F
UF_UI_write_listing_window("\n");
. B* l+ e/ X. ^, y5 T; f5 b UF_UI_write_listing_window(call);0 t9 i4 W# J8 |, O
UF_UI_write_listing_window(";\n");! L# u: P3 S/ d7 ^# ~6 b% a" r
}0 K, ?" N2 n Q; k1 z5 n- Y
}
( i% k: d/ f8 v3 w$ i" _$ x return(irc);
7 W3 S8 K S/ K0 q% ]. D; r# n% w}( }0 s" {8 [ {. F+ b) V8 R
& `; \$ o, a* R9 j0 k3 I6 C. k
/*****************************************************************************+ I& b! x. `+ \3 T+ k
** Activation Methods$ I. O2 Y; j1 L( g; _9 v& W# G
*****************************************************************************/
+ s7 W2 e0 }( ^6 S/* Explicit Activation. S$ t4 _/ Q3 V' F% Y
** This entry point is used to activate the application explicitly, as in
* V8 k1 J( f# e# n1 d* }1 h** "File->Execute UG/Open->User Function..." */; L ]1 ]# W: N
tag_t part_tag=NULL_TAG;& a7 @- x8 v1 S: L( D9 @: t
tag_t tar_tag=NULL_TAG;
- c) J' @; A3 x8 f) wdouble origin[3]={0.0,0.0,0.0};
5 E2 m' U4 ?" Y S' g' Wchar *height="30";
6 m/ c+ J' \$ X2 V( xchar *diam="100";* |6 t6 A$ j9 A$ \' T2 [
double direction[3]={0.0,1.0,0.0};
4 z4 c- N3 `5 Wtag_t cylinderfea_tag=NULL_TAG;5 [/ y( g' A; i/ G
uf_list_p_t edge_list=NULL;- n7 `4 |) Q/ K6 \
int edge_count;
# v6 h" d7 Q7 a7 e5 [% _0 T( c% uchar msg[256];7 ~0 F$ t9 A# I. |, N8 J5 a
int i=0;
1 I) I% J6 O7 ytag_t edge_tag=NULL_TAG;5 G. f4 }. v; v; J s
tag_t curve_tag=NULL_TAG;9 Q6 S# r4 z% O, A+ e) P
tag_t point_tag=NULL_TAG;1 w8 |1 i# ~8 [6 |
tag_t line_tag=NULL_TAG;
% f0 z" g- J" n# ^$ A) y, {tag_t point_tag2=NULL_TAG;
+ K& c4 g6 |9 D [7 ~1 Odouble cen[2][3];8 M6 Q9 g$ d8 l# [6 s/ _
UF_CURVE_line_t line_coord;//最好不要定义为指针5 R/ k. @4 N2 F. p! O* O8 x! t
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
1 I# D! \1 V2 K{
/ U# ]' D c: V% h2 C; x/ N /* Initialize the API environment */
" {4 P) E/ N3 c9 E0 _2 f2 L if( UF_CALL(UF_initialize()) )
1 R, C! F/ ]9 I; Z4 g/ [ {
0 B! t# o+ ?9 a; s- N$ b /* Failed to initialize *// J3 X3 c& u/ i
return;: g- J+ Z# i$ r. O' a( _4 P) o
}# z7 S- K. z& I$ Z1 v4 G) _
2 j, N/ [! b6 v$ n( k# Q4 b
/* TODO: Add your application code here */
4 W6 G( H$ s9 w, V1 r- k t //1.create a new part
9 k/ w% ^6 ]6 @8 u ] UF_PART_new("C:\\NX_work\\cylinder.prt",1,&part_tag);4 o2 K: ^+ S9 I" e
//2.create a new cylinder6 U/ l+ d j. c* O. {. G
UF_MODL_create_cylinder(UF_NULLSIGN,tar_tag,origin,height,diam,direction,&cylinderfea_tag);' d o- P0 E8 \+ {* s, ~: U& y
//3.get the edge list
: O+ {1 i0 C% V$ d$ j% M UF_MODL_ask_feat_edges(cylinderfea_tag,&edge_list);: v! W( R+ w0 S
//4.get the edges0 q, E; v1 M; `; q' u
UF_MODL_ask_list_count(edge_list,&edge_count);6 E |( B" U+ i& T, B
! a& s0 V3 t$ H" d, ]" A" R& l+ C0 o( u
//5.get the centers+ D. m/ N( t9 h; }
for(;i<edge_count;++i){
4 {; t) X, w/ f% }! A9 r% u2 d; Z UF_MODL_ask_list_item(edge_list,i,&edge_tag);
, ~8 ?( I8 ?% N3 S$ o& o$ t8 t //UF_MODL_create_curve_from_edge(edge_tag,&curve_tag);
4 y: N w% E. | UF_CURVE_ask_centroid(edge_tag,cen[i]);5 w1 }( F4 d5 a' s7 A
}
4 g& t% s9 K$ R //6.create line2 c0 g+ l- D- ]: G+ O; S
//UF_CURVE_create_point(cen[0],&point_tag);
# \7 O, b- A9 _* L! M! A$ }) Z0 v //UF_CURVE_create_point(cen[1],&point_tag2);
( i5 t# K9 \9 N, T line_coord.start_point[0]=cen[0][0];
. M: n4 M, [# U3 R line_coord.start_point[1]=cen[0][1];
: _, X& t5 L5 B% \ line_coord.start_point[2]=cen[0][2];4 }' N3 Q& r4 [4 E) R3 o4 p0 O
line_coord.end_point[0]=cen[1][0];
* k; f) c) l# W I- V' { line_coord.end_point[1]=cen[1][1];6 l0 q: p3 l4 t" ?! h4 r
line_coord.end_point[2]=cen[1][2];
9 V- C6 D3 ^, U, W5 ?$ s UF_CURVE_create_line(&line_coord,&line_tag);
1 n+ f( n* l; v3 e+ n1 T7 I //UF_MODL_ask_list_item()$ @; C9 `5 \8 i$ i% t
/* Terminate the API environment */$ c% {6 N! I2 z! d. J4 d
UF_CALL(UF_terminate());
% J: m% b) |; d& i) Z b$ W! `}
' `, p8 M$ \3 s/*****************************************************************************9 q/ k- B7 f8 h' Z! \ ]
** Utilities! s( f5 E* s) P- }, m j1 x( _
*****************************************************************************/
- `9 X* x& b! u+ V% C z/* Unload Handler9 X( \- f3 b( S# [( q7 l3 T
** This function specifies when to unload your application from Unigraphics.% @, x- j- u/ n R, J; u
** If your application registers a callback (from a MenuScript item or a% W, ^: }7 s+ K: E. Y. M7 D" {5 ?
** User Defined Object for example), this function MUST return
* I6 D; O9 P3 i) a** "UF_UNLOAD_UG_TERMINATE". */
$ ]& v* @, l5 T" k$ E4 cextern int ufusr_ask_unload( void )
/ X6 Z+ e, e4 x+ r" s4 t{ W5 y) R" v, J0 F
return( UF_UNLOAD_IMMEDIATELY );
8 z' T5 \1 N3 P# V& F4 @; x}
& V& |" G+ {1 J! R- d& Y2 [7 ~/ u9 P+ m8 f: @" ]/ K" M
|
评分
-
查看全部评分
|