VS2010 NX8.5
//遍历所有图纸页
vector<NXOpen::Drawings::DrawingSheet*> AllSheet;
NXOpen::Drawings::DrawingSheet* Sheet1;
NXOpen::Drawings::DrawingSheetCollection::iterator Ite;//定义迭代器
for (Ite = workPart->DrawingSheets()->begin(); Ite != workPart->DrawingSheets()->end(); ++Ite)
{
Sheet1 = (*Ite);
AllSheet.push_back(Sheet1);
}
if ( AllSheet.size()==0)
{
theUI->NXMessageBox()->Show("提示", NXOpen::NXMessageBox::DialogTypeInformation, "当前不部件不是工程图环境");
return ;
}
Drawings::DrawingSheet *nullDrawings_DrawingSheet(NULL);
Drawings::DrawingSheetBuilder *drawingSheetBuilder1;
drawingSheetBuilder1 = workPart->DrawingSheets()->DrawingSheetBuilder(nullDrawings_DrawingSheet);
drawingSheetBuilder1->SetStandardMetricScale(Drawings::DrawingSheetBuilder::SheetStandardMetricScaleS11);
drawingSheetBuilder1->SetStandardEnglishScale(Drawings::DrawingSheetBuilder::SheetStandardEnglishScaleS11);
drawingSheetBuilder1->SetMetricSheetTemplateLocation("D:\\YiNing tools\\Drf_files\\A4_YN_horizontal.prt");//模板路径
drawingSheetBuilder1->SetEnglishSheetTemplateLocation("");
drawingSheetBuilder1->SetHeight(210.00); //图纸高度
drawingSheetBuilder1->SetLength(297.00); //图纸长度
drawingSheetBuilder1->SetStandardMetricScale(Drawings::DrawingSheetBuilder::SheetStandardMetricScaleS11);
drawingSheetBuilder1->SetStandardEnglishScale(Drawings::DrawingSheetBuilder::SheetStandardEnglishScaleS11);
drawingSheetBuilder1->SetScaleNumerator(1.0);
drawingSheetBuilder1->SetScaleDenominator(1.0);
drawingSheetBuilder1->SetUnits(Drawings::DrawingSheetBuilder::SheetUnitsMetric);
drawingSheetBuilder1->SetProjectionAngle(Drawings::DrawingSheetBuilder::SheetProjectionAngleFirst);
drawingSheetBuilder1->SetNumber("2");
drawingSheetBuilder1->SetSecondaryNumber("");
drawingSheetBuilder1->SetRevision("A");
NXObject *nXObject1;
nXObject1 = drawingSheetBuilder1->Commit();
drawingSheetBuilder1->Destroy();
workPart->Drafting()->SetTemplateInstantiationIsComplete(true);
原文:https://www.cnblogs.com/hqsalanhuang/p/14587885.html