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

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

  [复制链接]

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

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

文星和合 楼主

2015-5-1 11:53:07

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

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

x

6 M" i, }6 _: Z1 U$ h" b/*****************************************************************************
, p% t$ m) w* ^/ E$ L**% P4 J+ P( A3 C6 X" _$ l) v
** createfilebox.cpp
  Y; Z7 M# |2 V! L! v**
. i1 n6 W8 X4 H; D! _** Description:* W: s, U8 l1 V8 g9 `/ a: [5 x
**     Contains Unigraphics entry points for the application.
# V$ o1 `  M8 _. G& T  Y**/ T/ m+ X, V2 l" R! w
*****************************************************************************/$ i3 w3 Z/ k, }+ Z7 o+ S3 q
/* Include files */
) ^9 N5 K: h9 J/ G( S9 R  k#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )+ n* j7 _( m* F9 T- d
#   include <strstream>. o5 U3 i" [0 G7 E4 V2 F
#   include <iostream>* z8 S+ a- I5 b! N' S
    using std:strstream;
" v# s7 k3 L8 v1 b& G& |    using std::endl;    $ n" A* N1 g9 {
    using std::ends;
; E/ {) u( n  F' L4 Q    using std::cerr;
. ]/ y$ n6 M8 Z! C#else
( `! M* L  f+ G+ R8 ?8 s$ `& _9 u#   include <strstream.h>
( t2 ~9 Q+ H( Q#   include <iostream.h>
; A( P: C% _0 `1 E1 v- S#endif- [' f4 n% q: p- z$ |3 h0 P
#include <uf.h>
0 _& d8 U# _$ a" {9 q#include <uf_ui.h>
- A  W* c/ V# D2 a( |  i#include <uf_exit.h>/ |! A8 f( L9 Z+ r! n( a
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
) [+ ~6 g. s: [7 a/ hstatic int report_error( char *file, int line, char *call, int irc)
4 u2 K* a+ j* d9 V: k) B! G{
% Z$ ^4 c* d, M1 Z7 r* Q/ {    if (irc)7 x; `! E7 I3 X. q% x5 u: a  n
    {
" i1 [. R. X( I& F        char err[133],/ p. u- c3 Q; {% m8 H0 J) w
             msg[133];" _  p) @+ G; J
        sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
7 L8 \) K' l. J' I( G5 X4 o( y            irc, line, file);# f- m8 V7 w7 E$ Y
        UF_get_fail_message(irc, err);  ~7 s, f9 W! U0 f
        UF_print_syslog(msg, FALSE);
' E2 n" c4 z, B        UF_print_syslog(err, FALSE);% W8 ^6 ^( p! B
        UF_print_syslog("\n", FALSE);0 B. [' V* O) B  Q8 r0 b! A% [
        UF_print_syslog(call, FALSE);
5 o/ }0 T9 U; ~; ~5 `! g        UF_print_syslog(";\n", FALSE);: [. ~* u/ ~9 ~% C1 N  K$ k
        if (!UF_UI_open_listing_window())
8 ^! x& e4 C- Y, O$ ^- R6 y        {
3 P: r! S4 }# {& D6 ^5 }; I3 [, Z            UF_UI_write_listing_window(msg);
& w! N$ m; `. Q  Z9 j            UF_UI_write_listing_window(err);1 ]3 e( _9 s# V
            UF_UI_write_listing_window("\n");! L' a5 L) Y1 M8 Y' ^& t, W
            UF_UI_write_listing_window(call);5 ?3 w7 i- w+ W
            UF_UI_write_listing_window(";\n");9 S$ w7 o0 N9 H" c+ s
        }
1 {' D0 b0 q7 |4 N! D5 `4 k    }
  o6 J& u) L! [0 c4 d  V    return(irc);& U( i# n: G9 q  S+ K
}2 b( F% ]4 L3 i- M: z8 H

' C& l  n$ Z. }* ^) h3 Y/*****************************************************************************
2 s+ b5 F: W$ Q/ }% I0 ^**  Activation Methods* \/ J& i  [2 z4 I2 m3 z
*****************************************************************************/
( ?5 N; ~" x0 s* j/*  Explicit Activation
/ G; I4 n/ s# h) ~5 t! z**      This entry point is used to activate the application explicitly, as in$ R0 i% S6 I7 @+ a
**      "File->Execute UG/Open->User Function..." */
8 e2 Q4 A! H3 J+ ^8 R. aextern DllExport void ufusr( char *parm, int *returnCode, int rlen )3 m: p  h0 F# [. U0 ?
{
! F- U/ W0 _3 R    /* Initialize the API environment */: H$ ^- d% s; b& i2 K
char prompt_string[]="open file";
" {% Q+ ^6 o' _, X6 E char title_string[] = "select file";# A% t' t2 i2 j8 w. t
char filter_string[] = "*.prt";* y. M/ K$ O/ e4 ~/ J/ ]4 U
char default_name[] = "my file";
0 ~9 X2 r  c& O+ h0 n char filename[256];9 P" k5 i1 g+ P& K! Q
int response;
" V6 A6 k2 I+ d; t( D    if( UF_CALL(UF_initialize()) )
  C' ?& N" c. \/ x: \    {9 S3 t# k& h4 T/ f8 S+ [# p
        /* Failed to initialize */
6 @" [7 D$ R/ R7 z9 Y3 O        return;9 v8 A! I; @. w3 P9 |
    }
2 X' f! `( ~9 Q$ n: F   
4 p% P: a! \: k    /* TODO: Add your application code here */
: U/ k1 a8 V, H3 P! \" C UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox; a- I! ?/ p; K+ N
    /* Terminate the API environment */
/ D' l) @. z- @2 E0 U    UF_CALL(UF_terminate());& n" T$ A& v& B( t* d. S
}( |8 j6 g9 }; r) I, g- K+ |6 R
/*****************************************************************************
$ D% }4 x( s- u**  Utilities* E: ^  u1 ^7 Y7 ?' Y
*****************************************************************************/' K; g2 i' M- j1 d& @
/* Unload Handler! X$ z- w' n0 q/ W. P
**     This function specifies when to unload your application from Unigraphics.
1 C' |3 O& t0 R**     If your application registers a callback (from a MenuScript item or a: T* {" V- ], B7 P" h+ ^  L
**     User Defined Object for example), this function MUST return
' t  v% B2 U$ J3 o3 B5 E# O' D9 e3 F9 c& |: b**     "UF_UNLOAD_UG_TERMINATE". */  n. s* C, T& H& _  G' l
extern int ufusr_ask_unload( void )* m/ I! y. M* f: M- ?- n6 h
{
2 a' _0 N3 \2 J  f3 }    return( UF_UNLOAD_IMMEDIATELY );
  M1 X: a0 p; X) m}
  C5 L4 g9 H# F5 K/ K" g# U8 k6 m% K4 j& |3 f5 s
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 我没有试你这个
/ s- m5 F, t) {# N5 A4 G  |' B. K
& x" E( S* m: `/ M* k  G+ E不过你加个uf_call或者看下syslog 啥问题
" ^% d2 A5 T: }5 S% F1 O* ]! h- S  [0 y/ Y+ x2 @$ I
该会员没有填写今日想说内容.
回复 支持 反对

使用道具 举报

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

文星和合 板凳

2015-5-2 20:18:39

mildcat 发表于 2015-5-2 20:075 h8 c% l8 g0 [1 }
UF_UI_create_filebox 我没有试你这个 , R- C% G. |4 J/ R; S
8 L3 H' }: {3 h4 G$ g8 F; F
不过你加个uf_call或者看下syslog 啥问题

8 a% ?7 c& A  I3 w# x! {UF_CALL没有报错。打开文件的对话框也生成了。就是在点击ok之后,UG崩掉了。
5 r; P: |4 \( v5 q* c我想用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
6 T5 e5 D4 Y' Q  L& tUF_CALL没有报错。打开文件的对话框也生成了。就是在点击ok之后,UG崩掉了。* ^" g: D5 Z! m+ B3 T) x
我想用UF_UI_create_filebox ...

2 w7 d# u( G" y7 T' B
8 L7 X# k) ]6 f  S  ~5 J#include <uf.h>
5 _, @/ H9 p" O2 }6 x. d#include <uf_ui.h>; M1 L- Z5 U- t2 m/ V
#include <uf_exit.h>' i+ V* I' C/ m- B& ~
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
( Y, K) k# Y! u{
) @- N  A  \! ^6 D; r* u0 D& q, B        /* Initialize the API environment */% Z$ u$ ]. |' |5 W
        char *prompt_string="输入文件名";! ^$ I( Q9 U4 O4 F! K% _- f5 y1 m
        char *title_string = "另存为";
* _# i1 W# x; G) F* l, q        char *filter_string = "E:\\+*.prt";
- i2 T  }6 I5 Z7 Y) A& L        char *default_name = "OK-PRT";
8 s3 l  y- I$ m6 M$ t        char filename[256];8 ^9 E) Y" T) X7 X7 v
        int response;
9 Z0 @" J( b* Q& I2 K# B3 e3 F        UF_initialize();
# T$ N" v' |: Q) p        UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);+ S  x1 C" s' g' n+ s* I
        if (response ==UF_UI_OK)4 Q# T8 `* N# F; w
                uc1601(filename,1);
/ D: Q5 t/ R9 d! L+ \        else if(response ==UF_UI_CANCEL)
' e9 H4 ^" i& T                uc1601("取消",1);3 {8 u& U; t3 y3 c. f+ \
        UF_terminate();
" j5 n# f  z8 N}
, @& q6 g1 x% v( fextern int ufusr_ask_unload( void )+ j% W: y( n: J' N1 H+ x
{
; U+ T: d2 k: z* [3 ^" k! H        return( UF_UNLOAD_IMMEDIATELY );
+ U  r/ K& t2 Y) s}

评分

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

    我知道了