PLM之家PLMHome-工业软件与AI结合践行者

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

  [复制链接]

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

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

文星和合 楼主

2015-5-1 11:53:07

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

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

x
9 g- c0 |9 M) a3 X
/*****************************************************************************
, i, y3 z" A5 A3 N**
1 M* ~# {4 G- t4 \1 g3 ]) ?: j% O$ J** createfilebox.cpp
" Y" ~$ o6 R7 w+ _  l2 G3 I**: M5 E  i; |0 b
** Description:
- v, k% g7 h8 O5 H0 n**     Contains Unigraphics entry points for the application.
) n( r% O. j& c**8 m" O# b. G/ U
*****************************************************************************/
) }; v2 l8 O, S9 C8 r3 P% B! o9 }/* Include files */
( I; K" C6 a5 {#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )# [5 H/ ^& i7 B/ H# @
#   include <strstream>  }: x! ?  t! G* ?* B1 \- a% Y
#   include <iostream>
& m$ z& p* S* }$ ]: s/ x    using std:strstream;
0 A: f2 j* E5 |' h6 ?# S    using std::endl;   
: K% [* }. `; V1 Z3 F    using std::ends;0 D' p6 W; V& x& A. m7 D$ N7 T& m
    using std::cerr;
. y9 _8 J1 g6 f+ g8 T#else
0 ~! @% e+ X" ~- u#   include <strstream.h>
' q0 ?2 x# I4 n5 h, |! s#   include <iostream.h>
: u! b1 t4 q+ x! [" P#endif
* O- B& g& c( h3 W$ G% O/ _#include <uf.h>; v5 ], w$ d' r& v! x
#include <uf_ui.h>* A1 x4 T7 W5 B( @6 [+ z( ^
#include <uf_exit.h>
" u$ `6 n8 V# K* T! g/ z% x" l#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))$ g! I' G8 L3 F4 |  a" K
static int report_error( char *file, int line, char *call, int irc)
$ g8 |( h! j  @5 G{
' v2 l' j& \' @, a* r    if (irc)
7 Z9 M' ]" e6 ~    {
6 Y4 n* X6 K8 {6 u        char err[133]," Y+ u  o/ B" S5 U  Y; f
             msg[133];
& _/ ~/ B7 D. s        sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",/ i8 E! Z3 \  n
            irc, line, file);
) F5 p4 C. v) e: a5 x5 c        UF_get_fail_message(irc, err);
5 ]( k; t8 X- N  m/ ~1 b        UF_print_syslog(msg, FALSE);
: n2 b8 h8 T+ o! X9 r8 {        UF_print_syslog(err, FALSE);( F" [% A, x0 |5 o6 o
        UF_print_syslog("\n", FALSE);
! ?7 a; J1 R8 W+ q2 Z. W        UF_print_syslog(call, FALSE);
- |  z! K" d( X. M2 {+ ~1 O        UF_print_syslog(";\n", FALSE);
6 R7 r5 f6 _) u2 N: S0 P% q/ x        if (!UF_UI_open_listing_window())
2 d& i3 o' }% H' a        {& s* E- K# D, e% H
            UF_UI_write_listing_window(msg);) e$ d; M+ d4 G# V& Q
            UF_UI_write_listing_window(err);
: q+ [' f, o  ^0 L3 d            UF_UI_write_listing_window("\n");
/ F  u' y. O( y            UF_UI_write_listing_window(call);
. Y. \" W; \. Z( i9 {  T            UF_UI_write_listing_window(";\n");
5 x7 r4 e: S  n9 ~. f/ J' `8 b! M        }# q6 M  w, h1 e! P( ~/ v% f+ x
    }
. z  {* B; V5 K- {: f, K+ c5 |. T    return(irc);, w# r' b$ x1 b- p/ w) E1 C8 r7 f
}
& O/ S& x, t; @9 j) Q+ o2 [3 @) b2 c3 N( p, ^: J/ {! Q
/*****************************************************************************5 K- ?- w$ b3 B6 H/ M
**  Activation Methods
- ]" z" A( q7 d" B1 B7 c1 [7 V*****************************************************************************/
1 r( Z( O5 y  E- @6 r) W8 R; L3 B/*  Explicit Activation* Q- _4 v6 M) x% m; Z
**      This entry point is used to activate the application explicitly, as in# ]9 d9 G, E" s8 U+ F
**      "File->Execute UG/Open->User Function..." */8 J! B9 m0 W' M
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )' X. j4 \: s% n1 H" v
{
/ m$ t) ^8 w( |2 t4 j7 B& b  b( F' ]    /* Initialize the API environment */: a0 f& u3 ~$ k9 l* j" i
char prompt_string[]="open file";
. U2 j2 a8 _$ x8 L char title_string[] = "select file";/ I7 d' S* K* A0 P; h8 \
char filter_string[] = "*.prt";1 w* s( f: K9 e) L7 `( ~" ?3 \* E
char default_name[] = "my file";
+ o6 N8 `5 b4 ?3 u; f char filename[256];* A7 _* N6 U* ]6 E' k' I( v9 q
int response;
* ~; j6 L3 o$ j; B    if( UF_CALL(UF_initialize()) ) * e% V* A, l+ x& a: C" C
    {6 Z) P- e( U( h* ~1 ?7 r+ L) f
        /* Failed to initialize */
* C+ z) ^! y6 M" N4 k3 E5 s$ G        return;5 `# |. U" M2 E' l6 u% ?' m: S
    }+ Z3 I" H$ o- N1 X
   
) k+ I8 g* y- {% u7 b7 \    /* TODO: Add your application code here */  u8 h: H$ d) D9 f
UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox
8 y) t) M3 y) O0 s. ]    /* Terminate the API environment */
/ z8 H& B4 D7 t  p# ]( U    UF_CALL(UF_terminate());2 s/ p' t+ C; `; w
}
# Z  {7 X" `" [$ ^" ^/*****************************************************************************0 w2 b5 _# u% I( t$ o- k
**  Utilities- q" j. u8 d: X: R" l
*****************************************************************************/2 Y# c" [! Y0 x
/* Unload Handler
/ A: B/ I1 j6 N( o; e: E2 H, H**     This function specifies when to unload your application from Unigraphics., N- k1 s2 q5 w
**     If your application registers a callback (from a MenuScript item or a: T' j- I; X) D0 O- {
**     User Defined Object for example), this function MUST return
8 b' O8 p5 H/ \8 C, _**     "UF_UNLOAD_UG_TERMINATE". *// }3 x8 {( [6 W& I/ j1 |1 o+ c
extern int ufusr_ask_unload( void )  y  q& X: a6 |9 G" e/ E# ~# c% j) w+ p
{# b9 T) d. u5 Q$ \* m% n9 Y. P5 f
    return( UF_UNLOAD_IMMEDIATELY );9 P3 i. K/ c. ^$ u
}
! U9 N9 k: ]& ?0 u  P" R# r
& e* I" @  |: {$ K) ~, 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 我没有试你这个
  l; u7 L+ j* A( b' V
) I5 b; z/ T1 i& Z不过你加个uf_call或者看下syslog 啥问题 6 k2 \0 K8 s" ]6 [( V. Q3 j
) D' ~3 |; \8 o# I( p8 T. h! B( n
该会员没有填写今日想说内容.
回复 支持 反对

使用道具 举报

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

文星和合 板凳

2015-5-2 20:18:39

mildcat 发表于 2015-5-2 20:07
8 }: O( y& W& X( t! h7 J# D6 A4 g$ KUF_UI_create_filebox 我没有试你这个 8 T7 Z8 h) |4 i2 Q; l

+ j& a0 J. h, ~* J' h  ?4 I8 S不过你加个uf_call或者看下syslog 啥问题
$ R2 W* g) C4 ?9 i
UF_CALL没有报错。打开文件的对话框也生成了。就是在点击ok之后,UG崩掉了。
- k4 P3 U# d0 Q1 M我想用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:186 ~+ U7 U7 n8 Y4 p" E
UF_CALL没有报错。打开文件的对话框也生成了。就是在点击ok之后,UG崩掉了。5 e- h# m$ S: T1 ^/ z" e
我想用UF_UI_create_filebox ...
: Q  d; Z( D8 ~) w/ C" J

! E4 ~& r" d/ G& ~3 n#include <uf.h>
6 l/ @# O2 g% a  _( E#include <uf_ui.h>
: X( {- ]6 T  D#include <uf_exit.h>
' F. M' y0 R4 {/ c. w$ Z/ d: r! Eextern DllExport void ufusr( char *parm, int *returnCode, int rlen )
, ?* p9 D; A2 k- ?{, P  j* t) C) l3 Q) T9 W" U, I
        /* Initialize the API environment */
$ K; o. N! l* D  }        char *prompt_string="输入文件名";) ~8 {% x. X. n0 M; M+ B6 _
        char *title_string = "另存为";
' n" |) Z! P/ L4 D        char *filter_string = "E:\\+*.prt";% N! {( _: D- J/ f( p
        char *default_name = "OK-PRT";2 _( n6 Y% v) L' g
        char filename[256];4 ~) Q2 h9 Z, e% Y. d6 ^
        int response;
! O5 }  S1 Z8 f" W0 l" k        UF_initialize();* ?# a8 F9 r6 D2 w( W
        UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);+ S$ r0 b7 B$ E4 ^- H, E
        if (response ==UF_UI_OK)
+ |2 C0 k5 V% l8 `2 y5 c                uc1601(filename,1);. B* B% ^% b2 d) s" K: |* {2 a
        else if(response ==UF_UI_CANCEL)
, g4 m% U2 h: C                uc1601("取消",1);
. |4 J& H  F& R; a( E        UF_terminate();+ r: A) F& ~2 J" U# R
}4 |2 B# z% Q7 O& x1 Y: _6 I/ K
extern int ufusr_ask_unload( void )0 f  s7 o, \9 q5 v0 y
{. l6 [3 L4 I2 D% ~: O% t/ [$ Y
        return( UF_UNLOAD_IMMEDIATELY );3 s# \* @' c* q( S" 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二次开发专题模块培训报名开始啦

    我知道了