NX二次开发-NXOPEN将工程图转成PDF文件

Posted nxopen2018

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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();

技术图片

以上是关于NX二次开发-NXOPEN将工程图转成PDF文件的主要内容,如果未能解决你的问题,请参考以下文章

NX二次开发-NXOPEN自动切换到工程图模块

NX二次开发-NXOPEN工程图导出CAD图纸DxfdwgCreator *dxfdwgCreator1;

NX二次开发-NXOPEN获取所有工程图和所有视图DrawingSheet,DrawingSheetCollection,DraftingView

NX二次开发-NXOPEN创建工程图表格Annotations::TableSectionBuilder *tableSectionBuilder1;

NX二次开发-NXopen录制:导入IGS

NX二次开发-UFUN工程图表格注释写入文本内容UF_TABNOT_set_cell_text