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

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

  [复制链接]

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

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

文星和合 楼主

2015-5-1 11:53:07

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

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

x
! _7 Z  C! }- y' c# e
/*****************************************************************************9 x: q( ]" Q6 X7 ]: A/ W
**
! [( N* F/ a' o8 ?, k& e** createfilebox.cpp
, l# D) V+ E+ w" a! b0 d9 N9 V5 D**; {/ G4 _7 W# u1 X2 R8 ~
** Description:% e; C; o8 p: K  m4 R  r: O
**     Contains Unigraphics entry points for the application.
! J4 X- S6 H) Q  o$ b: B& x**5 t3 R/ g# d9 i
*****************************************************************************/
# D" B) Q; ^/ y8 x9 `, ?/* Include files */
" V' }. B$ y5 E2 ]/ x' B#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )2 C5 a: w+ v3 i
#   include <strstream>
7 d) J- q) o; m& p! X1 N#   include <iostream>
8 C1 B* [) Y( f+ K    using std:strstream;/ w$ j+ G: E8 }) w; e. C" w
    using std::endl;   
5 X6 H% y- k3 w% h) O    using std::ends;
2 s/ {% k' D& w. R# b    using std::cerr;
8 i- W- s8 [9 q/ H9 Y#else
1 F6 F5 \- z. [$ I* C, V. D- C#   include <strstream.h>
0 e; O) z8 v; C8 m" |#   include <iostream.h>
+ Q( [, Q, F, g: |  v9 W#endif
" ]! C) o+ S3 R#include <uf.h>
+ G  J( L) r4 ?2 w#include <uf_ui.h>
& \: ?) e: I! x3 O* I8 i$ |' C0 G#include <uf_exit.h>% m1 Y, n% t1 A# N4 t& ?1 B# k
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))): W) l3 h1 F% ~8 O
static int report_error( char *file, int line, char *call, int irc)- r% Z7 f- _& X
{5 ~8 A( T" h5 z* s2 y9 m
    if (irc)/ l1 L8 I& u5 R, \; \6 s) \
    {& S  q/ w8 k2 t% t6 c
        char err[133],! f4 `( B. @! P8 Y
             msg[133];* |# c& f( D, g: M2 a
        sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",1 g* d, t% U4 H% }$ f8 Z1 ?0 h" ?
            irc, line, file);
( x% t  G$ @2 Z; k0 \9 Y' p        UF_get_fail_message(irc, err);
$ B; L/ J  u/ t/ q: \8 }        UF_print_syslog(msg, FALSE);* e2 _! @, b5 [$ D6 z+ `1 ?8 G. a# \
        UF_print_syslog(err, FALSE);' s; b. ^% s4 b& x2 j! o
        UF_print_syslog("\n", FALSE);5 q0 W/ U  R! P4 G; C
        UF_print_syslog(call, FALSE);
* `8 A% i! L  t& b        UF_print_syslog(";\n", FALSE);& k8 b2 V9 g4 P# a% k' _$ R6 W
        if (!UF_UI_open_listing_window())* X3 q/ @4 y+ D3 p, N& M- h! l
        {
5 b2 x/ a" `" V. E& V! f            UF_UI_write_listing_window(msg);  Z# Z# }& [# g
            UF_UI_write_listing_window(err);" f7 U) \! `! \. K
            UF_UI_write_listing_window("\n");
2 \+ D- R1 o# r$ D            UF_UI_write_listing_window(call);
6 P# Y: s0 u9 \; N7 A& o8 o& e            UF_UI_write_listing_window(";\n");9 X% w: t* T8 B+ g
        }3 b$ O4 G9 g9 n# B1 r7 O$ B
    }6 U* @2 h/ l# M
    return(irc);
: B4 g' |* l1 H/ {( m2 V}
! \( T, b/ V1 F
) f% H0 c* L3 c/*****************************************************************************6 H1 t4 W  ]9 l4 p, d
**  Activation Methods
  y# {( s' e, p) M6 g5 y7 V3 F5 |*****************************************************************************/6 I2 s6 A; j- K
