PLM之家PLMHome-国产软件践行者

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

  [复制链接]

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

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

文星和合 楼主

2015-5-1 11:53:07

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

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

x
8 z0 L( ^: a& R2 Z
/*****************************************************************************: G" G: f( j- b
**
1 l% g# v( ~" j7 _- I** createfilebox.cpp
, ^1 `8 E$ u) [8 p: I**
4 W% T- {" Y% u! ?6 f. t** Description:
6 d( J& D* U2 Z. r6 [, l' r**     Contains Unigraphics entry points for the application.
9 W2 |& M0 o8 C* K( u8 i**! t& P" O7 }' p& B! `
*****************************************************************************/6 n/ D5 P3 Z" \+ N  \4 i0 a- t. `) v
/* Include files */
1 ?; w3 T8 ]" J! a( ]#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )/ t/ L/ H$ {7 h
#   include <strstream>, P, S' l4 l5 S4 h
#   include <iostream>1 H, |+ `1 b  {- ^/ [# P
    using std:strstream;
$ Y$ i; J% N+ W2 K! j" D& b    using std::endl;    ! C2 C" }8 t7 x4 T8 V
    using std::ends;
% U  d0 I/ C: x! h. r) y    using std::cerr;  a& p# o# K% n1 @& |" E/ Z
#else
! s; y5 x0 O) m# P. R#   include <strstream.h>
7 f1 C) I; \: a* N8 b( {! ^, T/ \#   include <iostream.h>
) e+ N/ j4 m/ r1 G) A- K#endif
3 u* Y4 S/ S% Y2 x& x% @#include <uf.h>
! v) |  b- w+ `" ~, u#include <uf_ui.h>
3 p& R/ K0 e' s& t- F#include <uf_exit.h>
, }4 [' D) h3 J#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
9 T6 F$ O5 Q5 X5 I$ w) j0 cstatic int report_error( char *file, int line, char *call, int irc). {4 I4 E) Y0 p/ P- T& a  C( c3 ?' O
{
2 O1 a+ y  `+ c7 S0 E0 f    if (irc). ~6 R4 z# [& o2 f1 V
    {. K; _# b1 n! n& u) W
        char err[133],' O9 m2 J* \; f6 g1 {4 Y! _
             msg[133];7 \) Z& G9 T6 V! T! @" e1 ]/ c, r0 G
        sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",: N9 P" a% x' Q% U! G" q- R3 _! d% ^5 V
            irc, line, file);
6 P0 s3 j: `8 q( }3 |        UF_get_fail_message(irc, err);! o% R4 |- I9 ^, D6 r3 X9 O* }
        UF_print_syslog(msg, FALSE);
4 m6 l1 v8 J; \7 j5 u+ Z        UF_print_syslog(err, FALSE);
: ^3 t: d! F0 q8 E3 X) d* a% ?( }        UF_print_syslog("\n", FALSE);6 w5 k# V# L8 x6 l
        UF_print_syslog(call, FALSE);  t& R# I- z8 U! A  g5 ]
        UF_print_syslog(";\n", FALSE);$ N4 ~7 O4 D: s
        if (!UF_UI_open_listing_window())' i( A4 s) m! I
        {6 C4 k; J# ]3 g) j; c  C
            UF_UI_write_listing_window(msg);3 X! U; W) p' M' Q+ O% F* h5 m
            UF_UI_write_listing_window(err);, g) T3 @' m7 ~
            UF_UI_write_listing_window("\n");  _: _8 k( i: \8 H
            UF_UI_write_listing_window(call);8 {6 r  V- F9 q; E: r( B. c
            UF_UI_write_listing_window(";\n");
# {) a' h7 q" e8 l' X        }
2 e/ Q) q! y; @    }
: ~- c0 p) }: u% c8 M' U$ `. S& i    return(irc);
' u' o8 j: P4 }/ Q}
  v. Y3 T5 f) ~& S/ U# o* Y8 h
: w! }8 \! C) e8 u) P2 d/*****************************************************************************
5 L$ c- Q( R; |- |6 y$ Y**  Activation Methods: b( F# ?. x" x. `0 G  i$ L$ d
*****************************************************************************/# g5 ^* W# d+ j' Q, O" ~' r9 Q: B
/*  Explicit Activation
2 I+ y1 X& v2 Y* b* C**      This entry point is used to activate the application explicitly, as in
& Z6 _4 P- M; R**      "File->Execute UG/Open->User Function..." */
; J+ _: K; q# q" z5 n! c2 Fextern DllExport void ufusr( char *parm, int *returnCode, int rlen )8 d/ s) S* ^3 Y% \* k
{, Z' Y$ C4 `! j: w5 i  F
    /* Initialize the API environment */4 l) A5 s6 C7 @! T8 f' r) ?2 K
