PLM之家PLMHome-工业软件践行者

[解决] 用UF_UI_create_filebox()时UG崩溃了

  [复制链接]

2015-5-5 08:36:17 4743 4

文星和合 发表于 2015-5-1 11:53:07 |阅读模式

文星和合 楼主

2015-5-1 11:53:07

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x

5 q7 q+ o, J4 A4 \/*****************************************************************************
5 k/ V& G  _- \/ \) z& `6 a* z**( G) b" l' N4 ], E
** createfilebox.cpp# G+ w: L; Q; `( r7 t3 ?
**! C* J6 K3 Q5 E" |
** Description:
0 v2 x. E. J4 F  l! |- _, R**     Contains Unigraphics entry points for the application.: R, N' |" j: e: o  q8 ^* r
**: V5 U! g* b8 f% h: _9 ?
*****************************************************************************/
" F" ~$ a/ x  m" q" P$ ]/* Include files */
7 p* y5 T1 v3 s# o4 I! b3 m4 ?#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
9 F9 _' C+ N( G. M: a' Q# M& v" n#   include <strstream>
: y- I! D  ]) o/ \#   include <iostream>) S- T( W* k+ x% G
    using std:strstream;# ^; x( P, i. r2 h5 c; s
    using std::endl;    . W/ p" H& I0 y7 [* w* n
    using std::ends;
: c& a( `- t) O4 E' Q    using std::cerr;
, }  Y$ T' n* Q6 w#else
) F, p& E$ W4 \; m# Z* P#   include <strstream.h>, T, \9 \/ n- W7 [' h) A; }
#   include <iostream.h>
' b$ O$ v0 X1 n0 J#endif) J2 U/ P: T& Q' j; l' R
#include <uf.h>
% S: e6 s+ |0 d: X6 e- p$ m& }" g#include <uf_ui.h>: s5 ^, ^% G( Q' i8 y2 A6 f
#include <uf_exit.h>
7 z; O( o  y* d6 r#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))7 b, J9 z  ~2 o4 X5 F2 c# ^
static int report_error( char *file, int line, char *call, int irc)1 y# }9 H2 D7 g/ x# |+ P- E
{
. b, U) }% I- a: W5 u" M6 F    if (irc)' l( _* B0 {" U5 E1 h9 j
    {4 m. Y+ w: X" z( _  E' b
        char err[133],
( h& _& B& X. u: J; U4 J0 b             msg[133];
+ Q  ?8 j: c+ x, E% ]$ E        sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
" c) R+ p6 Y3 b- X; {( c- J            irc, line, file);
* ?0 X3 P9 v2 {9 b6 p0 A/ O        UF_get_fail_message(irc, err);
5 A1 A6 Q2 U7 E+ `8 q; e: A        UF_print_syslog(msg, FALSE);
. a+ z3 d4 Q9 f0 q1 ^        UF_print_syslog(err, FALSE);$ o0 D# d% R% x* ]7 {7 q0 G/ j9 _
        UF_print_syslog("\n", FALSE);" y/ L: K2 A5 d
        UF_print_syslog(call, FALSE);
6 R, R9 Z) t3 D6 D9 t        UF_print_syslog(";\n", FALSE);/ |9 Q4 @4 [4 M' O* n" Q
        if (!UF_UI_open_listing_window())- H1 o  \) a: g3 k
        {, g4 k! Q. ?# v+ O8 J4 f' P
            UF_UI_write_listing_window(msg);" ?1 W( r# p  D4 P5 X( E+ G( L
            UF_UI_write_listing_window(err);! W! Q/ ^' D' m) L$ }7 ^& L
            UF_UI_write_listing_window("\n");, o; ?& |" }: s+ K" s
            UF_UI_write_listing_window(call);
