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();
  • 相关阅读:
    SQL获取当天0点0分0秒和23点59分59秒方法
    全球唯一标识符 System.Guid.NewGuid().ToString()
    Js获取当前日期时间及其它操作
    MySQL日期函数与日期转换格式化函数大全
    访问者模式
    享元模式
    中介者模式
    职责链模式
    命令模式
    桥接模式
  • 原文地址:https://www.cnblogs.com/nxopen2018/p/11876256.html
Copyright © 2011-2022 走看看