NXOpen 批量导出STP、IGS、DWG、DXF、PDF(五合一)

时间:2024-03-03 22:26:02

C++

关键代码

//导出STP
void ExportFile::ExportSTPfile()
{
    try
    {
  UF_initialize();

   string  filepath = strDir +  "\\" ;//拼接路径
   //获取图层过滤
   PropertyList *stringLayerProps = stringLayer->GetProperties();
   NXString filelayer = stringLayerProps->GetString("Value");
   delete stringLayerProps;
   stringLayerProps = NULL; 

   //获取NX路径
   char *translationNX;
   UF_translate_variable("UGII_BASE_DIR", &translationNX);
   string fileDIR1 = translationNX;
   string fileDIR2 = "\\step214ug\\ugstep214.def";
   string step214ugfilePath = fileDIR1+fileDIR2;
   //theSession->ListingWindow()->WriteLine(step214ugfilePath);

   for ( int i = 0 ; i < listboxselectStrings.size(); i ++ )
   {
    string ExportPatFilePath = filepath + listboxselectStrings[i].GetLocaleText() + ".prt";
    string ExportStpFilePath = filepath + listboxselectStrings[i].GetLocaleText() + ".stp";
    //theSession->ListingWindow()->WriteLine(ExportPatFilePath);
    //theSession->ListingWindow()->WriteLine(ExportStpFilePath);

   //指定本地数据文件
   int STPPathStatus=0;
   //测试文件或目录是否存在
   UF_CFI_ask_file_exist (ExportStpFilePath.c_str(),&STPPathStatus);
   //如果文件已存在,先删除掉
   if ( STPPathStatus == 0 ) // 0表示文件存在 1表示文件不存在
   {
    DeleteFile(ExportStpFilePath.c_str()); 
   }

    //导出STP
   Step214Creator *step214Creator1;
   step214Creator1 = theSession->DexManager()->CreateStep214Creator();
 
   //设置要被导出的PRT
   step214Creator1->SetInputFile(ExportPatFilePath);
 
   //设置导出的位置和文件名
   step214Creator1->SetOutputFile(ExportStpFilePath);
 
   step214Creator1->ObjectTypes()->SetCurves(true);
   step214Creator1->ObjectTypes()->SetSurfaces(true);
   step214Creator1->ObjectTypes()->SetSolids(true);
   step214Creator1->ObjectTypes()->SetCsys(true);
   step214Creator1->ObjectTypes()->SetProductData(true);
   step214Creator1->SetValidationProperties(true);
 
 
   step214Creator1->SetExportExtRef(true);
   step214Creator1->SetSettingsFile(step214ugfilePath);
   step214Creator1->ObjectTypes()->SetProductData(false);
   step214Creator1->SetExportExtRef(false);
 
   step214Creator1->SetValidationProperties(false);
   step214Creator1->SetFileSaveFlag(false);
   step214Creator1->SetLayerMask(filelayer);//图层过滤
   NXObject *nXObject1;
   nXObject1 = step214Creator1->Commit();
   step214Creator1->Destroy();  
  
   }

   UF_terminate();

 

    }
    catch(exception& ex)
    {
        //---- Enter your exception handling code here -----
        ExportFile::theUI->NXMessageBox()->Show("导出STP", NXOpen::NXMessageBox::DialogTypeError, ex.what());
    }
}
//导出IGS
void ExportFile::ExportIGSfile()
{
    try
    {
  UF_initialize();

   string  filepath = strDir +  "\\" ;//拼接路径
   //获取图层过滤
   PropertyList *stringLayerProps = stringLayer->GetProperties();
   NXString filelayer = stringLayerProps->GetString("Value");
   delete stringLayerProps;
   stringLayerProps = NULL; 

   //获取NX路径
   char *translationNX;
   UF_translate_variable("UGII_BASE_DIR", &translationNX);
   string fileDIR1 = translationNX;
   string fileDIR2 = "\\iges\\igesexport.def";
   string stepigsfilePath = fileDIR1+fileDIR2;
   //theSession->ListingWindow()->WriteLine(step214ugfilePath);

   for ( int i = 0 ; i < listboxselectStrings.size(); i ++ )
   {
    string ExportPatFilePath = filepath + listboxselectStrings[i].GetLocaleText() + ".prt";
    string ExportIgsFilePath = filepath + listboxselectStrings[i].GetLocaleText() + ".igs";
    //theSession->ListingWindow()->WriteLine(ExportPatFilePath);
    //theSession->ListingWindow()->WriteLine(ExportStpFilePath);

   //指定本地数据文件
   int STPPathStatus=0;
   //测试文件或目录是否存在
   UF_CFI_ask_file_exist (ExportIgsFilePath.c_str(),&STPPathStatus);
   //如果文件已存在,先删除掉
   if ( STPPathStatus == 0 ) // 0表示文件存在 1表示文件不存在
   {
    DeleteFile(ExportIgsFilePath.c_str()); 
   }

    //导出IGS
   IgesCreator *igesCreator1;
   igesCreator1 = theSession->DexManager()->CreateIgesCreator();
   igesCreator1->SetExportModelData(true);
   igesCreator1->SetExportDrawings(true);
   igesCreator1->SetMapTabCylToBSurf(true);
   igesCreator1->SetBcurveTol(0.0508);
   igesCreator1->SetIdenticalPointResolution(0.001);
   igesCreator1->SetMaxThreeDMdlSpace(10000.0);
   igesCreator1->ObjectTypes()->SetCurves(true);
   igesCreator1->ObjectTypes()->SetSurfaces(true);
   igesCreator1->ObjectTypes()->SetAnnotations(true);
   igesCreator1->ObjectTypes()->SetStructures(true);
   igesCreator1->ObjectTypes()->SetSolids(true);
   igesCreator1->SetSettingsFile(stepigsfilePath);//日记文件
   igesCreator1->SetMaxLineThickness(2.0);
   igesCreator1->SetSysDefmaxThreeDMdlSpace(true);
   igesCreator1->SetSysDefidenticalPointResolution(true);
   igesCreator1->SetInputFile(ExportPatFilePath);//需导出的源文件
   igesCreator1->SetOutputFile(ExportIgsFilePath);//导出的IGS
   igesCreator1->SetFileSaveFlag(false);
   igesCreator1->SetLayerMask(filelayer);//图层过滤
   igesCreator1->SetDrawingList("");
   igesCreator1->SetViewList("Top,Front,Right,Back,Bottom,Left,Isometric,Trimetric,User Defined");
   NXObject *nXObject1;
   nXObject1 = igesCreator1->Commit();
   igesCreator1->Destroy();
  
   }

   UF_terminate();
    }
    catch(exception& ex)
    {
        //---- Enter your exception handling code here -----
        ExportFile::theUI->NXMessageBox()->Show("导出IGS", NXOpen::NXMessageBox::DialogTypeError, ex.what());
    }
}
//导出DWG
void ExportFile::ExportDWGfile()
{
    try
    {
   UF_initialize();
  
    string  filepath = strDir +  "\\" ;//拼接路径
   Part *workPart(theSession->Parts()->Work());
   Part *displayPart(theSession->Parts()->Display());

   //获取图层过滤
   PropertyList *stringLayerProps = stringLayer->GetProperties();
   NXString filelayer = stringLayerProps->GetString("Value");
   delete stringLayerProps;
   stringLayerProps = NULL; 

   //获取NX路径
   char *translationNX;
   UF_translate_variable("UGII_BASE_DIR", &translationNX);
   string fileDIR1 = translationNX;
   string fileDIR2 = "\\dxfdwg\\dxfdwg.def";
   string step214ugfilePath = fileDIR1+fileDIR2;
   //theSession->ListingWindow()->WriteLine(step214ugfilePath);

   for ( int i = 0 ; i < listboxselectStrings.size(); i ++ )
   {
    string ExportPatFilePath = filepath + listboxselectStrings[i].GetLocaleText() + ".prt";

    //打开文件(没打开直接打开,已打开重新打开)
    BasePart *basePart1;
    PartLoadStatus *partLoadStatus1;
    try
    {
     // 文件已存在
     basePart1 = theSession->Parts()->OpenBaseDisplay(ExportPatFilePath, &partLoadStatus1);
    }
    catch (const NXException &ex)
    {
     ex.AssertErrorCode(1020004);
    }

    Part *part1(dynamic_cast<Part *>(theSession->Parts()->FindObject(listboxselectStrings[i].GetLocaleText())));
    BasePart *basePart2;
    PartReopenReport *partReopenReport1;
    basePart2 = part1->Reopen(BasePart::CloseWholeTreeFalse, BasePart::CloseModifiedCloseModified, NULL, &partReopenReport1);

    delete partReopenReport1;
    Session::UndoMarkId markId1;
    markId1 = theSession->SetUndoMark(Session::MarkVisibilityVisible, "Change Display Part");

    Part *part2(dynamic_cast<Part *>(basePart2));
    PartLoadStatus *partLoadStatus2;
    PartCollection::SdpsStatus status1;
    status1 = theSession->Parts()->SetDisplay(part2, true, true, &partLoadStatus2);

    workPart = theSession->Parts()->Work();
    displayPart = theSession->Parts()->Display();
    delete partLoadStatus2;
 
   //得到所有图纸页
   vector<NXOpen::Drawings::DrawingSheet*> AllSheetsVector;//存到vector
   NXOpen::Drawings::DrawingSheet* AllSheets;//定义类型
   NXOpen::Drawings::DrawingSheetCollection::iterator Ite = workPart->DrawingSheets()->begin();
   for (; Ite != workPart->DrawingSheets()->end(); ++Ite)//迭代器遍历
   {
    AllSheets = (*Ite);
    AllSheetsVector.push_back(AllSheets);
   }

   for ( int j = 0 ; j < AllSheetsVector.size() ; j ++ )
   {
    //打开图纸页
    AllSheetsVector[j]->Open();

    NXString SheetsName = AllSheetsVector[j]->Name();
    //转到2D
    Drawings::DrawingSheet *drawingSheet1(dynamic_cast<Drawings::DrawingSheet *>(workPart->DrawingSheets()->FindObject(SheetsName)));
    drawingSheet1->Open();
   
    Session::UndoMarkId markId1;
    markId1 = theSession->SetUndoMark(Session::MarkVisibilityVisible, "Enter Drafting");
   
    workPart->Views()->WorkView()->UpdateCustomSymbols();
   
    workPart->Drafting()->SetTemplateInstantiationIsComplete(true);

    //得到当前图纸页
    NXOpen::Drawings::DrawingSheet* MySheet = workPart->DrawingSheets()->CurrentDrawingSheet();

    //得到图纸页中的所有视图
    vector<NXOpen::Drawings::DraftingView*> MySheetViews = MySheet->GetDraftingViews();

    //将工程图页中的所有视图进行更新
    workPart->DraftingViews()->UpdateViews(DraftingViewCollection::ViewUpdateOptionAll, MySheet);
    
    string ExportdwgFilePath = filepath + listboxselectStrings[i].GetLocaleText() +"_" + SheetsName.GetLocaleText() + ".dwg";
    //theSession->ListingWindow()->WriteLine(ExportPDFFilePath);

    //指定本地数据文件
    int STPPathStatus=0;
    //测试文件或目录是否存在
    UF_CFI_ask_file_exist (ExportdwgFilePath.c_str(),&STPPathStatus);
    //如果文件已存在,先删除掉
    if ( STPPathStatus == 0 ) // 0表示文件存在 1表示文件不存在
    {
     DeleteFile(ExportdwgFilePath.c_str()); 
    }

    //导出DWG
    DxfdwgCreator *dxfdwgCreator1;
    dxfdwgCreator1 = theSession->DexManager()->CreateDxfdwgCreator();
    dxfdwgCreator1->SetExportData(DxfdwgCreator::ExportDataOptionDrawing);
    dxfdwgCreator1->SetAutoCADRevision(DxfdwgCreator::AutoCADRevisionOptionsR2004);
    dxfdwgCreator1->SetViewEditMode(true);
    dxfdwgCreator1->SetFlattenAssembly(true);
    //dxfdwgCreator1->SetExportScaleValue("1:1");
    //dxfdwgCreator1->SetOutputFileType(DxfdwgCreator::OutputFileTypeOptionDxf);//导出DXF
    dxfdwgCreator1->SetOutputFileType(DxfdwgCreator::OutputFileTypeOptionDwg);//导出DWG
    dxfdwgCreator1->SetInputFile(ExportPatFilePath);//需导出的源文件
    dxfdwgCreator1->SetOutputFile(ExportdwgFilePath);//导出的文件
    dxfdwgCreator1->SetSettingsFile(step214ugfilePath);//记录文件
    dxfdwgCreator1->ObjectTypes()->SetCurves(true);
    dxfdwgCreator1->SetAutoCADRevision(DxfdwgCreator::AutoCADRevisionOptionsR2004);//导出对应的CAD版本
    dxfdwgCreator1->ObjectTypes()->SetAnnotations(true);
    dxfdwgCreator1->ObjectTypes()->SetStructures(true);
    dxfdwgCreator1->SetLayerMask(filelayer);//图层

    NXObject *nXObject1;
    nXObject1 = dxfdwgCreator1->Commit();

    dxfdwgCreator1->Destroy();
    
  
   }
 
   }


   UF_terminate();
    }
    catch(exception& ex)
    {
        //---- Enter your exception handling code here -----
        ExportFile::theUI->NXMessageBox()->Show("导出DWG", NXOpen::NXMessageBox::DialogTypeError, ex.what());
    }
}
//导出DXF
void ExportFile::ExportDXFfile()
{
    try
    {
   UF_initialize();
  
    string  filepath = strDir +  "\\" ;//拼接路径
   Part *workPart(theSession->Parts()->Work());
   Part *displayPart(theSession->Parts()->Display());

   //获取图层过滤
   PropertyList *stringLayerProps = stringLayer->GetProperties();
   NXString filelayer = stringLayerProps->GetString("Value");
   delete stringLayerProps;
   stringLayerProps = NULL; 

   //获取NX路径
   char *translationNX;
   UF_translate_variable("UGII_BASE_DIR", &translationNX);
   string fileDIR1 = translationNX;
   string fileDIR2 = "\\dxfdwg\\dxfdwg.def";
   string step214ugfilePath = fileDIR1+fileDIR2;
   //theSession->ListingWindow()->WriteLine(step214ugfilePath);

   for ( int i = 0 ; i < listboxselectStrings.size(); i ++ )
   {
    string ExportPatFilePath = filepath + listboxselectStrings[i].GetLocaleText() + ".prt";

    //打开文件(没打开直接打开,已打开重新打开)
    BasePart *basePart1;
    PartLoadStatus *partLoadStatus1;
    try
    {
     // 文件已存在
     basePart1 = theSession->Parts()->OpenBaseDisplay(ExportPatFilePath, &partLoadStatus1);
    }
    catch (const NXException &ex)
    {
     ex.AssertErrorCode(1020004);
    }

    Part *part1(dynamic_cast<Part *>(theSession->Parts()->FindObject(listboxselectStrings[i].GetLocaleText())));
    BasePart *basePart2;
    PartReopenReport *partReopenReport1;
    basePart2 = part1->Reopen(BasePart::CloseWholeTreeFalse, BasePart::CloseModifiedCloseModified, NULL, &partReopenReport1);

    delete partReopenReport1;
    Session::UndoMarkId markId1;
    markId1 = theSession->SetUndoMark(Session::MarkVisibilityVisible, "Change Display Part");

    Part *part2(dynamic_cast<Part *>(basePart2));
    PartLoadStatus *partLoadStatus2;
    PartCollection::SdpsStatus status1;
    status1 = theSession->Parts()->SetDisplay(part2, true, true, &partLoadStatus2);

    workPart = theSession->Parts()->Work();
    displayPart = theSession->Parts()->Display();
    delete partLoadStatus2;
 
   //得到所有图纸页
   vector<NXOpen::Drawings::DrawingSheet*> AllSheetsVector;//存到vector
   NXOpen::Drawings::DrawingSheet* AllSheets;//定义类型
   NXOpen::Drawings::DrawingSheetCollection::iterator Ite = workPart->DrawingSheets()->begin();
   for (; Ite != workPart->DrawingSheets()->end(); ++Ite)//迭代器遍历
   {
    AllSheets = (*Ite);
    AllSheetsVector.push_back(AllSheets);
   }

   for ( int j = 0 ; j < AllSheetsVector.size() ; j ++ )
   {
    //打开图纸页
    AllSheetsVector[j]->Open();

    NXString SheetsName = AllSheetsVector[j]->Name();
    //转到2D
    Drawings::DrawingSheet *drawingSheet1(dynamic_cast<Drawings::DrawingSheet *>(workPart->DrawingSheets()->FindObject(SheetsName)));
    drawingSheet1->Open();
   
    Session::UndoMarkId markId1;
    markId1 = theSession->SetUndoMark(Session::MarkVisibilityVisible, "Enter Drafting");
   
    workPart->Views()->WorkView()->UpdateCustomSymbols();
   
    workPart->Drafting()->SetTemplateInstantiationIsComplete(true);

    //得到当前图纸页
    NXOpen::Drawings::DrawingSheet* MySheet = workPart->DrawingSheets()->CurrentDrawingSheet();

    //得到图纸页中的所有视图
    vector<NXOpen::Drawings::DraftingView*> MySheetViews = MySheet->GetDraftingViews();

    //将工程图页中的所有视图进行更新
    workPart->DraftingViews()->UpdateViews(DraftingViewCollection::ViewUpdateOptionAll, MySheet);
    
    string ExportdxfFilePath = filepath + listboxselectStrings[i].GetLocaleText() +"_" + SheetsName.GetLocaleText() + ".dxf";
    //theSession->ListingWindow()->WriteLine(ExportPDFFilePath);

    //指定本地数据文件
    int STPPathStatus=0;
    //测试文件或目录是否存在
    UF_CFI_ask_file_exist (ExportdxfFilePath.c_str(),&STPPathStatus);
    //如果文件已存在,先删除掉
    if ( STPPathStatus == 0 ) // 0表示文件存在 1表示文件不存在
    {
     DeleteFile(ExportdxfFilePath.c_str()); 
    }

    //导出DWG
    DxfdwgCreator *dxfdwgCreator1;
    dxfdwgCreator1 = theSession->DexManager()->CreateDxfdwgCreator();
    dxfdwgCreator1->SetExportData(DxfdwgCreator::ExportDataOptionDrawing);
    dxfdwgCreator1->SetAutoCADRevision(DxfdwgCreator::AutoCADRevisionOptionsR2004);
    dxfdwgCreator1->SetViewEditMode(true);
    dxfdwgCreator1->SetFlattenAssembly(true);
    //dxfdwgCreator1->SetExportScaleValue("1:1");
    dxfdwgCreator1->SetOutputFileType(DxfdwgCreator::OutputFileTypeOptionDxf);//导出DXF
    //dxfdwgCreator1->SetOutputFileType(DxfdwgCreator::OutputFileTypeOptionDwg);//导出DWG
    dxfdwgCreator1->SetInputFile(ExportPatFilePath);//需导出的源文件
    dxfdwgCreator1->SetOutputFile(ExportdxfFilePath);//导出的文件
    dxfdwgCreator1->SetSettingsFile(step214ugfilePath);//记录文件
    dxfdwgCreator1->ObjectTypes()->SetCurves(true);
    dxfdwgCreator1->SetAutoCADRevision(DxfdwgCreator::AutoCADRevisionOptionsR2004);//导出对应的CAD版本
    dxfdwgCreator1->ObjectTypes()->SetAnnotations(true);
    dxfdwgCreator1->ObjectTypes()->SetStructures(true);
    dxfdwgCreator1->SetLayerMask(filelayer);//图层

    NXObject *nXObject1;
    nXObject1 = dxfdwgCreator1->Commit();

    dxfdwgCreator1->Destroy();
    
  
   }
 
   }


   UF_terminate();

    }
    catch(exception& ex)
    {
        //---- Enter your exception handling code here -----
        ExportFile::theUI->NXMessageBox()->Show("导出DXF", NXOpen::NXMessageBox::DialogTypeError, ex.what());
    }
}
//导出PDF
void ExportFile::ExportPDFfile()
{
    try
    {
   UF_initialize();
  
    string  filepath = strDir +  "\\" ;//拼接路径
   Part *workPart(theSession->Parts()->Work());
   Part *displayPart(theSession->Parts()->Display());

   for ( int i = 0 ; i < listboxselectStrings.size(); i ++ )
   {
    string ExportPatFilePath = filepath + listboxselectStrings[i].GetLocaleText() + ".prt";
    //string ExportPDFFilePath = filepath + listboxselectStrings[i].GetLocaleText() + ".pdf";
    //theSession->ListingWindow()->WriteLine(ExportPatFilePath);
    //theSession->ListingWindow()->WriteLine(Exportx_tFilePath);

    //打开文件(没打开直接打开,已打开重新打开)
    BasePart *basePart1;
    PartLoadStatus *partLoadStatus1;
    try
    {
     // 文件已存在
     basePart1 = theSession->Parts()->OpenBaseDisplay(ExportPatFilePath, &partLoadStatus1);
    }
    catch (const NXException &ex)
    {
     ex.AssertErrorCode(1020004);
    }

    Part *part1(dynamic_cast<Part *>(theSession->Parts()->FindObject(listboxselectStrings[i].GetLocaleText())));
    BasePart *basePart2;
    PartReopenReport *partReopenReport1;
    basePart2 = part1->Reopen(BasePart::CloseWholeTreeFalse, BasePart::CloseModifiedCloseModified, NULL, &partReopenReport1);

    delete partReopenReport1;
    Session::UndoMarkId markId1;
    markId1 = theSession->SetUndoMark(Session::MarkVisibilityVisible, "Change Display Part");

    Part *part2(dynamic_cast<Part *>(basePart2));
    PartLoadStatus *partLoadStatus2;
    PartCollection::SdpsStatus status1;
    status1 = theSession->Parts()->SetDisplay(part2, true, true, &partLoadStatus2);

    workPart = theSession->Parts()->Work();
    displayPart = theSession->Parts()->Display();
    delete partLoadStatus2;
 
   //得到所有图纸页
   vector<NXOpen::Drawings::DrawingSheet*> AllSheetsVector;//存到vector
   NXOpen::Drawings::DrawingSheet* AllSheets;//定义类型
   NXOpen::Drawings::DrawingSheetCollection::iterator Ite = workPart->DrawingSheets()->begin();
   for (; Ite != workPart->DrawingSheets()->end(); ++Ite)//迭代器遍历
   {
    AllSheets = (*Ite);
    AllSheetsVector.push_back(AllSheets);
   }

   for ( int j = 0 ; j < AllSheetsVector.size() ; j ++ )
   {
    //打开图纸页
    AllSheetsVector[j]->Open();

    NXString SheetsName = AllSheetsVector[j]->Name();
    //转到2D
    Drawings::DrawingSheet *drawingSheet1(dynamic_cast<Drawings::DrawingSheet *>(workPart->DrawingSheets()->FindObject(SheetsName)));
    drawingSheet1->Open();
   
    Session::UndoMarkId markId1;
    markId1 = theSession->SetUndoMark(Session::MarkVisibilityVisible, "Enter Drafting");
   
    workPart->Views()->WorkView()->UpdateCustomSymbols();
   
    workPart->Drafting()->SetTemplateInstantiationIsComplete(true);

    //得到当前图纸页
    NXOpen::Drawings::DrawingSheet* MySheet = workPart->DrawingSheets()->CurrentDrawingSheet();

    //得到图纸页中的所有视图
    vector<NXOpen::Drawings::DraftingView*> MySheetViews = MySheet->GetDraftingViews();

    //将工程图页中的所有视图进行更新
    workPart->DraftingViews()->UpdateViews(DraftingViewCollection::ViewUpdateOptionAll, MySheet);
    
    string ExportPDFFilePath = filepath + listboxselectStrings[i].GetLocaleText() +"_" + SheetsName.GetLocaleText() + ".pdf";
    //theSession->ListingWindow()->WriteLine(ExportPDFFilePath);

    //指定本地数据文件
    int STPPathStatus=0;
    //测试文件或目录是否存在
    UF_CFI_ask_file_exist (ExportPDFFilePath.c_str(),&STPPathStatus);
    //如果文件已存在,先删除掉
    if ( STPPathStatus == 0 ) // 0表示文件存在 1表示文件不存在
    {
     DeleteFile(ExportPDFFilePath.c_str()); 
    }

    //导出PDF
     tag_t drawing_tag = NULL_TAG;
     UF_DRAW_ask_current_drawing(&drawing_tag);
 
     if (drawing_tag != NULL_TAG)
     {
      PrintPDFBuilder *printPDFBuilder1;
      printPDFBuilder1 = workPart->PlotManager()->CreatePrintPdfbuilder();
 
      printPDFBuilder1->SetColors(PrintPDFBuilder::ColorBlackOnWhite); //ColorAsDisplayed 显示色
      printPDFBuilder1->SetWidths(PrintPDFBuilder::WidthStandardWidths);
      printPDFBuilder1->SetSize(PrintPDFBuilder::SizeOptionScaleFactor);
      printPDFBuilder1->SetScale(1.0);
      printPDFBuilder1->SetOutputText(PrintPDFBuilder::OutputTextOptionPolylines);
      printPDFBuilder1->SetUnits(PrintPDFBuilder::UnitsOptionMetric);
 
      std::vector<NXObject *> sheets1(1);
      Drawings::DrawingSheet *drawingSheet2(dynamic_cast<Drawings::DrawingSheet *>(NXOpen::NXObjectManager::Get(drawing_tag)));
      sheets1[0] = drawingSheet2;
      printPDFBuilder1->SourceBuilder()->SetSheets(sheets1);
      printPDFBuilder1->SetFilename(ExportPDFFilePath);

      NXObject *nXObject1;
      nXObject1 = printPDFBuilder1->Commit();
      printPDFBuilder1->Destroy();
     }
  
   }
 
   }


   UF_terminate();

    }
    catch(exception& ex)
    {
        //---- Enter your exception handling code here -----
        ExportFile::theUI->NXMessageBox()->Show("导出PDF", NXOpen::NXMessageBox::DialogTypeError, ex.what());
    }
}