/// <summary> /// Сохранить PDF из чертежа с тем же именем /// </summary> /// <param name="swModelMan"></param> /// <param name="folder">Папка сохранения</param> /// <param name="name">Имя файла с расширением</param> /// <returns></returns> public static bool SavePDF(SwModelManager swModelMan, string folder = null, string name = null) { bool ret = false; int lineNum = 14; const int offset = 23; Console.CursorLeft = 0; if (string.IsNullOrEmpty(folder)) { folder = swModelMan.FolderPath; } if (string.IsNullOrEmpty(name)) { name = swModelMan.FileNameWhithoutExt + ".pdf"; } StringManager.ClearLine(lineNum); Console.Write($"{"Сохранение PDF: ",offset}"); DrawingDoc DrawDoc; string drawName = Path.ChangeExtension(swModelMan.FileName, "SLDDRW"); var openedDraw = SwProcess.swApp.GetOpenDocument(drawName); bool docIsOpened = false; if (!(openedDraw is null)) { docIsOpened = true; } if (SwFileManager.OpenDraw(swModelMan.FilePath, out DrawDoc)) { var model = (ModelDoc2)DrawDoc; ret = swModelMan.Export.SavePdf(DrawDoc, folder + name, true); if (!docIsOpened) { SwProcess.swApp.CloseDoc(model.GetTitle()); } } Console.Write(ret ? " OK\n" : " Не сохранено\n"); return(ret); }
/// <summary> /// Написать список параметров сборки или детали /// </summary> /// <param name="swModelMan"></param> public static void ShowProp(SwModelManager swModelMan) { bool ret = false; const int offset = 23; int lineNum = 6; Console.CursorTop = lineNum; swDocumentTypes_e doctype = swModelMan.DocType; if (doctype == swDocumentTypes_e.swDocPART || doctype == swDocumentTypes_e.swDocASSEMBLY) { string NameProp = swModelMan.PrpMan.Title; string parnNum = swModelMan.PrpMan.GetParam("Обозначение"); string configName = swModelMan.PrpMan.GetActiveConf; bool isDrawExist = SwFileManager.isDrawExcist(swModelMan.FilePath); bool isSheet = swModelMan.PrpMan.isSheet; string DrawIsFound = isDrawExist ? "Найден" : "Не найден"; string isSheetMetal = isSheet ? $"Листовая - {swModelMan.PrpMan.GetSheetThickness}мм" : "Не листовая"; //Clear console below for (int i = lineNum; i < lineNum + 5; ++i) { StringManager.ClearLine(i); } Console.CursorLeft = 0; Console.CursorTop = lineNum; Console.WriteLine($"{"Обозначение: ",offset} {parnNum}"); Console.WriteLine($"{"Наименование: ",offset} {NameProp}"); Console.WriteLine($"{"Активная конфигурация: ",offset} {configName}"); Console.WriteLine($"{"Одноимённый чертёж: ",offset} {DrawIsFound}"); Console.WriteLine($"{"Тип детали: ",offset} {isSheetMetal}"); } else { Console.WriteLine($"{"Имя чертежа: ",offset} {swModelMan.swModel.GetTitle()}"); } }