本文主要是介绍NXopen 批量输出装配体零件几何模型的STEP和IGS格式文件,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
通过对话框指定文件夹,输出该文件夹下PARt文件为STEP和IGS格式文件
//头文件#include <uf_modl_primitives.h>#include <NXOpen/Session.hxx>#include <NXOpen/PartCollection.hxx>#include <NXOpen/ListingWindow.hxx>#include <uf_ui.h>#include <NXOpen/Assemblies_ComponentAssembly.hxx>#include <io.h> #include <fstream>#include <string>#include <string>#include <vector>#include <iostream>#include <stdio.h>//主程序NXOpen::Session* theSession = NXOpen::Session::GetSession();NXOpen::Part* workPart(theSession->Parts()->Work());NXOpen::Part* displayPart(theSession->Parts()->Display());NXOpen::NXString NXpathi = nativeFolderBrowser0->Path();const char* pathi = NXpathi.GetLocaleText();const char* szTemp1 = pathi;const char* szTemp2 = "*.prt";const char* path = NULL;string temp = string(szTemp1) + string(szTemp2);path = temp.c_str();//result即为合并后的结果_finddata64i32_t fileInfo;intptr_t hFile = _findfirst(path, &fileInfo);vector<string> files;if (hFile == -1) {files.clear();return -1;}do{files.push_back(fileInfo.name);} while (_findnext(hFile, &fileInfo) == 0);vector<string> partfiles;for (int i = 0; i < files.size(); i++){string PartName = (string)files[i];PartName = szTemp1 + PartName;partfiles.push_back(PartName);}NXOpen::NXString Spath = nativeFolderBrowser01->Path();const char* Spathchar = Spath.GetLocaleText();theSession->ListingWindow()->WriteLine(Spathchar);for (int i = 0; i < partfiles.size(); i++){NXOpen::BasePart* basePart1;NXOpen::PartLoadStatus* partLoadStatus1;basePart1 = theSession->Parts()->OpenActiveDisplay(partfiles[i], NXOpen::DisplayPartOptionAllowAdditional, &partLoadStatus1);NXOpen::Part* part2 = theSession->Parts()->Work();delete partLoadStatus1;theSession->ApplicationSwitchImmediate("UG_APP_MODELING");Assemblies::ComponentAssembly* compAssy = part2->ComponentAssembly();Assemblies::Component* rootcomponent = compAssy->RootComponent();if (rootcomponent == NULL){NXOpen::NXString NXString2 = part2->JournalIdentifier();const char* Spathi = NXString2.GetLocaleText();if (toggle0->Value() == 1){const char* pathstep = ".stp";const char* path22 = NULL;string temp11 = string(Spathchar) + string(Spathi) + string(pathstep);path22 = temp11.c_str();//result即为合并后的结果theSession->ListingWindow()->WriteLine(path22);NXOpen::PartSaveStatus* partSaveStatus1;partSaveStatus1 = part2->SaveAs(NXOpen::NXString(path22, NXOpen::NXString::UTF8));delete partSaveStatus1;}if (toggle01->Value() == 1){const char* pathigs = ".igs";const char* path44 = NULL;string temp44 = string(Spathchar) + string(Spathi) + string(pathigs);path44 = temp44.c_str();theSession->ListingWindow()->WriteLine(path44);NXOpen::PartSaveStatus* partSaveStatus2;partSaveStatus2 = part2->SaveAs(path44);delete partSaveStatus2;}}else{}}
这篇关于NXopen 批量输出装配体零件几何模型的STEP和IGS格式文件的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!