VS2010 NX8.5
UF_initialize();
char msg[256];
int ModuleId = 0;
int button_id1 = 0;
UF_ask_application_module(&ModuleId);//获取当前所在的模块
FileNew *fileNewDrawing;
fileNewDrawing = theSession->Parts()->FileNew();
fileNewDrawing->SetTemplateFileName("A3_YN_horizontal.prt");//模板名称
fileNewDrawing->SetApplication(FileNewApplicationDrafting);
fileNewDrawing->SetUnits(Part::UnitsMillimeters);
fileNewDrawing->SetRelationType("");
fileNewDrawing->SetUsesMasterModel("Yes");
fileNewDrawing->SetTemplateType(FileNewTemplateTypeItem);
fileNewDrawing->SetNewFileName("D:\Alan-work\YN35678-2-001_dwg1.prt");//设置新建加工图的全路路径
fileNewDrawing->SetMasterFileName("YN35678-2-001");//要创建图纸的部件
fileNewDrawing->SetUseBlankTemplate(false);
fileNewDrawing->SetMakeDisplayedPart(true);
NXObject *nXObject1;
nXObject1 = fileNewDrawing->Commit();
workPart = theSession->Parts()->Work();
displayPart = theSession->Parts()->Display();
fileNewDrawing->Destroy();
Drawings::DrawingSheet *drawingSheet1(dynamic_cast<Drawings::DrawingSheet *>(workPart->DrawingSheets()->FindObject("SHT1")));
drawingSheet1->Open();
workPart->Drafting()->SetTemplateInstantiationIsComplete(true);
if ( ModuleId != 1)
{
theUI->MenuBarManager()->ApplicationSwitchRequest("UG_APP_DRAFTING");//切换到工程图模块
}
UF_terminate();