zoukankan      html  css  js  c++  java
  • NX二次开发-重命名装配组件

    在GC工具里面是有一个重命名装配组件的命令的,除了这个外,好像没看到NX里还有其他可以重命名装配组件的命令,本来以为在UFUN ASSEM装配的头文件里会有更改装配部件名字的函数,但是没有找到,可能没有。本来以为UF_ASSEM_rename_instance这个可以,后来发现还不行,这个只能改右键属性名字。

    但是我找到了替换组件的函数,我觉得这个是可以实现功能的。后来我按照自己想到的思路,对照着GC工具就写了一下。

    我的思路是这样的:一个单选对话框->选择装配组件->得到tag->由tag得到装配组件的part名字->把名字显示到一个字符串窗口->用户更改名字->copy本地那个装配组件.prt文件->把新名字命名给copy后的那个.prt文件->

    然后用替换组件函数替换copy后的那个.prt文件->最后在把copy前那个旧的.prt文件删掉

      1 //RenameComponent
      2 
      3 // Mandatory UF Includes
      4 #include <uf.h>
      5 #include <uf_object_types.h>
      6 
      7 // Internal Includes
      8 #include <NXOpen/ListingWindow.hxx>
      9 #include <NXOpen/NXMessageBox.hxx>
     10 #include <NXOpen/UI.hxx>
     11 
     12 // Internal+External Includes
     13 #include <NXOpen/Annotations.hxx>
     14 #include <NXOpen/Assemblies_Component.hxx>
     15 #include <NXOpen/Assemblies_ComponentAssembly.hxx>
     16 #include <NXOpen/Body.hxx>
     17 #include <NXOpen/BodyCollection.hxx>
     18 #include <NXOpen/Face.hxx>
     19 #include <NXOpen/Line.hxx>
     20 #include <NXOpen/NXException.hxx>
     21 #include <NXOpen/NXObject.hxx>
     22 #include <NXOpen/Part.hxx>
     23 #include <NXOpen/PartCollection.hxx>
     24 #include <NXOpen/Session.hxx>
     25 
     26 #include <uf.h>
     27 #include <uf_ui.h>
     28 #include <uf_modl.h>
     29 #include <uf_part.h>
     30 #include <uf_curve.h>
     31 #include <uf_assem.h>
     32 #include <uf_obj.h>
     33 #include <windows.h>
     34 #include <stdarg.h>
     35 #include <strstream>
     36 #include <iostream>
     37 #include <string>
     38 #include <io.h>  
     39 
     40 // Std C++ Includes
     41 #include <iostream>
     42 #include <sstream>
     43 
     44 using namespace NXOpen;
     45 using std::string;
     46 using std::exception;
     47 using std::stringstream;
     48 using std::endl;
     49 using std::cout;
     50 using std::cerr;
     51 
     52 
     53 //------------------------------------------------------------------------------
     54 // NXOpen c++ test class 
     55 //------------------------------------------------------------------------------
     56 class MyClass
     57 {
     58     // class members
     59 public:
     60     static Session *theSession;
     61     static UI *theUI;
     62 
     63     MyClass();
     64     ~MyClass();
     65 
     66     void do_it();
     67     void print(const NXString &);
     68     void print(const string &);
     69     void print(const char*);
     70 
     71     int DelectValue;//对话框返回值,决定是否删除原组件
     72     string NameOrPath(const char* Path, int Type);//返回.prt文件名字和所在文件夹路径
     73     void filesearch(string path, int layer);//遍历文件夹所有.prt文件
     74     char part_name[MAX_FSPEC_BUFSIZE];//当前显示部件.prt文件所在路径
     75     char str[133];//字符串输入对话框值
     76 
     77 private:
     78     Part *workPart, *displayPart;
     79     NXMessageBox *mb;
     80     ListingWindow *lw;
     81     LogFile *lf;
     82 };
     83 
     84 //------------------------------------------------------------------------------
     85 // Initialize static variables
     86 //------------------------------------------------------------------------------
     87 Session *(MyClass::theSession) = NULL;
     88 UI *(MyClass::theUI) = NULL;
     89 
     90 //------------------------------------------------------------------------------
     91 // Constructor 
     92 //------------------------------------------------------------------------------
     93 MyClass::MyClass()
     94 {
     95 
     96     // Initialize the NX Open C++ API environment
     97     MyClass::theSession = NXOpen::Session::GetSession();
     98     MyClass::theUI = UI::GetUI();
     99     mb = theUI->NXMessageBox();
    100     lw = theSession->ListingWindow();
    101     lf = theSession->LogFile();
    102 
    103     workPart = theSession->Parts()->Work();
    104     displayPart = theSession->Parts()->Display();
    105     
    106 }
    107 
    108 //------------------------------------------------------------------------------
    109 // Destructor
    110 //------------------------------------------------------------------------------
    111 MyClass::~MyClass()
    112 {
    113 }
    114 
    115 //------------------------------------------------------------------------------
    116 // Print string to listing window or stdout
    117 //------------------------------------------------------------------------------
    118 void MyClass::print(const NXString &msg)
    119 {
    120     if(! lw->IsOpen() ) lw->Open();
    121     lw->WriteLine(msg);
    122 }
    123 void MyClass::print(const string &msg)
    124 {
    125     if(! lw->IsOpen() ) lw->Open();
    126     lw->WriteLine(msg);
    127 }
    128 void MyClass::print(const char * msg)
    129 {
    130     if(! lw->IsOpen() ) lw->Open();
    131     lw->WriteLine(msg);
    132 }
    133 
    134 
    135 
    136 static int select_filter_proc_fn(tag_t object, int type[3], void* user_data, UF_UI_selection_p_t select)
    137 {
    138     if (object == NULL)
    139     {
    140         return UF_UI_SEL_REJECT;
    141     }
    142     else
    143     {
    144         return UF_UI_SEL_ACCEPT;
    145     }
    146 }
    147 
    148 static int init_proc(UF_UI_selection_p_t select, void* user_data)
    149 {
    150     int num_triples = 1;//可选类型的数量
    151     UF_UI_mask_t mask_triples[] =
    152     { UF_component_type, UF_UI_SEL_NOT_A_FEATURE,
    153     };//可选对象类型
    154     UF_UI_set_sel_mask(select, UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC, num_triples, mask_triples);
    155     if ((UF_UI_set_sel_procs(select, select_filter_proc_fn, NULL, user_data)) == 0)
    156     {
    157         return UF_UI_SEL_SUCCESS;
    158     }
    159     else
    160     {
    161         return UF_UI_SEL_FAILURE;
    162     }
    163 }
    164 
    165 
    166 string MyClass::NameOrPath(const char* Path, int Type)
    167 {
    168     //反向找位置,分割字符串(只读取文件夹路径)
    169     string strPath = Path;
    170     string strDir;
    171     int nPos = strPath.find_last_of('\');
    172     if (string::npos != nPos)
    173     {
    174         strDir = strPath.substr(0, nPos);
    175     }
    176 
    177     //分割字符串(只读取part名字+后缀)
    178     //方法2
    179     int pos = strPath.find_last_of('\');
    180     string s1(strPath.substr(pos + 1));
    181 
    182     //分割字符串(只读取part名)
    183     string PartName(s1.substr(0, s1.find(".prt")));
    184 
    185     if (Type == 1)
    186     {
    187         return PartName;//返回名字
    188     }
    189     else if (Type == 2)
    190     {
    191         return strDir;//返回文件夹路径
    192     }
    193 }
    194 
    195 
    196 void MyClass::filesearch(string path, int layer)
    197 {
    198     char msg[256] = "";
    199     char msgg[256] = "";
    200     struct _finddata_t filefind;
    201     string f;
    202     string curr = path + "\*.*";
    203     int done = 0, i, handle;
    204     if ((handle = _findfirst(curr.c_str(), &filefind)) != -1)
    205     {
    206         while (!(done = _findnext(handle, &filefind)))
    207         {
    208             if (strcmp(filefind.name, "..") == 0)
    209                 continue;
    210             for (i = 0; i < layer; i++)
    211                 printf("	");
    212             if ((_A_SUBDIR == filefind.attrib))              // 是目录  
    213             {
    214                 curr = path + "\" + filefind.name;
    215                 sprintf(msg, "%s
    ", curr.c_str());
    216                 //UF_UI_write_listing_window(msg);
    217                 filesearch(curr, layer + 1);                  // 递归遍历子目录  
    218             }
    219             else                                            // 是文件
    220             {
    221 
    222                 sprintf(msg, "%s", filefind.name);
    223                 if (strlen(msg) > 4)
    224                 {
    225                     strncpy(msgg, msg + strlen(msg) - 4, 4);
    226                     if (strcmp(msgg, ".prt") == 0)             // 文件格式
    227                     {
    228                         f = path + "\" + filefind.name;
    229                         sprintf(msg, "%s
    ", f.c_str());
    230                         //UF_UI_write_listing_window(msg);
    231 
    232                         //分割字符串(只读取part名)
    233                         string PartName = NameOrPath(f.c_str(), 1);
    234                         string PartPath = NameOrPath(f.c_str(), 2);
    235 
    236                         //分割字符串(只读取part名)
    237                         string PartName1 = NameOrPath(part_name, 1);
    238 
    239                         //找到名字相同的.prt文件
    240                         if (PartName == PartName1)
    241                         {
    242                             //转换
    243                             char NewName1[256];
    244                             sprintf(NewName1, "\%s.prt", str);
    245                             string NewName2 = NewName1;
    246                             //字符串拼接
    247                             string NewName = PartPath + NewName2;
    248 
    249                             //copy出一个新的.prt文件
    250                             CopyFile(f.c_str(), NewName.c_str(), FALSE);
    251 
    252                             //由名字得到装配部件实例的TAG
    253                             tag_t instanceTAG = UF_ASSEM_ask_instance_of_name(UF_PART_ask_display_part(), part_name);
    254 
    255                             //重新命名装配部件的part名称
    256                             UF_PART_load_status_t load_status;
    257                             UF_ASSEM_use_alternate(&instanceTAG, NewName.c_str(), str, str, &load_status);
    258 
    259                             //由对话框值判断是否删除原组件
    260                             if (DelectValue == 5)
    261                             {
    262                                 //删除旧名字的.prt文件
    263                                 DeleteFile(f.c_str());
    264                             }
    265 
    266 
    267                         }
    268 
    269                     }
    270                 }
    271             }
    272         }
    273         _findclose(handle);
    274     }
    275 }
    276 
    277 
    278 //------------------------------------------------------------------------------
    279 // Do something
    280 //------------------------------------------------------------------------------
    281 void MyClass::do_it()
    282 {
    283 
    284     // TODO: add your code here
    285     
    286     UF_initialize();
    287 
    288     //单对象选择对话框
    289     char sCue[] = "单对象选择对话框";
    290     char sTitle[] = "选择一个装配组件";
    291     int iScope = UF_UI_SEL_SCOPE_NO_CHANGE;
    292     int iResponse;
    293     tag_t tView;
    294     double adCursor[3];
    295     tag_t ComponentTag = NULL_TAG;//单选控件获得的tag
    296     UF_UI_select_with_single_dialog(sCue, sTitle, iScope, init_proc, NULL, &iResponse, &ComponentTag, adCursor, &tView);
    297 
    298     //获取装配部件的part名称
    299     char refset_name[UF_OBJ_NAME_BUFSIZE];
    300     char instance_name[UF_CFI_MAX_FILE_NAME_BUFSIZE];
    301     double origin[3];
    302     double csys_matrix[9];
    303     double transform[4][4];
    304     UF_ASSEM_ask_component_data(ComponentTag, part_name, refset_name, instance_name, origin, csys_matrix, transform);
    305 
    306     //输入字符串控件
    307     char * cue = "输入框";
    308     //转换
    309     char str1[133];
    310     sprintf(str1, "%s", part_name);
    311     //分割字符串(只读取part名)
    312     string PartName1 = NameOrPath(str1, 1);
    313     sprintf(str, "%s", PartName1.c_str());
    314     int length = 0;
    315     uc1600(cue, str, &length);
    316 
    317     //弹出对话框
    318     char sPromptStr1[] = "单选菜单对话框";
    319     int iDefault1 = 0;
    320     char asOptions1[][38] = { "删除原组件", "保留原组件" };
    321     int iNumOfOptions1 = 2;
    322     DelectValue = uc1603(sPromptStr1, iDefault1, asOptions1, iNumOfOptions1);
    323 
    324     //获得当前显示部件.prt文件所在路径
    325     char part_fspec[MAX_FSPEC_BUFSIZE];
    326     UF_PART_ask_part_name(UF_PART_ask_display_part(), part_fspec);
    327 
    328     //获取文件夹路径
    329     string strDir = NameOrPath(part_fspec, 2);
    330 
    331     //遍历文件夹
    332     filesearch(strDir, 0);
    333     
    334     UF_terminate();
    335 
    336 }
    337 
    338 //------------------------------------------------------------------------------
    339 // Entry point(s) for unmanaged internal NXOpen C/C++ programs
    340 //------------------------------------------------------------------------------
    341 //  Explicit Execution
    342 extern "C" DllExport void ufusr( char *parm, int *returnCode, int rlen )
    343 {
    344     try
    345     {
    346         // Create NXOpen C++ class instance
    347         MyClass *theMyClass;
    348         theMyClass = new MyClass();
    349         theMyClass->do_it();
    350         delete theMyClass;
    351     }
    352     catch (const NXException& e1)
    353     {
    354         UI::GetUI()->NXMessageBox()->Show("NXException", NXOpen::NXMessageBox::DialogTypeError, e1.Message());
    355     }
    356     catch (const exception& e2)
    357     {
    358         UI::GetUI()->NXMessageBox()->Show("Exception", NXOpen::NXMessageBox::DialogTypeError, e2.what());
    359     }
    360     catch (...)
    361     {
    362         UI::GetUI()->NXMessageBox()->Show("Exception", NXOpen::NXMessageBox::DialogTypeError, "Unknown Exception.");
    363     }
    364 }
    365 
    366 
    367 //------------------------------------------------------------------------------
    368 // Unload Handler
    369 //------------------------------------------------------------------------------
    370 extern "C" DllExport int ufusr_ask_unload()
    371 {
    372     return (int)NXOpen::Session::LibraryUnloadOptionImmediately;
    373 }
    374 
    375 Caesar卢尚宇
    376 2019年8月12日

    补充:

    今天又写了第二种方法(2019年8月13日)

      1 //NX9_NXOpenCPP_Wizard2
      2 
      3 // Mandatory UF Includes
      4 #include <uf.h>
      5 #include <uf_object_types.h>
      6 
      7 // Internal Includes
      8 #include <NXOpen/ListingWindow.hxx>
      9 #include <NXOpen/NXMessageBox.hxx>
     10 #include <NXOpen/UI.hxx>
     11 
     12 // Internal+External Includes
     13 #include <NXOpen/Annotations.hxx>
     14 #include <NXOpen/Assemblies_Component.hxx>
     15 #include <NXOpen/Assemblies_ComponentAssembly.hxx>
     16 #include <NXOpen/Body.hxx>
     17 #include <NXOpen/BodyCollection.hxx>
     18 #include <NXOpen/Face.hxx>
     19 #include <NXOpen/Line.hxx>
     20 #include <NXOpen/NXException.hxx>
     21 #include <NXOpen/NXObject.hxx>
     22 #include <NXOpen/Part.hxx>
     23 #include <NXOpen/PartCollection.hxx>
     24 #include <NXOpen/Session.hxx>
     25 
     26 
     27 #include <uf.h>
     28 #include <uf_assem.h>
     29 #include <uf_obj.h>
     30 #include <uf_part.h>
     31 #include <uf_modl.h>
     32 #include <uf_ui.h>
     33 #include <windows.h>
     34 #include <uf_disp.h>
     35 
     36 
     37 // Std C++ Includes
     38 #include <iostream>
     39 #include <sstream>
     40 
     41 using namespace NXOpen;
     42 using std::string;
     43 using std::exception;
     44 using std::stringstream;
     45 using std::endl;
     46 using std::cout;
     47 using std::cerr;
     48 
     49 
     50 //------------------------------------------------------------------------------
     51 // NXOpen c++ test class 
     52 //------------------------------------------------------------------------------
     53 class MyClass
     54 {
     55     // class members
     56 public:
     57     static Session *theSession;
     58     static UI *theUI;
     59 
     60     MyClass();
     61     ~MyClass();
     62 
     63     void do_it();
     64     void print(const NXString &);
     65     void print(const string &);
     66     void print(const char*);
     67 
     68     //单选
     69     int DelectValue;//对话框返回值,决定是否删除原组件
     70     string NameOrPath(const char* Path, int Type);//返回.prt文件名字和所在文件夹路径
     71 
     72 private:
     73     Part *workPart, *displayPart;
     74     NXMessageBox *mb;
     75     ListingWindow *lw;
     76     LogFile *lf;
     77 };
     78 
     79 //------------------------------------------------------------------------------
     80 // Initialize static variables
     81 //------------------------------------------------------------------------------
     82 Session *(MyClass::theSession) = NULL;
     83 UI *(MyClass::theUI) = NULL;
     84 
     85 //------------------------------------------------------------------------------
     86 // Constructor 
     87 //------------------------------------------------------------------------------
     88 MyClass::MyClass()
     89 {
     90 
     91     // Initialize the NX Open C++ API environment
     92     MyClass::theSession = NXOpen::Session::GetSession();
     93     MyClass::theUI = UI::GetUI();
     94     mb = theUI->NXMessageBox();
     95     lw = theSession->ListingWindow();
     96     lf = theSession->LogFile();
     97 
     98     workPart = theSession->Parts()->Work();
     99     displayPart = theSession->Parts()->Display();
    100     
    101 }
    102 
    103 //------------------------------------------------------------------------------
    104 // Destructor
    105 //------------------------------------------------------------------------------
    106 MyClass::~MyClass()
    107 {
    108 }
    109 
    110 //------------------------------------------------------------------------------
    111 // Print string to listing window or stdout
    112 //------------------------------------------------------------------------------
    113 void MyClass::print(const NXString &msg)
    114 {
    115     if(! lw->IsOpen() ) lw->Open();
    116     lw->WriteLine(msg);
    117 }
    118 void MyClass::print(const string &msg)
    119 {
    120     if(! lw->IsOpen() ) lw->Open();
    121     lw->WriteLine(msg);
    122 }
    123 void MyClass::print(const char * msg)
    124 {
    125     if(! lw->IsOpen() ) lw->Open();
    126     lw->WriteLine(msg);
    127 }
    128 
    129 
    130 
    131 static int select_filter_proc_fn(tag_t object, int type[3], void* user_data, UF_UI_selection_p_t select)
    132 {
    133     if (object == NULL)
    134     {
    135         return UF_UI_SEL_REJECT;
    136     }
    137     else
    138     {
    139         return UF_UI_SEL_ACCEPT;
    140     }
    141 }
    142 
    143 static int init_proc(UF_UI_selection_p_t select, void* user_data)
    144 {
    145     int num_triples = 1;//可选类型的数量
    146     UF_UI_mask_t mask_triples[] =
    147     { UF_component_type, UF_UI_SEL_NOT_A_FEATURE,
    148     };//可选对象类型
    149     UF_UI_set_sel_mask(select, UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC, num_triples, mask_triples);
    150     if ((UF_UI_set_sel_procs(select, select_filter_proc_fn, NULL, user_data)) == 0)
    151     {
    152         return UF_UI_SEL_SUCCESS;
    153     }
    154     else
    155     {
    156         return UF_UI_SEL_FAILURE;
    157     }
    158 }
    159 
    160 string MyClass::NameOrPath(const char* Path, int Type)
    161 {
    162     //反向找位置,分割字符串(只读取文件夹路径)
    163     string strPath = Path;
    164     string strDir;
    165     int nPos = strPath.find_last_of('\');
    166     if (string::npos != nPos)
    167     {
    168         strDir = strPath.substr(0, nPos);
    169     }
    170 
    171     //分割字符串(只读取part名字+后缀)
    172     //方法2
    173     int pos = strPath.find_last_of('\');
    174     string s1(strPath.substr(pos + 1));
    175 
    176     //分割字符串(只读取part名)
    177     string PartName(s1.substr(0, s1.find(".prt")));
    178 
    179     if (Type == 1)
    180     {
    181         return PartName;//返回名字
    182     }
    183     else if (Type == 2)
    184     {
    185         return strDir;//返回文件夹路径
    186     }
    187 }
    188 
    189 //------------------------------------------------------------------------------
    190 // Do something
    191 //------------------------------------------------------------------------------
    192 void MyClass::do_it()
    193 {
    194 
    195     // TODO: add your code here
    196     
    197     UF_initialize();
    198 
    199     //单对象选择对话框
    200     char sCue[] = "单对象选择对话框";
    201     char sTitle[] = "选择一个装配组件";
    202     int iScope = UF_UI_SEL_SCOPE_NO_CHANGE;
    203     int iResponse;
    204     tag_t tView;
    205     double adCursor[3];
    206     tag_t ComponentTag = NULL_TAG;//单选控件获得的tag
    207     UF_UI_select_with_single_dialog(sCue, sTitle, iScope, init_proc, NULL, &iResponse, &ComponentTag, adCursor, &tView);
    208 
    209     //获取装配部件的part名称
    210     char part_name[MAX_FSPEC_BUFSIZE];//当前显示部件.prt文件所在路径
    211     char refset_name[UF_OBJ_NAME_BUFSIZE];
    212     char instance_name[UF_CFI_MAX_FILE_NAME_BUFSIZE];
    213     double origin[3];
    214     double csys_matrix[9];
    215     double transform[4][4];
    216     UF_ASSEM_ask_component_data(ComponentTag, part_name, refset_name, instance_name, origin, csys_matrix, transform);
    217 
    218     //输入字符串控件
    219     char * cue = "输入框";
    220     //转换
    221     char str1[133];
    222     sprintf(str1, "%s", part_name);
    223     //分割字符串(只读取part名)
    224     string PartName1 = NameOrPath(str1, 1);
    225     char str[133];//字符串输入对话框值
    226     sprintf(str, "%s", PartName1.c_str());
    227     int length = 0;
    228     uc1600(cue, str, &length);
    229 
    230     //弹出对话框
    231     char sPromptStr1[] = "单选菜单对话框";
    232     int iDefault1 = 0;
    233     char asOptions1[][38] = { "删除原组件", "保留原组件" };
    234     int iNumOfOptions1 = 2;
    235     DelectValue = uc1603(sPromptStr1, iDefault1, asOptions1, iNumOfOptions1);
    236 
    237     //返回原型标识
    238     tag_t ComponentPart = UF_ASSEM_ask_prototype_of_occ(ComponentTag);
    239 
    240     //设置为工作部件
    241     UF_ASSEM_set_work_part(ComponentPart);
    242 
    243     //获得当前工作部件.prt文件所在路径
    244     char part_fspec1[MAX_FSPEC_BUFSIZE];
    245     UF_PART_ask_part_name(UF_ASSEM_ask_work_part(), part_fspec1);
    246 
    247     //重命名实例名称
    248     UF_PART_rename(ComponentPart, str);
    249 
    250     //获得当前显示部件.prt文件所在路径
    251     char part_fspec[MAX_FSPEC_BUFSIZE];
    252     UF_PART_ask_part_name(UF_PART_ask_display_part(), part_fspec);
    253 
    254     //获取文件夹路径
    255     string strDir = NameOrPath(part_fspec, 2);
    256 
    257     //转换
    258     char msg[256];
    259     sprintf_s(msg, "\%s.prt", str);
    260     string strDir1 = msg;
    261 
    262     //字符串拼接
    263     string strDir2 = strDir + strDir1;
    264 
    265     //另存为改名后的.prt
    266     UF_PART_save_as(strDir2.c_str());
    267 
    268     //把显示部件设置为工作部件
    269     UF_ASSEM_set_work_part(UF_PART_ask_display_part());
    270 
    271     //部件清理,移除高亮
    272     NXOpen::PartCleanup *partCleanup1;
    273     partCleanup1 = theSession->NewPartCleanup();
    274     partCleanup1->SetTurnOffHighlighting(true);
    275     partCleanup1->DoCleanup();
    276 
    277     //删除旧的.prt文件
    278     if (DelectValue == 5)
    279     {
    280         DeleteFile(part_fspec1);
    281     }
    282 
    283     UF_terminate();
    284 }
    285 
    286 //------------------------------------------------------------------------------
    287 // Entry point(s) for unmanaged internal NXOpen C/C++ programs
    288 //------------------------------------------------------------------------------
    289 //  Explicit Execution
    290 extern "C" DllExport void ufusr( char *parm, int *returnCode, int rlen )
    291 {
    292     try
    293     {
    294         // Create NXOpen C++ class instance
    295         MyClass *theMyClass;
    296         theMyClass = new MyClass();
    297         theMyClass->do_it();
    298         delete theMyClass;
    299     }
    300     catch (const NXException& e1)
    301     {
    302         UI::GetUI()->NXMessageBox()->Show("NXException", NXOpen::NXMessageBox::DialogTypeError, e1.Message());
    303     }
    304     catch (const exception& e2)
    305     {
    306         UI::GetUI()->NXMessageBox()->Show("Exception", NXOpen::NXMessageBox::DialogTypeError, e2.what());
    307     }
    308     catch (...)
    309     {
    310         UI::GetUI()->NXMessageBox()->Show("Exception", NXOpen::NXMessageBox::DialogTypeError, "Unknown Exception.");
    311     }
    312 }
    313 
    314 
    315 //------------------------------------------------------------------------------
    316 // Unload Handler
    317 //------------------------------------------------------------------------------
    318 extern "C" DllExport int ufusr_ask_unload()
    319 {
    320     return (int)NXOpen::Session::LibraryUnloadOptionImmediately;
    321 }
    322 
    323 
    324 Caesar卢尚宇
    325 2019年8月13日

    补充2019年11月18日

    今天有网友合工大-wzl给我留言,纠正了一个bug,在这个例子中,这个函数tag_t instanceTAG = UF_ASSEM_ask_instance_of_name(UF_PART_ask_display_part(), part_name);

    里面的这个输入参数,part_name,不应该是part的名字,应该是装配部件的实例名称instance_name。这个地方是我的一个疏忽,因为默认情况下应该part名字和实例名字是一个名字。

    感谢网友纠正的错误。

    查看全文
  • 相关阅读:
    bzoj 1858 线段树
    bzoj 1877 最小费用流
    bzoj 1833 数位dp
    Codeforces Round #285 (Div. 1) B
    HDU2028 Lowest Common Multiple Plus
    HDU5706 GirlCat
    HDU2022 海选女主角
    687E: TOF
    687D: Dividing Kingdom II
    687D: Dividing Kingdom II
  • 原文地址:https://www.cnblogs.com/nxopen2018/p/11342606.html
  • 最新文章
  • tarjan算法(学习笔记)
    乘法逆元(学习笔记)
    欧拉函数 欧拉定理(学习笔记)
    LIS LCS(学习笔记)
    XML和Schema
    Java 包的概述和讲解
    Java 常用对象-Date类和Calender类
    Java 常用对象-BigDecimal
    Java 常用对象-BigInteger类
    Java 常用对象-System类
  • 热门文章
  • Java 常用对象-Math类
    Java 常用对象-StringBuffer类
    Java 常用对象-String类
    Java 常用对象-Scanner类
    bzoj 1816 二分
    bzoj 1856 卡特兰数
    bzoj 1861 treap
    bzoj 1875 矩阵快速幂
    bzoj 1854 并查集 + 贪心
    bzoj 1853 容斥 + 搜索
Copyright © 2011-2022 走看看

4617作文网周公解梦梦见蛇掉身上4周公解梦卖书的店铺起什么名字猪宝宝起名考虑事项梦到鬼周公解梦周易起名大全测分招聘 周易算死命文免费阅读全文周易称骨对照表周公解梦做梦梦到蛇红楼梦第八回赏析解读瑞名轩周易起名馆男孩起名一一的意思姓马起名 女孩子巩性女孩起名怎样算命最准又简单周公解梦算姻缘姓陈女孩取起名寓意好汽车公司起名大全集两字的佳起名字啊生命计算器在线姓段起名字企业免费起名三个字的易烊千玺周冬雨少年的你公司起名吉利笔画北京企业起名字矿泉水起名字大全徐氏女士起名周公解梦大全查询火车闫姓起名字淀粉肠小王子日销售额涨超10倍罗斯否认插足凯特王妃婚姻让美丽中国“从细节出发”清明节放假3天调休1天男子给前妻转账 现任妻子起诉要回网友建议重庆地铁不准乘客携带菜筐月嫂回应掌掴婴儿是在赶虫子重庆警方辟谣“男子杀人焚尸”国产伟哥去年销售近13亿新的一天从800个哈欠开始男孩疑遭霸凌 家长讨说法被踢出群高中生被打伤下体休学 邯郸通报男子持台球杆殴打2名女店员被抓19岁小伙救下5人后溺亡 多方发声单亲妈妈陷入热恋 14岁儿子报警两大学生合买彩票中奖一人不认账德国打算提及普京时仅用姓名山西省委原副书记商黎光被逮捕武汉大学樱花即将进入盛花期今日春分张家界的山上“长”满了韩国人?特朗普谈“凯特王妃P图照”王树国3次鞠躬告别西交大师生白宫:哈马斯三号人物被杀代拍被何赛飞拿着魔杖追着打315晚会后胖东来又人满为患了房客欠租失踪 房东直发愁倪萍分享减重40斤方法“重生之我在北大当嫡校长”槽头肉企业被曝光前生意红火手机成瘾是影响睡眠质量重要因素考生莫言也上北大硕士复试名单了妈妈回应孩子在校撞护栏坠楼网友洛杉矶偶遇贾玲呼北高速交通事故已致14人死亡西双版纳热带植物园回应蜉蝣大爆发男孩8年未见母亲被告知被遗忘张立群任西安交通大学校长恒大被罚41.75亿到底怎么缴沈阳一轿车冲入人行道致3死2伤奥运男篮美国塞尔维亚同组周杰伦一审败诉网易国标起草人:淀粉肠是低配版火腿肠外国人感慨凌晨的中国很安全男子被流浪猫绊倒 投喂者赔24万杨倩无缘巴黎奥运男子被猫抓伤后确诊“猫抓病”春分“立蛋”成功率更高?记者:伊万改变了国足氛围奥巴马现身唐宁街 黑色着装引猜测

4617作文网 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化