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

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

  [复制链接]

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

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

文星和合 楼主

2015-5-1 11:53:07

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

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

x

1 T" S# ^3 c1 V/*****************************************************************************
# _3 K2 Z! i- I2 x9 [1 H* u  s**
3 f! U$ i0 H. }6 U** createfilebox.cpp3 B9 T. E* G0 Z1 \3 S% v% S
**
) c% ?) [7 Y1 a+ E+ N$ x, z0 D** Description:
( r5 `, r3 ?9 B0 e4 g2 u**     Contains Unigraphics entry points for the application.
  H" H' T  x+ F. Q% U/ }: x**
1 M/ l/ l2 W, n. K*****************************************************************************/" H9 u$ S0 T' e* N) j, O1 i
/* Include files */
( x! c( H1 Y( m#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun ): ?' o+ v* c/ C3 ^' e0 t
#   include <strstream>9 F  j* M& x& B2 N
#   include <iostream>
! j# D, G; k- S6 y    using std:strstream;
9 O7 ]% M) W) M8 W& M" L    using std::endl;   
( C9 z1 Z+ v0 G8 k    using std::ends;
. h5 s# ]/ I# V' d. k    using std::cerr;. S' _$ N9 e1 n7 v
#else
) O' b: h% b$ j7 Z% l  y$ b#   include <strstream.h>
) `: {4 S% A  c5 v. L0 L#   include <iostream.h>
2 |3 n% e  Q  {6 ~2 Y#endif
, o+ F9 K7 E9 R4 S#include <uf.h>
" W9 [  A+ x. I2 c. m( Y5 ?! z#include <uf_ui.h>
/ {7 C$ e/ D( i3 [- L7 b#include <uf_exit.h>5 L8 h: S- r, `' v
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
0 x- j3 O" S: Q: X  hstatic int report_error( char *file, int line, char *call, int irc)3 D9 M8 _; _3 S6 c
{9 i* D- z+ T# p0 G
    if (irc)
* q; c4 \. }# i    {
1 W$ L9 v! w! D3 b+ A        char err[133],
6 S  u& z" K) U  Q' \# n* P- f             msg[133];/ t- w. c( `1 h) Y0 e0 \
        sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
7 t# t7 F! l/ \% r            irc, line, file);# Y: F8 r2 G' |, v; j9 S$ p
        UF_get_fail_message(irc, err);
+ H6 V/ O$ L4 C5 M        UF_print_syslog(msg, FALSE);1 j5 x# d  c$ F5 [0 w1 T( z
        UF_print_syslog(err, FALSE);6 I. b$ @3 d7 f3 W
        UF_print_syslog("\n", FALSE);3 }0 Z7 f: d' k; V# `$ }# Y& N4 O, B: {
        UF_print_syslog(call, FALSE);. \0 v* ?) ?3 q$ E# Z1 Q
        UF_print_syslog(";\n", FALSE);, b9 P: ]- ]# a" C* o: d
        if (!UF_UI_open_listing_window())  g6 S; @/ V* B; x
        {
. {4 D3 G3 m) i( h2 c0 V            UF_UI_write_listing_window(msg);3 u; _1 C, S$ W' ^* s8 [$ o' I
            UF_UI_write_listing_window(err);9 k* q4 T4 |/ l3 a
            UF_UI_write_listing_window("\n");/ A1 E5 f. `" J8 o( X
            UF_UI_write_listing_window(call);
' ~  |) Z4 ?( [0 K. m) r$ e$ Q) j            UF_UI_write_listing_window(";\n");
5 o5 ]7 \6 y0 {0 f: \% A        }8 F. g+ j$ \  g  O2 k
    }. W6 ?# a  P& K! _
    return(irc);8 g8 f" i5 J1 l( L% H& L
}
; \: K9 k) N+ `: |' m/ Y, U& |" I/ P; g, @/ f
/*****************************************************************************2 X; i! X$ _& J- V' G; R3 s2 L
**  Activation Methods7 i+ N( o- b) L% l
*****************************************************************************/
- x, e: Y2 c- t( Y, O6 f( X/ V/*  Explicit Activation- Z: A2 ~4 v8 b9 Q8 [
**      This entry point is used to activate the application explicitly, as in
8 D* u4 W( m+ J5 O+ R; w  G  K**      "File->Execute UG/Open->User Function..." */$ ~; t5 F( p$ F9 `- e7 x
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
3 u' F  z; i8 a5 K3 \{1 v/ T5 y! T# s$ ~" J
    /* Initialize the API environment */
8 p% f8 |4 F1 d; \ char prompt_string[]="open file";
! w9 h  p0 {) k7 v2 h char title_string[] = "select file";
( _- H/ p: e# D9 Z char filter_string[] = "*.prt";6 k) s, q. X% r5 M( m
char default_name[] = "my file";
0 a7 k/ y" R0 x  z, Y: X char filename[256];
/ Q& Y4 }1 {' \" t9 _( c int response;
* C. B7 [) ~% h    if( UF_CALL(UF_initialize()) )
- k  l3 `7 h. @) }0 R, i    {
& l% T2 x; o" z( F2 Z' s$ Z: j        /* Failed to initialize */
  n. }1 s* ?' g- B        return;
( f- C+ a; L6 X    }
2 I9 L( H$ y) C! \4 o   
& \8 \0 K( @. B* V# c$ w* |- R7 a    /* TODO: Add your application code here */8 A' c- W: a3 r7 I
UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox
/ Z* O4 D$ N' w5 I/ \* ]* Y7 V    /* Terminate the API environment */( G7 i& s' n+ q2 |; w
    UF_CALL(UF_terminate());! [( p/ g. `& K
}+ N/ l3 H3 _, r) X4 T1 e" W( e6 b. \
/*****************************************************************************
/ I- x' E0 y+ D% F/ w/ l# Q6 [**  Utilities2 V& m" q8 X5 T0 ^
*****************************************************************************/2 ^4 r1 N, x* R7 w4 `0 Q: {
/* Unload Handler6 U) D# }0 I( P& S( p
**     This function specifies when to unload your application from Unigraphics.
) L/ y' t4 X3 i) s7 V: _**     If your application registers a callback (from a MenuScript item or a
4 {: a" Y8 A+ C, E+ [+ S6 _7 _**     User Defined Object for example), this function MUST return* w8 Z% m- @# k# Q% \
**     "UF_UNLOAD_UG_TERMINATE". */+ S! @4 r# \, h; H3 S8 T/ U
extern int ufusr_ask_unload( void )( H" W# O" S, k$ a4 }# G
{
! }: y6 b0 }$ F: W, w6 D    return( UF_UNLOAD_IMMEDIATELY );
4 [: M) o) V4 T* P0 v: W( w1 t}/ ^) h& r: y7 h! }8 k

" I. a5 \" Q% F* w
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 我没有试你这个 6 B: _  z7 P" p3 R

8 b6 Y2 [  S* J3 S! j* g+ `' M0 P不过你加个uf_call或者看下syslog 啥问题 5 |' ]. T" `, ^; V- x% `! e- v

5 s0 W3 z$ a1 ^
该会员没有填写今日想说内容.
回复 支持 反对

使用道具 举报

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

文星和合 板凳

2015-5-2 20:18:39

mildcat 发表于 2015-5-2 20:07
6 U' ]) ^% L; q/ X# R% w7 pUF_UI_create_filebox 我没有试你这个
1 T/ ^7 Q& ?' I) w8 y
7 K+ x9 [( ^7 s9 S' w2 V不过你加个uf_call或者看下syslog 啥问题

4 m# i- G$ A  ?# xUF_CALL没有报错。打开文件的对话框也生成了。就是在点击ok之后,UG崩掉了。& M! ?- [1 `& x  @/ w
我想用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
9 p- Q: x( q* {2 iUF_CALL没有报错。打开文件的对话框也生成了。就是在点击ok之后,UG崩掉了。8 ?" ]1 s4 v3 J, i; q
我想用UF_UI_create_filebox ...
) t8 \/ g) @1 q! B% U. `- W

  n' d+ k8 p2 F( r1 Y# z! b5 q+ T#include <uf.h>2 h( V+ p+ K! W* K
#include <uf_ui.h>
$ Q& c( o: G. |  T0 b0 e% m, g#include <uf_exit.h>
9 j/ ~3 d+ {/ Z; Q$ K0 kextern DllExport void ufusr( char *parm, int *returnCode, int rlen )  ]8 C; B+ z4 Y0 }! a) c5 h
{" B6 i( p! w" o, H! \1 E
        /* Initialize the API environment */3 x2 j" z( u8 M5 U/ I7 D9 ~7 T
        char *prompt_string="输入文件名";
( r2 ]- }+ c* J        char *title_string = "另存为";
6 I9 ~9 G. D6 N; b        char *filter_string = "E:\\+*.prt";
1 u0 R) N) \; D        char *default_name = "OK-PRT";' l  K* g+ u* `0 N6 Q8 V  f1 Y
        char filename[256];
6 x5 F( \) \7 {9 y( `; D        int response;
/ n8 d! x: n0 l# r2 v8 \        UF_initialize();, u2 L1 A1 P, }4 P
        UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);
; ?% [$ W  ^4 d' Y6 U1 i        if (response ==UF_UI_OK)
3 @* o/ c3 y# U! u+ ~                uc1601(filename,1);
: P! l4 P" X$ B- K4 a8 Q/ F        else if(response ==UF_UI_CANCEL)
8 }7 r9 d: o' }/ G6 A* F                uc1601("取消",1);" Q, d5 O# [4 ?1 N
        UF_terminate();4 x- Q* ^1 t  c2 S
}
, Q7 t' Y! Z* g4 j  Aextern int ufusr_ask_unload( void )$ V7 j4 H7 A/ P; {4 @7 ~. O
{9 r) X9 j+ V1 n* P" P: f
        return( UF_UNLOAD_IMMEDIATELY );
( T: d0 G* u) d+ `+ ]! U5 b! G/ P}

评分

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

    我知道了