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

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

  [复制链接]

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

4

主题

4

回帖

83

积分

培训VIP会员

积分
83
发表于 2015-5-1 11:53:07 | 显示全部楼层 |阅读模式

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

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

x
8 ]) H, C$ H6 A4 }$ ?
/*****************************************************************************
- g# I, `0 X8 k4 U* P0 T2 k3 a*** \  E3 e6 ]+ [7 \
** createfilebox.cpp
( l3 l$ s; K! E9 X: X0 ~. A**
1 M6 V) z  `( _; I7 O, Z9 a( k  h** Description:
3 Y5 E8 S' {; S: _+ h& E/ h( t6 c**     Contains Unigraphics entry points for the application.8 }1 D; Q& ]9 d! @* H; f
**
) P& B: w) g  S*****************************************************************************/6 v; Q$ V! u* [) L+ F
/* Include files */" A5 N  W6 X& k2 D% d  t
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun ). p! Z; z) E2 G6 n7 u. Y1 v
#   include <strstream>
1 F  D6 p# L+ L6 r& }' x#   include <iostream>1 p8 k: H7 ^9 ^9 B3 b2 Y
    using std:strstream;2 L) u, p5 B# J
    using std::endl;   
4 z5 p- j- l# D    using std::ends;- L  m, p. e! o6 a( ?' C
    using std::cerr;
# V& T" Z  ]; [' h4 E5 Q7 H#else7 M# B0 e9 Z. P1 i" `2 J
#   include <strstream.h>
& X! o" e. ^( b+ k& v( l#   include <iostream.h>1 e+ Y" M" |6 W% i6 ]
#endif
% D- H8 p* i0 i- t) B#include <uf.h>
, X+ Q5 f  C! t' Y#include <uf_ui.h>
: R2 @) ^6 k; S  d: S) u5 K#include <uf_exit.h>1 V1 j, }: t; i, ]' |* s
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))  u. S: x- r( k' S
static int report_error( char *file, int line, char *call, int irc)
/ P- Q. s+ O# s# S6 ^5 ]{2 r2 K) Z: h6 n4 `
    if (irc)
) J9 }) a/ y/ w5 z$ ]& B. M    {+ l; l. b- X& N4 q" n9 k4 L
        char err[133],- C/ u3 @+ J) I  O
             msg[133];2 A0 l$ G, C$ C9 f7 E3 E
        sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",' V, F; A' J5 y+ S/ N
            irc, line, file);
3 q/ Q! `1 ?, W( @# I3 [* a2 S        UF_get_fail_message(irc, err);
1 g# S3 f; ~$ V. g0 r2 i+ R5 y7 \        UF_print_syslog(msg, FALSE);
4 x& W1 M- B) ]        UF_print_syslog(err, FALSE);1 M+ l% G' P0 e% t+ O
        UF_print_syslog("\n", FALSE);/ A5 _9 q) i. B, T
        UF_print_syslog(call, FALSE);
/ K2 x7 z6 q- q1 S3 a" j# Q        UF_print_syslog(";\n", FALSE);0 B5 z; ]2 n7 u, Z/ R* H
        if (!UF_UI_open_listing_window())
0 z& d, r& U6 i; M+ B        {
1 X8 ^5 u4 p# _6 ^: {4 X* I0 w            UF_UI_write_listing_window(msg);
' U" b& |3 t0 B: m            UF_UI_write_listing_window(err);
% C2 F  b, O9 t2 n% t, I            UF_UI_write_listing_window("\n");. T; M) [- M) r- b
            UF_UI_write_listing_window(call);
3 m/ x9 |1 e! Q3 u& ]# p& _            UF_UI_write_listing_window(";\n");
* x& D0 r$ F6 z5 |        }
$ Q: M# P8 E/ N! g9 m* \/ G6 i3 Q    }, ]: G5 g% h  `  H1 ]  _
    return(irc);
, f. `( i8 \9 h- E! e}1 O! r2 P) o- D: O6 {7 H7 L
  Y6 Z& N9 x" `1 D' [3 |; E