char prompt_string[]="open file";
" w$ }" U( Z) v6 Q9 a( H char title_string[] = "select file";
2 V; |5 b2 f0 a4 r5 i( E6 t char filter_string[] = "*.prt";) R! h2 i% c# C# |
char default_name[] = "my file";
8 z. z7 {9 E8 d  \ char filename[256];
4 H. U8 ?; z& @; K8 W% `- C& x int response;2 r) C  ]% h5 n& ^9 ]( _! d, V2 o
    if( UF_CALL(UF_initialize()) ) 6 n. C+ e$ \' G' P
    {! T9 Y( h! B' m5 r7 R
        /* Failed to initialize */+ d  k5 ?$ Y: K& M" j
        return;
' Z8 g$ g" Q9 g    }
9 [) w- e. ?5 p! H3 r    + o+ v6 j( |8 q
    /* TODO: Add your application code here */
8 p" k7 e% w% P9 n UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox
: k& ^4 n" h; Z8 [6 q3 C( d; `    /* Terminate the API environment */% l& y5 ?' a4 J+ j2 K3 Z
    UF_CALL(UF_terminate());
6 x5 m9 j# L% G2 \}
' w9 Y% Z' l/ y& o. u" _, c3 j3 d5 _/*****************************************************************************/ H; _' M) O# d. l/ R8 W9 h
**  Utilities
+ V3 x& j9 `! w$ {*****************************************************************************/
! T; D. Q% W! @, _  |! J/* Unload Handler6 P- [: B0 `. r8 b2 p" ?
**     This function specifies when to unload your application from Unigraphics.3 y! u; D0 m. J0 v: k. O
**     If your application registers a callback (from a MenuScript item or a
5 Y1 s7 I+ f1 n- ~& ?**     User Defined Object for example), this function MUST return
. _( H3 @% p* {* W7 b**     "UF_UNLOAD_UG_TERMINATE". */! W! T6 y5 d" ~# n) e, X  s1 d; V* V
extern int ufusr_ask_unload( void )6 ]! \+ J- u; m$ A- R
{# c6 G, E" `2 u( Y, G, a
    return( UF_UNLOAD_IMMEDIATELY );' L2 X, j& n$ [- ~/ y4 u
}: K& D( Z0 g: \- R7 v5 ~

) ~/ E2 o# f" H) H6 C0 \
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 我没有试你这个
, C+ t* c( V! Z6 B/ i) s* i* R
  }: b0 v4 y8 \, N, J4 A+ [不过你加个uf_call或者看下syslog 啥问题
3 J" W+ b; d. L4 q6 K$ O
+ J, n% e% m! y0 a/ B. r
该会员没有填写今日想说内容.
回复 支持 反对

使用道具 举报

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

文星和合 板凳

2015-5-2 20:18:39

mildcat 发表于 2015-5-2 20:07; H& T) f8 G0 O+ h2 c" Y
UF_UI_create_filebox 我没有试你这个
6 M3 M0 o: ]4 l$ p
0 |4 V( c" @9 |; I4 C$ _不过你加个uf_call或者看下syslog 啥问题

: h: `. _0 Z8 w$ W- cUF_CALL没有报错。打开文件的对话框也生成了。就是在点击ok之后,UG崩掉了。# H" U8 B% {+ c9 D8 }0 v) U+ Z  C' u
我想用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* ~. Q! R& \* \& R5 {  M
UF_CALL没有报错。打开文件的对话框也生成了。就是在点击ok之后,UG崩掉了。
2 Q- m* T5 f& y' U( ~: m: ~. L& W我想用UF_UI_create_filebox ...
  i' ^: X' O; I* y

4 P# r! W8 D5 E) k, c, ?#include <uf.h>6 Y( @( A. V2 t) q% p
#include <uf_ui.h>3 M( ?& M( w1 r8 N2 L
#include <uf_exit.h>
2 G; ?/ F% V# X' G+ E  q  Kextern DllExport void ufusr( char *parm, int *returnCode, int rlen )
* s* [! d, N  ?' l) F$ |) T! P! a$ K; P{9 C( }0 V' k6 l( u7 a/ b
        /* Initialize the API environment */# u9 c4 s( M+ L3 @- _' o
        char *prompt_string="输入文件名";
! v3 Y: Z" \$ j9 g8 B        char *title_string = "另存为";
  h1 X& d8 m0 P% v        char *filter_string = "E:\\+*.prt";  o7 Q- }8 I, X' I& D/ V6 v
        char *default_name = "OK-PRT";7 O8 i+ z! j' n6 G  L: z6 _  v/ `3 r
        char filename[256];
" Z" @$ a: C" D! s  d. X& Q7 S        int response;
8 a) I- V/ l2 q: O; \        UF_initialize();$ K- h2 F' s' B+ X9 l, K9 Z0 w
        UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);
7 b, T& ^0 h, \6 q( [        if (response ==UF_UI_OK)0 i# ]! Y1 }1 [: z. ?" q" O
                uc1601(filename,1);
7 H- i  }9 g- P) Q! ?- R7 P        else if(response ==UF_UI_CANCEL)
) O+ b: z+ @: K. k                uc1601("取消",1);
" z4 K$ |4 K# K( r( @& [& K) ]        UF_terminate();
! T0 }# F% X4 f1 \3 _' ^2 ?, Q}" l1 q& A% Y4 d5 _2 z. Y. \$ k
extern int ufusr_ask_unload( void )+ L) f! D; Q9 o8 u  w  x. p
{
! o  R7 s6 E( m. V# y        return( UF_UNLOAD_IMMEDIATELY );
+ I* B- S& m/ E# ]3 P) O$ G}

评分

参与人数 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二次开发专题模块培训报名开始啦

    我知道了