/*  Explicit Activation/ u( r4 _4 y. h
**      This entry point is used to activate the application explicitly, as in
* U- t. k" K; }- a# {**      "File->Execute UG/Open->User Function..." */2 |' R4 I3 F; D: ~
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )4 [5 M# N) N( I8 Z  o  B
{' c% U$ V3 i4 m" \2 k7 L7 [
    /* Initialize the API environment */2 [7 E( M& T9 `* h: H
char prompt_string[]="open file";
; Y, q; h& {0 {7 T5 c8 W/ I char title_string[] = "select file";
' `- `& k! Z7 U9 t char filter_string[] = "*.prt";
- j% j1 a+ g6 h8 Y# H( d1 H( h0 N char default_name[] = "my file";+ _& N7 \/ \! X/ N, f6 |
char filename[256];
) ]8 N7 f# m) o; y int response;
7 k8 s2 y! U1 {! ]+ e    if( UF_CALL(UF_initialize()) )
" n3 A4 b; b! J0 a  _9 J* v. f    {
5 ~$ O8 q) o" l6 D        /* Failed to initialize */: c0 q. V% t( M* ~+ t1 e2 t, m# k9 ?
        return;% q6 A) M( t5 }( |% \$ h
    }- U6 N# M1 ]0 y
    6 \$ a) N2 [. r, {
    /* TODO: Add your application code here */& A- r3 K4 q6 I2 R& T" g2 [3 l
UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox
. E" {5 e# z" L) q    /* Terminate the API environment */% v( X  U# }" p; k' |9 S: ]! T
    UF_CALL(UF_terminate());
# U3 ]7 j) N, O5 K2 W2 o}
; Q) m) O/ [/ |# J/*****************************************************************************
6 g) m$ r/ N, \$ k8 V; V8 R/ @**  Utilities' l7 P$ v' ~: [6 z: l# m
*****************************************************************************/3 w5 g/ M- O# Q0 i
/* Unload Handler
6 G2 z" H) M, H" I**     This function specifies when to unload your application from Unigraphics.
" l1 @  H9 H' x6 p9 L**     If your application registers a callback (from a MenuScript item or a
/ t$ I1 L2 k, T2 G; M7 B6 Z7 z) N**     User Defined Object for example), this function MUST return% f' A$ N, v+ ^! C) C" C
**     "UF_UNLOAD_UG_TERMINATE". */
; n% v  ~, X* L  Nextern int ufusr_ask_unload( void )
/ Z; o7 G/ ~% S: P) X* c7 N& w{
) |$ z& T+ G6 a2 E, h8 t# F( q    return( UF_UNLOAD_IMMEDIATELY );
2 v7 b% n- }5 ?  ?}( T( X4 F9 u( T+ P1 \; @# y. E  W
! i! R3 W$ X4 r( D) p/ |2 M
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 我没有试你这个
: D* T4 x0 z! f2 f/ H  z& A1 ]& F8 n: A0 d
不过你加个uf_call或者看下syslog 啥问题 * _! q6 V& V8 |9 A# c. Q9 i9 H

# x! s/ u# x# D
该会员没有填写今日想说内容.
回复 支持 反对

使用道具 举报

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

文星和合 板凳

2015-5-2 20:18:39

mildcat 发表于 2015-5-2 20:07# T9 U' C) |, s/ y$ K( g( h
UF_UI_create_filebox 我没有试你这个 3 g  C9 O, D3 D$ e

4 D+ V3 V1 c6 N6 A; Z不过你加个uf_call或者看下syslog 啥问题

$ R5 g, X/ ]) Y5 {% nUF_CALL没有报错。打开文件的对话框也生成了。就是在点击ok之后,UG崩掉了。
/ Y. z$ J2 f' Q- p2 Q7 J# G, |& o我想用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
! N' f  R+ n! S/ x. x, mUF_CALL没有报错。打开文件的对话框也生成了。就是在点击ok之后,UG崩掉了。
" @; V( O+ f$ T$ F! J我想用UF_UI_create_filebox ...
" a5 K4 P# f# @( K

* d) W7 ^* @; a( ]/ K/ R#include <uf.h>- y! q" J: J/ @4 v
#include <uf_ui.h>
5 x4 a2 u' {6 g  a0 y% U0 n. m#include <uf_exit.h>
+ i" J' p1 F: e3 a% w2 b3 |  Hextern DllExport void ufusr( char *parm, int *returnCode, int rlen )
0 I. J3 L2 k" a) n; M( b{7 F% Y9 l# O5 d6 ?) v6 U
        /* Initialize the API environment */
& W5 \  z7 p3 ^& g& ?        char *prompt_string="输入文件名";
$ H+ C: W4 I1 ^$ c0 E        char *title_string = "另存为";
$ ~: Q: k  x% W7 F  p. J$ Z7 P- N        char *filter_string = "E:\\+*.prt";
2 S5 _' \% [; L% b' S* T        char *default_name = "OK-PRT";% s6 T" A0 e+ A2 F6 U" `% Y
        char filename[256];
) Y+ j- i5 ~, f4 Z3 c. |& n2 j9 K        int response;" N4 W4 p* s( i8 e5 O3 h
        UF_initialize();
  b& M% w: e, |+ z2 _5 D& }8 t        UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);' C6 j( V4 y  s/ A1 N
        if (response ==UF_UI_OK)9 O' v0 g; f( j5 x. _% P- {5 g
                uc1601(filename,1);% c' R/ {+ S7 e# a0 N  \
        else if(response ==UF_UI_CANCEL)6 a- u; ^+ I1 h5 j7 q9 p1 _3 H
                uc1601("取消",1);3 [+ Y: T( Q4 |1 y% ?' e' h
        UF_terminate();
2 J7 e$ x9 |$ O  z# m}
( w9 W' k4 Y- C' gextern int ufusr_ask_unload( void ): y  e/ N5 W- L3 F
{8 \  U1 X5 C) x+ c$ p
        return( UF_UNLOAD_IMMEDIATELY );
  H0 x3 ]# `  y3 g5 ?/ L5 ]! N0 R}

评分

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

    我知道了