/*****************************************************************************
) h. Z4 C1 D) Z. x**  Activation Methods, E. M9 p# c' d
*****************************************************************************/8 t, S7 Y0 n4 w1 y) I
/*  Explicit Activation# J  T+ _% G" ?" ~- X+ A
**      This entry point is used to activate the application explicitly, as in/ A) I- i# S6 ~. p# ~" z' @
**      "File->Execute UG/Open->User Function..." */' e2 P4 w+ r5 u1 W, P. z7 ]
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )1 m; n: v2 {5 M) o; Y
{% j4 k- u! q' O2 b$ t0 ^* N
    /* Initialize the API environment */4 @" v; D; M& @
char prompt_string[]="open file";% s: k2 W: U9 s! \- t9 _, x" i
char title_string[] = "select file";- O# e# {' u9 o" S2 C
char filter_string[] = "*.prt";- f4 o! N& ]; q4 O5 s/ n# _
char default_name[] = "my file";
1 N# b4 r- t. d# T( Q5 I; ` char filename[256];( R4 D+ v* C- d6 x6 e
int response;) l9 I: y3 y" f1 ^3 P
    if( UF_CALL(UF_initialize()) ) 0 u- N6 |- Q: H
    {
8 N% |7 t8 y' J) M        /* Failed to initialize */2 m/ C1 s: I$ n# x
        return;1 k5 {2 N* R( Q, S
    }; j! t9 x$ A& i( g2 q, ]
    1 B: ^. m% D2 N" F% i# d! r
    /* TODO: Add your application code here */! Q" \6 B9 \/ |$ ?  w5 }
UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox+ B; O& ^) K# y# c
    /* Terminate the API environment */
1 K, Y! v4 \, S: y8 P1 {    UF_CALL(UF_terminate());
1 N4 M  C$ ?5 G' T  t( F8 T+ q" Z}
; a" W* A8 ]$ P: p8 h( d4 [/*****************************************************************************
1 ]& C, l* x3 w$ P# I**  Utilities( I4 P0 d# u! M4 f; |
*****************************************************************************/9 c  R4 `: ?7 @9 u2 m3 M! }9 j; K% P
/* Unload Handler4 W% q+ L& C* w$ ]1 z& B" B, B8 G
**     This function specifies when to unload your application from Unigraphics.
# m: ]' l( ]8 G4 f**     If your application registers a callback (from a MenuScript item or a; J- n, W8 M* Q, D# B/ x8 X1 w
**     User Defined Object for example), this function MUST return
2 S# r9 \/ e+ o( D**     "UF_UNLOAD_UG_TERMINATE". */0 Q4 w' W* G" b) }$ b# v
extern int ufusr_ask_unload( void )8 u, c- H0 [0 ]8 I# a
{
) f! I) T! V1 h' g% Q6 h    return( UF_UNLOAD_IMMEDIATELY );
; I5 |' T' E; W1 L8 p; o5 d3 i}
* |" n0 B5 V0 C( @( W
7 i1 A% c7 O( X- G; G
CreateFilebox.png
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

全部回复4

320

主题

226

回帖

9784

积分

管理员

PLM之家NX|TC专家

积分
9784
发表于 2015-5-2 20:07:06 | 显示全部楼层
UF_UI_create_filebox 我没有试你这个
. r, s$ }# k+ U4 ?1 S* Q
! p# D4 Z) j& X3 Q% S% j5 ?" B1 G不过你加个uf_call或者看下syslog 啥问题
2 J1 n7 A* `% p. ^# x# e. x9 v* w/ Q# A4 R/ s
该会员没有填写今日想说内容.
回复 支持 反对

使用道具 举报

4

主题

4

回帖

83

积分

培训VIP会员

积分
83
 楼主| 发表于 2015-5-2 20:18:39 | 显示全部楼层
mildcat 发表于 2015-5-2 20:071 ~! z6 o5 Y0 Z( b) |8 ?
UF_UI_create_filebox 我没有试你这个 6 }4 z6 q( ^' P, ]: `6 x0 D
$ e5 T. ^/ E' V% e% e; b' k* P( A
不过你加个uf_call或者看下syslog 啥问题
+ w0 [" F$ [) l$ [
UF_CALL没有报错。打开文件的对话框也生成了。就是在点击ok之后,UG崩掉了。
2 X1 M3 ], |) Y" U: a我想用UF_UI_create_filebox()创建一个打开文件的对话框。UG有别的函数可以创建打开文件的对话框?
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复 支持 反对

使用道具 举报

8

主题

58

回帖

896

积分

培训VIP会员

积分
896
发表于 2015-5-5 08:31:59 | 显示全部楼层
文星和合 发表于 2015-5-2 20:18" }3 G, d! K3 o3 p: b6 o  y
UF_CALL没有报错。打开文件的对话框也生成了。就是在点击ok之后,UG崩掉了。  ^) o' v( R6 p% n$ c8 `
我想用UF_UI_create_filebox ...

! J4 W3 m: o: Q% `* E! {  y: x& l. n; F  K$ v2 V: w. {+ L
#include <uf.h>! h9 }4 G6 e8 R$ }! T3 r9 Z
#include <uf_ui.h>" l& K% K/ \- Z! ^. G* q4 z# P( z
#include <uf_exit.h>
7 P) k0 n. q, H9 ?extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
: a6 y, s( {6 Q1 A1 O1 e- w. I{
/ \# A" s$ c1 J  ]% N- w# ?# Y: Z8 D- \        /* Initialize the API environment */) O, z( h( {/ M' F
        char *prompt_string="输入文件名";2 Q( R+ F8 w% b* t& H- _! J: x9 f
        char *title_string = "另存为";, Z% N; m6 O: @# z
        char *filter_string = "E:\\+*.prt";8 i9 q2 i& b& u: y! E
        char *default_name = "OK-PRT";
( h+ y' K6 u' F        char filename[256];1 I- l: ^& x, v) J! q2 b
        int response;% N' Z( N3 R: l* p- ?
        UF_initialize();
( L& z$ L5 G6 C- S! V* R- L        UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);
4 C8 m) y$ e4 a3 [  |/ x7 Z        if (response ==UF_UI_OK)5 k0 H# y2 a# N" ?$ G0 l, J$ m
                uc1601(filename,1);
  D/ W# x% e  I6 a' T# k  P' B        else if(response ==UF_UI_CANCEL)1 S1 ^3 u# u* B0 T6 F
                uc1601("取消",1);; Z9 n% u& y! {& [) Z) M
        UF_terminate();
, c  I' s! P7 {3 B4 E}
6 ?3 N6 Y+ D+ ~& Iextern int ufusr_ask_unload( void )& P8 u! m2 H5 H- g: V' r: \
{
# U6 e7 O8 R' [9 d% G$ {% v        return( UF_UNLOAD_IMMEDIATELY );  w  o$ X) h1 M
}

评分

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

查看全部评分

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

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

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

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

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

    我知道了