zoukankan      html  css  js  c++  java
  • NX二次开发-UFUN结合NXOPEN开发_常用代码模板

    hpp

     1 //头文件
     2 #include <NXOpen/Part.hxx>
     3 #include <NXOpen/PartCollection.hxx>
     4 #include <NXOpen/Session.hxx>
     5 #include <NXOpen/ListingWindow.hxx>
     6 #include <NXOpen/NXMessageBox.hxx>
     7 #include <NXOpen/UI.hxx>
     8 #include <stdarg.h>
     9 #include <strstream>
    10 #include <iostream>
    11 
    12 using namespace NXOpen;
    13 using namespace std;
    14 public:
    15     static Session *theSession;
    16     static UI *theUI;
    17     void print(const NXString &);
    18     void print(const string &);
    19     void print(const char*);
    20 
    21 private:
    22     Part *workPart, *displayPart;
    23     NXMessageBox *mb;
    24     ListingWindow *lw;
    25     LogFile *lf;

    cpp

     1 //使用UF_CALL
     2 static void ECHO(char *format, ...)
     3 {
     4     char msg[UF_UI_MAX_STRING_BUFSIZE];
     5     va_list args;
     6     va_start(args, format);
     7     vsnprintf_s(msg, sizeof(msg), _TRUNCATE, format, args);
     8     va_end(args);
     9     UF_UI_open_listing_window();
    10     UF_UI_write_listing_window(msg);
    11     UF_print_syslog(msg, FALSE);
    12 }
    13 
    14 #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
    15 
    16 static int report_error(char *file, int line, char *call, int irc)
    17 {
    18     if (irc)
    19     {
    20         char err[133];
    21 
    22         UF_get_fail_message(irc, err);
    23         ECHO("*** ERROR code %d at line %d in %s:
    ",
    24             irc, line, file);
    25         ECHO("+++ %s
    ", err);
    26         ECHO("%s;
    ", call);
    27     }
    28 
    29     return(irc);
    30 }
    31 
    32 
    33 构造函数()
    34         mb = theUI->NXMessageBox();
    35         lw = theSession->ListingWindow();
    36         lf = theSession->LogFile();
    37         workPart = theSession->Parts()->Work();
    38         displayPart = theSession->Parts()->Display();
  • 相关阅读:
    初拾Java(问题一:404错误,页面找不到)
    新年新气象--总结过去,展望未来
    接口测试[整理]
    [转]SVN-版本控制软件
    浅谈黑盒测试和白盒测试
    Bug管理工具的使用介绍(Bugger 2016)
    P2805/BZOJ1565 [NOI2009]植物大战僵尸
    近期学习目标
    P3643/BZOJ4584 [APIO2016]划艇
    P5344 【XR-1】逛森林
  • 原文地址:https://www.cnblogs.com/nxopen2018/p/11876256.html
Copyright © 2011-2022 走看看