其他分享
首页 > 其他分享> > NX二次开发-NXOPEN将工程图转成PDF文件

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();

标签:UF,printPDFBuilder1,PrintPDFBuilder,NX,工程图,tag,二次开发,include,drawing
来源: https://www.cnblogs.com/nxopen2018/p/10957494.html