zoukankan      html  css  js  c++  java
  • NX二次开发-NXOPEN将工程图转成PDF文件

     1 NX9+VS2012
     2 
     3 #include <uf.h>
     4 #include <uf_draw.h>
     5 #include <NXOpen/PrintPDFBuilder.hxx>
     6 #include <NXOpen/Drawings_DrawingSheet.hxx>
     7 #include <NXOpen/NXObjectManager.hxx>
     8 #include <NXOpen/PlotManager.hxx>
     9 #include <NXOpen/Part.hxx>
    10 #include <NXOpen/PartCollection.hxx>
    11 #include <NXOpen/Session.hxx>
    12 
    13 
    14 Session *theSession = Session::GetSession();
    15 Part *workPart(theSession->Parts()->Work());
    16 Part *displayPart(theSession->Parts()->Display());
    17 
    18 UF_initialize();
    19 
    20 tag_t drawing_tag = NULL_TAG;
    21 UF_DRAW_ask_current_drawing(&drawing_tag);
    22 
    23 if (drawing_tag != NULL_TAG)
    24 {
    25     PrintPDFBuilder *printPDFBuilder1;
    26     printPDFBuilder1 = workPart->PlotManager()->CreatePrintPdfbuilder();
    27 
    28     printPDFBuilder1->SetColors(PrintPDFBuilder::ColorAsDisplayed);
    29     printPDFBuilder1->SetWidths(PrintPDFBuilder::WidthStandardWidths);
    30     printPDFBuilder1->SetSize(PrintPDFBuilder::SizeOptionScaleFactor);
    31     printPDFBuilder1->SetScale(1.0);
    32     printPDFBuilder1->SetOutputText(PrintPDFBuilder::OutputTextOptionPolylines);
    33     printPDFBuilder1->SetUnits(PrintPDFBuilder::UnitsOptionMetric);
    34 
    35     std::vector<NXObject *> sheets1(1);
    36     Drawings::DrawingSheet *drawingSheet1(dynamic_cast<Drawings::DrawingSheet *>(NXOpen::NXObjectManager::Get(drawing_tag)));
    37     sheets1[0] = drawingSheet1;
    38     printPDFBuilder1->SourceBuilder()->SetSheets(sheets1);
    39     printPDFBuilder1->SetFilename("D:\11111.pdf");
    40 
    41     NXObject *nXObject1;
    42     nXObject1 = printPDFBuilder1->Commit();
    43     printPDFBuilder1->Destroy();
    44 }
    45 
    46 UF_terminate();

  • 相关阅读:
    Python基础-数据写入execl
    Python基础-读取excel
    table合并单元格colspan和rowspan
    从PHP客户端看MongoDB通信协议(转)
    win7环境下mongodb分片和移除
    32位下操作mongodb心得
    Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1099 bytes) in
    js关闭当前页面(窗口)的几种方式
    js页面跳转 和 js打开新窗口 方法
    MongoDB中的_id和ObjectId
  • 原文地址:https://www.cnblogs.com/nxopen2018/p/10957494.html
Copyright © 2011-2022 走看看