( N8 Q& J) V2 a5 X* _            UF_UI_write_listing_window(";\n");
3 L0 s8 q7 {( Q        }
9 Z! }; c9 z/ t+ Z0 a3 X    }
) J8 F+ a2 @5 i; S$ q2 |# y; T    return(irc);
2 \' j) }1 S$ l0 e% B0 O* Q# ~}
6 w$ d# c7 R, Q$ c/ V
2 \9 i$ N) Y3 {5 R4 G# ^6 v- \/*****************************************************************************
1 R+ ?6 V9 N; p) ~2 z4 a$ h2 J**  Activation Methods  h3 I. Y2 g* F; [4 [0 q6 K
*****************************************************************************/& n/ n% I" q( P/ ?
/*  Explicit Activation( q2 ^6 J6 T6 @$ |1 n& X1 j% b! \
**      This entry point is used to activate the application explicitly, as in
) E5 J+ x. f! w**      "File->Execute UG/Open->User Function..." */; O- Q  `6 S1 G  w
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
: k5 C% ?+ _- h2 v1 {, o{6 K. z( }0 L5 T7 O
    /* Initialize the API environment */! J9 T5 b" B0 s2 H  B3 _, V
char prompt_string[]="open file";
7 {, _" C3 V1 ^ char title_string[] = "select file";
( D$ X% x7 E/ V7 M5 j: @8 ^4 z/ r% ? char filter_string[] = "*.prt";
5 d5 k; h8 y& n* \/ c; ^8 e char default_name[] = "my file";
3 [! u) t9 i, e7 ]& n; q: F char filename[256];
3 d# P( v2 v+ T7 k# V int response;) k0 D3 H# s$ M8 P. Z8 g, D( a
    if( UF_CALL(UF_initialize()) ) . k" G" u% w8 t  ~# o, E/ h  l5 D
    {
* A. O& {, D4 Z3 \5 T% @! [        /* Failed to initialize */
/ ]9 X# C" d7 a8 R- M+ _        return;
" i+ d- ]0 D% _1 U    }8 x! {4 Z- M1 U7 |5 u  d
   
4 i8 A. h! L8 M: m3 ?  _( v8 T4 F    /* TODO: Add your application code here */& x" F8 ]% ]( H' A+ h0 N% y% n' v
UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox
) n! g6 k" Q+ e- S- c: v    /* Terminate the API environment */6 `- K; `0 {5 K  ]3 m& t) j& X/ o
    UF_CALL(UF_terminate());* z1 e7 o( M- B. n+ Z1 P2 M
}! m+ L7 V0 [* j# l& s
/*****************************************************************************) t* l0 ?% k+ b( O, q5 E
**  Utilities
, o* y( h. @5 a*****************************************************************************/
  _+ b) w6 _, K: {6 v% ~1 o8 c/* Unload Handler  b+ x; x0 G& E: C
**     This function specifies when to unload your application from Unigraphics.
1 ?( ]" {3 g# M**     If your application registers a callback (from a MenuScript item or a
$ Q1 F! X1 L: I' Q- @**     User Defined Object for example), this function MUST return
, c2 j0 B* C: V0 ?4 v7 m**     "UF_UNLOAD_UG_TERMINATE". */
5 f; _5 A- V+ u  D& _' Vextern int ufusr_ask_unload( void )
0 ]+ ?5 J& c+ a; |/ ]( I* m' Y) \{1 {# ~: Z- Z( F+ M# {
    return( UF_UNLOAD_IMMEDIATELY );
1 E4 @/ H  Q/ A( ^2 w}) T5 U! F4 k0 j( w: w

; e& W: [, c0 n# G
CreateFilebox.png
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

全部回复4

mildcat 发表于 2015-5-2 20:07:06

mildcat 沙发

2015-5-2 20:07:06

UF_UI_create_filebox 我没有试你这个 - R* Q; C& L1 j

8 N' b4 ~" ]+ E2 x' `不过你加个uf_call或者看下syslog 啥问题 % f+ G% r5 Y& u! ~5 X1 C+ p% q0 Q" A

! n! s9 ~" X  R$ u0 _
该会员没有填写今日想说内容.
回复 支持 反对

使用道具 举报

文星和合 发表于 2015-5-2 20:18:39

文星和合 板凳

2015-5-2 20:18:39

mildcat 发表于 2015-5-2 20:07/ {. k/ M: \. j4 Y1 H- P  A6 }
UF_UI_create_filebox 我没有试你这个 6 z: o. h) ^, g9 n# k
: R; e: l- ]' @  h% @) D
不过你加个uf_call或者看下syslog 啥问题

, Q/ k* v6 U% }8 ?" X; \/ h2 cUF_CALL没有报错。打开文件的对话框也生成了。就是在点击ok之后,UG崩掉了。
% k$ c2 {, K( |- R我想用UF_UI_create_filebox()创建一个打开文件的对话框。UG有别的函数可以创建打开文件的对话框?
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复 支持 反对

使用道具 举报

简简单单 发表于 2015-5-5 08:31:59

简简单单 地板

2015-5-5 08:31:59

文星和合 发表于 2015-5-2 20:18
( t& Q' X. K5 h! k) N$ ]7 l) o- XUF_CALL没有报错。打开文件的对话框也生成了。就是在点击ok之后,UG崩掉了。' s# v  H: F6 b/ m$ S# o3 t4 c
我想用UF_UI_create_filebox ...

8 f5 V2 M' B- K" r! d  F5 c# v) {. D; m7 \
#include <uf.h>' K8 x7 J, G: i6 n( O1 D5 v" w
#include <uf_ui.h>
( I8 l& ?5 c. x# q#include <uf_exit.h>
; b! E* J: E1 C/ p8 D0 dextern DllExport void ufusr( char *parm, int *returnCode, int rlen )" M9 d+ \- Q$ U: |2 U/ [9 g
{# ~$ W  w* H: i/ x  g! |! D( W/ K
        /* Initialize the API environment */
# `0 U  U' [) m) M3 Z8 b% t        char *prompt_string="输入文件名";6 \/ d& I# k/ g3 Z+ J) u- n
        char *title_string = "另存为";4 |9 [# c' ^. f9 L1 u
        char *filter_string = "E:\\+*.prt";
' }/ l3 w' G. E4 H: [. \) i, W        char *default_name = "OK-PRT";
+ v, H' M- v) y, b7 u        char filename[256];
4 X  |% M( l: t0 S        int response;
6 e2 N0 c4 _' t. N        UF_initialize();
; ?+ @, K) Y; h1 ~+ K5 V        UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);
# r+ Q( ~. Q$ T: c4 G5 v+ w        if (response ==UF_UI_OK)* U3 C/ P- A5 C  f0 A8 w6 k, R! G
                uc1601(filename,1);
( h7 t7 ]: `- R7 ~2 Z- `        else if(response ==UF_UI_CANCEL)
( h5 x8 y9 Z# U8 E" `                uc1601("取消",1);) i+ Y% k' k+ o+ z0 B) O" Q, q5 z# b
        UF_terminate();
' O4 k( |- _4 I$ Z. X$ n& F# |}! d) u$ A: \3 l
extern int ufusr_ask_unload( void ); D, C$ }$ t4 `' N: `, G( Y% m6 I
{2 ]3 p/ B, i$ `! q; C2 m% G
        return( UF_UNLOAD_IMMEDIATELY );; m: s( y7 p; M( o$ H+ O% ^- J
}

评分

参与人数 1PLM币 +3 收起 理由
admin + 3 很给力!

查看全部评分

上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复 支持 反对

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了