NX9+VS2012

 #include <uf.h>
#include <uf_draw.h>
#include <NXOpen/PrintPDFBuilder.hxx>
#include <NXOpen/Drawings_DrawingSheet.hxx>
#include <NXOpen/NXObjectManager.hxx>
#include <NXOpen/PlotManager.hxx>
#include <NXOpen/Part.hxx>
#include <NXOpen/PartCollection.hxx>
#include <NXOpen/Session.hxx> Session *theSession = Session::GetSession();
Part *workPart(theSession->Parts()->Work());
Part *displayPart(theSession->Parts()->Display()); UF_initialize(); 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::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();
Drawings::DrawingSheet *drawingSheet1(dynamic_cast<Drawings::DrawingSheet *>(NXOpen::NXObjectManager::Get(drawing_tag)));
sheets1[] = drawingSheet1;
printPDFBuilder1->SourceBuilder()->SetSheets(sheets1);
printPDFBuilder1->SetFilename("D:\\11111.pdf"); NXObject *nXObject1;
nXObject1 = printPDFBuilder1->Commit();
printPDFBuilder1->Destroy();
} UF_terminate();

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

05-28 10:36