public static int GetLocalVersionOfFile(string path) { try { IEdmFolder5 oFolder; var ver = GetEdmFile5(path, out oFolder); return(ver.CurrentVersion); } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nPath - {path}\nStackTrace - {exception.StackTrace}", null, "GetLastVersionOfFile", "SwEpdm"); //MessageBox.Show(exception.Message + "\n" + exception.StackTrace); return(0); } }
internal void GetIdPdm(string path, out string fileName, out int fileIdPdm, out int curVer, out List <string> configurations) { fileName = null; fileIdPdm = 0; curVer = 0; configurations = null; try { VaultSystem.GetIdPdm(path, out fileName, out fileIdPdm, out curVer, out configurations, false, VaultName); } catch (Exception e) { Логгер.Ошибка("Ошибка: " + e.StackTrace, e.GetHashCode().ToString("X"), path, "GetIdPdm"); } }
static void PartInfoToXml(string filePath) { try { if (filePath == "") { return; } var extension = Path.GetExtension(filePath); if (extension == null) { return; } if (extension.ToLower() != ".sldprt") { return; } var @class = new MakeDxfExportPartDataClass { PdmBaseName = VaultName }; bool isErrors; string newEdrwFileName; @class.CreateFlattPatternUpdateCutlistAndEdrawing(filePath, out newEdrwFileName, out isErrors, false, false, true, true); if (!isErrors) { Логгер.Информация("Закончена обработка детали " + Path.GetFileName(filePath), null, "", "PartInfoToXml"); } else { List <VaultSystem.VentsCadFile> list; VaultSystem.CheckInOutPdmNew(new List <VaultSystem.VentsCadFile> { new VaultSystem.VentsCadFile { LocalPartFileInfo = newEdrwFileName } }, true, // VaultName, out list); Логгер.Информация("Закончена обработка детали " + Path.GetFileName(filePath) + " с ошибками", null, "", "PartInfoToXml"); } } catch (Exception e) { Логгер.Ошибка("Ошибка:" + e.Message, e.StackTrace, "SwEpdm", "AddToPdmByPath"); } }
internal static IEdmFile5 GetEdmFile5(string path, out IEdmFolder5 folder) { folder = null; try { IEdmFolder5 oFolder; var edmFile5 = edmVault5.GetFileFromPath(path, out oFolder); edmFile5.GetFileCopy(0, 0, oFolder.ID, (int)EdmGetFlag.EdmGet_RefsVerLatest); folder = oFolder; return(edmFile5); } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nPath - {path}\nStackTrace - {exception.StackTrace}", null, "GetEdmFile5", "SwEpdm"); //MessageBox.Show(exception.Message + "\n" + exception.StackTrace + "\n" + path); return(null); } }
internal int GetPdmIds(string path, out int projectId) { var Id = 0; projectId = 0; try { IEdmFolder5 oFolder; Id = GetEdmFile5(path, out oFolder).ID; projectId = oFolder.ID; } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nPath - {path}\nStackTrace - {exception.StackTrace}", null, "GetPdmIds", "SwEpdm"); //MessageBox.Show(exception.Message + "\n" + exception.StackTrace); } return(Id); }
internal static void GetIdPdm(string path, out string fileName, out int fileIdPdm, EdmVault5 edmVault5) { fileName = null; fileIdPdm = 0; try { IEdmFolder5 oFolder; var tries = 1; m1: Thread.Sleep(500); path = new FileInfo(path).FullName; var edmFile5 = edmVault5.GetFileFromPath(path, out oFolder); if (oFolder == null) { tries++; if (tries > 10) { return; } goto m1; } try { edmFile5.GetFileCopy(0, 0, oFolder.ID, (int)EdmGetFlag.EdmGet_RefsVerLatest); } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nPath - {path}\nStackTrace - {exception.StackTrace}", null, "GetIdPdm", "SwEpdm"); //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } fileName = edmFile5.Name; fileIdPdm = edmFile5.ID; } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nPath - {path}\nStackTrace - {exception.StackTrace}", null, "GetIdPdm", "SwEpdm"); //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } }
public static void AddToPdmByPath(string path) { if (UseDll) { throw new Exception("!UseDll"); } else { try { var fileDirectory = new FileInfo(path).DirectoryName; var fileFolder = edmVault5.GetFolderFromPath(fileDirectory); fileFolder.AddFile(fileFolder.ID, "", Path.GetFileName(path)); } catch (Exception e) { Логгер.Ошибка("Ошибка:" + e.Message, e.StackTrace, "SwEpdm", "AddToPdmByPath"); } } }
public static void BatchGet(IEdmVault7 vault, List <AddinConvertTo.Classes.FilesData.TaskParam> files) { try { var batchGetter = (IEdmBatchGet)vault.CreateUtility(EdmUtility.EdmUtil_BatchGet); foreach (var taskVar in files) { //MessageBox.Show($"IdPDM - {taskVar.IdPDM}\n FolderID - {taskVar.FolderID}\n CurrentVersion - {taskVar.CurrentVersion}"); //batchGetter.AddSelectionEx((EdmVault5)vault, taskVar.IdPDM, taskVar.FolderID, taskVar.CurrentVersion); IEdmFolder5 ppoRetParentFolder; IEdmFile5 aFile; try { aFile = vault.GetFileFromPath(taskVar.FullFilePath, out ppoRetParentFolder); } catch (Exception ex) { //MessageBox.Show(ex.Message + "\n" + taskVar.FullFilePath, " Получение файла из PDM"); continue; } aFile = (IEdmFile5)vault.GetObject(EdmObjectType.EdmObject_File, taskVar.IdPDM); var aPos = aFile.GetFirstFolderPosition(); var aFolder = aFile.GetNextFolder(aPos); batchGetter.AddSelectionEx((EdmVault5)vault, taskVar.IdPDM, aFolder.ID, taskVar.CurrentVersion); } if ((batchGetter != null)) { batchGetter.CreateTree(0, (int)EdmGetCmdFlags.Egcf_SkipUnlockedWritable + (int)EdmGetCmdFlags.Egcf_RefreshFileListing); batchGetter.GetFiles(0, null); } } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchUnLock", "SwEpdm"); //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } }
internal static void BatchUnLock(List <VaultSystem.VentsCadFile> filesList, EdmVault5 edmVault5) { IEdmPos5 aPos; var batchUnlocker = (IEdmBatchUnlock2)edmVault5.CreateUtility(EdmUtility.EdmUtil_BatchUnlock); var i = 0; var ppoSelection = new EdmSelItem[filesList.Count]; foreach (var file in filesList) { var fileInfo = new FileInfo(file.LocalPartFileInfo); if (string.IsNullOrEmpty(fileInfo.Extension)) { continue; } IEdmFolder5 ppoRetParentFolder; IEdmFile5 aFile; try { aFile = edmVault5.GetFileFromPath(fileInfo.FullName, out ppoRetParentFolder); } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchUnLock", "SwEpdm"); //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); continue; } if (aFile != null) { try { aPos = aFile.GetFirstFolderPosition(); var aFolder = aFile.GetNextFolder(aPos); ppoSelection[i] = new EdmSelItem { mlDocID = aFile.ID, mlProjID = aFolder.ID }; i++; } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchUnLock", "SwEpdm"); //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } } } // Add selections to the batch of files to check in batchUnlocker.AddSelection(edmVault5, ppoSelection); batchUnlocker.CreateTree(0, (int)EdmUnlockBuildTreeFlags.Eubtf_ShowCloseAfterCheckinOption + (int)EdmUnlockBuildTreeFlags.Eubtf_MayUnlock); batchUnlocker.Comment = filesList[0].MessageForCheckOut; var fileList = (IEdmSelectionList6)batchUnlocker.GetFileList((int)EdmUnlockFileListFlag.Euflf_GetUnlocked + (int)EdmUnlockFileListFlag.Euflf_GetUndoLocked + (int)EdmUnlockFileListFlag.Euflf_GetUnprocessed); aPos = fileList.GetHeadPosition(); while (!(aPos.IsNull)) { EdmSelectionObject poSel; fileList.GetNext2(aPos, out poSel); } batchUnlocker.UnlockFiles(0); }
internal static void BatchAddFiles(List <VaultSystem.VentsCadFile> filesList, EdmVault5 edmVault5) { goto m1; #region Dll var edmVault7 = (IEdmVault7)edmVault5; AddinConvertTo.Classes.Batches.BatchAddFiles(edmVault7, ConvertVentsCadFiles(filesList)); return; #endregion m1: #region Code List <string> stringList = new List <string>(); #region Show // filesList.Select(x => x.LocalPartFileInfo).ToList(); //MessageBox.Show(stringList.Count.ToString(), "Count before"); //stringList = stringList.Distinct().ToList(); //MessageBox.Show(stringList.Count.ToString(), "Count after 2"); #endregion foreach (var item in filesList.OrderBy(x => x.LocalPartFileInfo)) { var inf = new FileInfo(item.LocalPartFileInfo); if (stringList.Contains(inf.Name)) { continue; } stringList.Add(inf.FullName); } var files = ""; foreach (var file in stringList.Distinct()) { files = files + "\n" + file; } files = ""; try { var poAdder = (IEdmBatchAdd2)edmVault5.CreateUtility(EdmUtility.EdmUtil_BatchAdd); foreach (var file in stringList.Distinct()) { var fileInfo = new FileInfo(file); var directoryName = fileInfo.Directory.FullName; files = files + $"\n File - {fileInfo.FullName} directory - {directoryName}"; poAdder.AddFileFromPathToPath(fileInfo.FullName, directoryName); } try { //MessageBox.Show(poAdder.CommitAdd(0, null).ToString()); poAdder.CommitAdd(-1, null); } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchAddFiles", "SwEpdm"); //MessageBox.Show(e.Message + "\n" + e.StackTrace, "2"); } } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "BatchAddFiles", "SwEpdm"); //MessageBox.Show(e.StackTrace, "BatchAddFiles"); } finally { //MessageBox.Show(files); } #endregion }
public static void GetIdPdm(string path, out string fileName, out int fileIdPdm, out int currentVerison, out List <string> configs, bool getFileCopy) { fileName = null; fileIdPdm = 0; currentVerison = 0; configs = new List <string>(); try { IEdmFolder5 oFolder; var tries = 1; m1: Thread.Sleep(500); path = new FileInfo(path).FullName; var edmFile5 = edmVault5.GetFileFromPath(path, out oFolder); if (oFolder == null) { tries++; if (tries > 10) { return; } goto m1; } if (getFileCopy) { try { edmFile5.GetFileCopy(0, 0, oFolder.ID, (int)EdmGetFlag.EdmGet_RefsVerLatest); } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nPath - {path}\nStackTrace - {exception.StackTrace}", null, "GetIdPdm", "SwEpdm"); //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } } fileName = edmFile5.Name; fileIdPdm = edmFile5.ID; currentVerison = edmFile5.CurrentVersion; EdmStrLst5 list = edmFile5.GetConfigurations(); IEdmPos5 pos = default(IEdmPos5); pos = list.GetHeadPosition(); string cfgName = null; while (!pos.IsNull) { cfgName = list.GetNext(pos); if (cfgName == "@") { continue; } configs.Add(cfgName); } } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nPath - {path}\nStackTrace - {exception.StackTrace}", null, "GetIdPdm", "SwEpdm"); //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } }
public static void CheckInOutPdm(List <FileInfo> filesList, bool registration) { foreach (var file in filesList) { var retryCount = 2; var success = false; while (!success && retryCount > 0) { try { IEdmFolder5 oFolder; var edmFile5 = edmVault5.GetFileFromPath(file.FullName, out oFolder); // Разрегистрировать if (registration == false) { edmFile5.GetFileCopy(0, 0, oFolder.ID, (int)EdmGetFlag.EdmGet_Simple); m1: edmFile5.LockFile(oFolder.ID, 0); //MessageBox.Show(edmFile5.Name); Thread.Sleep(50); var j = 0; if (!edmFile5.IsLocked) { j++; if (j > 5) { goto m3; } goto m1; } } // Зарегистрировать if (registration) { m2: edmFile5.UnlockFile(oFolder.ID, ""); Thread.Sleep(50); var i = 0; if (edmFile5.IsLocked) { i++; if (i > 5) { goto m4; } goto m2; } } m3: m4: //LoggerInfo(string.Format("В базе PDM - {1}, зарегестрирован документ по пути {0}", file.FullName, vaultName), "", "CheckInOutPdm"); success = true; } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nfile.FullName - {file.FullName}\nStackTrace - {exception.StackTrace}", null, "CheckInOutPdm", "SwEpdm"); //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); retryCount--; Thread.Sleep(200); if (retryCount == 0) { // } } } if (!success) { //LoggerError($"Во время регистрации документа по пути {file.FullName} возникла ошибка\nБаза - {vaultName}. {ex.Message}", "", "CheckInOutPdm"); } } }
static void SwPartParamsChangeWithNewName(string partName, string newName, string[,] newParams, bool newFuncOfAdding, IList <string> copies) { try { Логгер.Информация($"Начало изменения детали {partName}", null, newName, "SwPartParamsChangeWithNewName"); var swDoc = _swApp.OpenDoc6(partName + ".SLDPRT", (int)swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", 0, 0); var modName = swDoc.GetPathName(); for (var i = 0; i < newParams.Length / 2; i++) { try { var myDimension = ((Dimension)(swDoc.Parameter(newParams[i, 0] + "@" + partName + ".SLDPRT"))); var param = Convert.ToDouble(newParams[i, 1]); var swParametr = param; myDimension.SystemValue = swParametr / 1000; swDoc.EditRebuild3(); } catch (Exception e) { Логгер.Ошибка(string.Format("Во время изменения детали {4} произошла ошибка при изменении параметров {0}={1}. {2} {3}", newParams[i, 0], newParams[i, 1], e.TargetSite, e.Message, Path.GetFileNameWithoutExtension(modName)), null, "", "SwPartParamsChangeWithNewName"); } } if (newName == "") { return; } GabaritsForPaintingCamera(swDoc); swDoc.EditRebuild3(); swDoc.ForceRebuild3(false); if (!newFuncOfAdding) { // ComponentToAdd(new FileInfo($@"{destRootFolder}\{DamperDestinationFolder}\{newNameAsm}").FullName); // NewComponents.Add(new VaultSystem.VentsCadFiles{LocalPartFileInfo = new FileInfo(newName + ".SLDPRT").FullName}); } if (newFuncOfAdding) { NewComponents.Add(new VaultSystem.VentsCadFile { LocalPartFileInfo = new FileInfo(newName + ".SLDPRT").FullName, PartIdSql = Convert.ToInt32(newName.Substring(newName.LastIndexOf('-') + 1)) }); } swDoc.SaveAs2(new FileInfo(newName + ".SLDPRT").FullName, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); if (copies != null) { swDoc.SaveAs2(new FileInfo(copies[0] + ".SLDPRT").FullName, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, true, true); swDoc.SaveAs2(new FileInfo(copies[1] + ".SLDPRT").FullName, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, true, true); } _swApp.CloseDoc(newName + ".SLDPRT"); Логгер.Информация($"Деталь {partName} изменена и сохранена по пути {new FileInfo(newName).FullName}", null, "", "SwPartParamsChangeWithNewName"); } catch (Exception e) { MessageBox.Show(e.ToString()); } }
private static void VentsMatdll(IList <string> materialP1, IList <string> покрытие, string newName) { try { //MessageBox.Show("ApplyMaterial 1"); //_swApp.ActivateDoc2(newName, true, 0); //var setMaterials = new SetMaterials(); //ToSQL.Conn = ConnectionToSql; //var toSql = new ToSQL(); //MessageBox.Show("ApplyMaterial 2"); //setMaterials.ApplyMaterial("", "00", // 1700, // //Convert.ToInt32(materialP1[0]), // _swApp); //_swApp.IActiveDoc2.Save(); //foreach (var confname in setMaterials.GetConfigurationNames(_swApp)) //{ // foreach (var matname in setMaterials.GetCustomProperty(confname, _swApp)) // { // toSql.AddCustomProperty(confname, matname.Name, _swApp); // } //} //if (покрытие != null) //{ // if (покрытие[1] != "0") // { // setMaterials.SetColor("00", покрытие[0], покрытие[1], покрытие[2], _swApp); // } // _swApp.IActiveDoc2.Save(); //} //try //{ // string message; // setMaterials.CheckSheetMetalProperty("00", _swApp, out message); // if (message != null) // { // MessageBox.Show(message, newName); // } //} //catch (Exception e) //{ // MessageBox.Show(e.Message + "\n" + e.StackTrace, "VentsMatdll"); // Логгер.Ошибка("Ошибка: " + e.StackTrace, e.GetHashCode().ToString("X"), newName, "VentsMatdll"); //} } catch (Exception e) { MessageBox.Show(e.Message + "\n" + e.StackTrace, "VentsMatdll"); Логгер.Ошибка("Ошибка: " + e.StackTrace, e.GetHashCode().ToString("X"), newName, "VentsMatdll"); } finally { try { GabaritsForPaintingCamera(_swApp.IActiveDoc2); _swApp.IActiveDoc2.Save(); } catch (Exception e) { MessageBox.Show(e.Message + "\n" + e.StackTrace); Логгер.Ошибка("Ошибка: " + e.StackTrace, e.GetHashCode().ToString("X"), newName, "VentsMatdll"); } } }
static void GabaritsForPaintingCamera(IModelDoc2 swmodel) { try { const long valueset = 1000; const int swDocPart = 1; const int swDocAssembly = 2; var configNames = swmodel.GetConfigurationNames(); foreach (var configname in configNames) { try { IConfiguration swConf = swmodel.GetConfigurationByName(configname); if (swConf.IsDerived()) { continue; } } catch (Exception) { // } swmodel.EditRebuild3(); switch (swmodel.GetType()) { case swDocPart: { var part = (IPartDoc)swmodel; var box = part.GetPartBox(true); swmodel.AddCustomInfo3(configname, "Длина", 30, ""); swmodel.AddCustomInfo3(configname, "Ширина", 30, ""); swmodel.AddCustomInfo3(configname, "Высота", 30, ""); swmodel.CustomInfo2[configname, "Длина"] = Convert.ToString( Math.Round(Convert.ToDecimal((long)(Math.Abs(box[0] - box[3]) * valueset)), 0)); swmodel.CustomInfo2[configname, "Ширина"] = Convert.ToString( Math.Round(Convert.ToDecimal((long)(Math.Abs(box[1] - box[4]) * valueset)), 0)); swmodel.CustomInfo2[configname, "Высота"] = Convert.ToString( Math.Round(Convert.ToDecimal((long)(Math.Abs(box[2] - box[5]) * valueset)), 0)); } break; case swDocAssembly: { var swAssy = (AssemblyDoc)swmodel; var boxAss = swAssy.GetBox((int)swBoundingBoxOptions_e.swBoundingBoxIncludeRefPlanes); swmodel.AddCustomInfo3(configname, "Длина", 30, ""); swmodel.AddCustomInfo3(configname, "Ширина", 30, ""); swmodel.AddCustomInfo3(configname, "Высота", 30, ""); swmodel.CustomInfo2[configname, "Длина"] = Convert.ToString( Math.Round(Convert.ToDecimal((long)(Math.Abs(boxAss[0] - boxAss[3]) * valueset)), 0)); swmodel.CustomInfo2[configname, "Ширина"] = Convert.ToString( Math.Round(Convert.ToDecimal((long)(Math.Abs(boxAss[1] - boxAss[4]) * valueset)), 0)); swmodel.CustomInfo2[configname, "Высота"] = Convert.ToString( Math.Round(Convert.ToDecimal((long)(Math.Abs(boxAss[2] - boxAss[5]) * valueset)), 0)); } break; } } } catch (Exception e) { Логгер.Ошибка("Ошибка: " + e.StackTrace, e.GetHashCode().ToString("X"), null, "GabaritsForPaintingCamera"); } }
public static void SearchDoc(string fileName, SwDocType swDocType, out List <FindedDocuments> fileList, string vaultName) { var files = new List <FindedDocuments>(); try { var edmVault7 = (IEdmVault7)edmVault5; //Search for all text files in the edmVault7 var edmSearch5 = (IEdmSearch5)edmVault7.CreateUtility(EdmUtility.EdmUtil_Search); var extenison = ""; var like = ""; switch ((int)swDocType) { case 0: extenison = ""; like = ""; break; case 1: like = "%"; extenison = ".sldprt"; break; case 2: like = "%"; extenison = "%.sldasm"; break; case 3: like = "%"; extenison = "%.slddrw"; break; case 4: like = "%"; extenison = "%.%"; break; } edmSearch5.FileName = like + fileName + extenison; var edmSearchResult5 = edmSearch5.GetFirstResult(); while (edmSearchResult5 != null) { files.Add(new FindedDocuments { PartIdPdm = edmSearchResult5.ID, PartName = edmSearchResult5.Name, PartSize = edmSearchResult5.FileSize, ProjectId = edmSearchResult5.ParentFolderID, Path = edmSearchResult5.Path, Time = (DateTime)edmSearchResult5.FileDate }); edmSearchResult5 = edmSearch5.GetNextResult(); } if (edmSearch5.GetFirstResult() == null) { //LoggerInfo("Файл не найден!"); files = null; } } catch (Exception exception) { Логгер.Ошибка($"Message - {exception.Message}\nStackTrace - {exception.StackTrace}", null, "SearchDoc", "SwEpdm"); //MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } fileList = files; }
public string Panels50(string[] typeOfPanel, string width, string height, string[] materialP1, string[] materialP2, string[] покрытие, bool onlyPath) { if (!ConvertToInt(new[] { width, height })) { return(""); } //Логгер.Отладка("Начало построения 50-й панели. ", "", "Panels50BuildStr", "Panels50BuildStr"); string modelPanelsPath; string modelName; string nameAsm; var modelType = $"50-{materialP1[3]}{(materialP1[3] == "AZ" ? "" : materialP1[1])}-{materialP2[3]}{(materialP2[3] == "AZ" ? "" : materialP2[1])}-MW"; switch (typeOfPanel[1]) { case "Панель несъемная глухая": modelPanelsPath = Panel50Folder; nameAsm = "02-01"; modelName = "02-01"; DestinationFolder = Panels0201; break; case "Панель съемная с ручками": modelPanelsPath = Panel50Folder; nameAsm = "02-01"; modelName = "02-04"; DestinationFolder = Panels0204; break; case "Панель теплообменника": modelPanelsPath = Panel50Folder; nameAsm = "02-01"; modelName = "02-05"; DestinationFolder = Panels0205; break; case "Панель двойная несъемная": modelPanelsPath = DublePanel50Folder; nameAsm = "02-104-50"; modelName = "02-01"; DestinationFolder = Panels0201; break; case "Панель двойная съемная": modelPanelsPath = DublePanel50Folder; nameAsm = "02-104-50"; modelName = "02-01"; DestinationFolder = Panels0201; break; default: modelPanelsPath = Panel50Folder; nameAsm = "02-01"; modelName = "02-01"; break; } #region Обозначения и Хранилище #region before //var newPanel50Name = String.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}", // modelName + "-" + width + "-" + height + "-50", // string.IsNullOrEmpty(materialP1) ? "" : "-" + materialP1, // //string.IsNullOrEmpty(покрытие[0]) ? "" : "-" + покрытие[0], // //string.IsNullOrEmpty(покрытие[1]) ? "" : "-" + покрытие[1], // //string.IsNullOrEmpty(покрытие[2]) ? "" : "-" + покрытие[2], // string.IsNullOrEmpty(materialP2) ? "" : "-" + materialP2, // //string.IsNullOrEmpty(покрытие[3]) ? "" : "-" + покрытие[3], // //string.IsNullOrEmpty(покрытие[4]) ? "" : "-" + покрытие[4], // //string.IsNullOrEmpty(покрытие[5]) ? "" : "-" + покрытие[5], // "-MW"); #endregion #region Без покрытия //if (покрытие[0] == "Без покрытия") //{ // покрытие[1] = "0"; // покрытие[2] = "0"; //} //if (покрытие[3] == "Без покрытия") //{ // покрытие[4] = "0"; // покрытие[5] = "0"; //} //var partIds = new List<int>(); //var панельВнешняя = // new PanelsVault // { // PanelTypeName = typeOfPanel[1], // ElementType = 1, // Width = Convert.ToInt32(width), // Height = Convert.ToInt32(height), // PartThick = 50, // PartMat = Convert.ToInt32(materialP1[0]), // PartMatThick = Convert.ToDouble(materialP1[1].Replace('.', ',')), // Ral = покрытие[0], // CoatingType = покрытие[1], // CoatingClass = Convert.ToInt32(покрытие[2]), // Mirror = false, // Reinforcing = false // }; //var id = панельВнешняя.AirVents_AddPartOfPanel(); //partIds.Add(id); //панельВнешняя.NewName = "02-" + typeOfPanel[0] + "-1-" + id; //var панельВнутренняя = // new AddingPanel // { // PanelTypeName = typeOfPanel[1], // ElementType = 2, // Width = Convert.ToInt32(width), // Height = Convert.ToInt32(height), // PartThick = 50, // PartMat = Convert.ToInt32(materialP2[0]), // PartMatThick = Convert.ToDouble(materialP2[1].Replace('.', ',')), // Ral = покрытие[3], // CoatingType = покрытие[4], // CoatingClass = Convert.ToInt32(покрытие[5]), // Reinforcing = false // }; //id = панельВнутренняя.AddPart(); //partIds.Add(id); //панельВнутренняя.NewName = "02-" + typeOfPanel[0] + "-2-" + id; //var теплоизоляция = // new AddingPanel // { // PanelTypeName = typeOfPanel[1], // ElementType = 3, // Width = Convert.ToInt32(width), // Height = Convert.ToInt32(height), // PartThick = 50, // PartMat = 4900, // Reinforcing = false, // PartMatThick = 1, // Ral = "Без покрытия", // CoatingType = "0", // CoatingClass = Convert.ToInt32("0") // }; //id = теплоизоляция.AddPart(); //partIds.Add(id); //теплоизоляция.NewName = "02-" + id; //var уплотнитель = // new AddingPanel // { // PanelTypeName = typeOfPanel[1], // ElementType = 4, // Width = Convert.ToInt32(width), // Height = Convert.ToInt32(height), // PartThick = 50, // PartMat = 14800, // Reinforcing = false, // PartMatThick = 1, // Ral = "Без покрытия", // CoatingType = "0", // CoatingClass = Convert.ToInt32("0") // }; //id = уплотнитель.AddPart(); //partIds.Add(id); //уплотнитель.NewName = "02-" + id; //var деталь103 = // new AddingPanel // { // PanelTypeName = typeOfPanel[1], // ElementType = 103, // Width = Convert.ToInt32(width), // Height = Convert.ToInt32(height), // PartThick = 50, // PartMat = 14800, // Reinforcing = false, // PartMatThick = 1, // Ral = "Без покрытия", // CoatingType = "0", // CoatingClass = Convert.ToInt32("0") // }; //id = деталь103.AddPart(); //partIds.Add(id); //деталь103.NewName = "02-" + id; //#region ////MessageBox.Show( //// String.Format("{0}\n{1}\n{2}\n{3}\n{4}\n", //// панельВнешняя.NewName, //// панельВнутренняя.NewName, //// теплоизоляция.NewName, //// уплотнитель.NewName, //// деталь103.NewName)); return ""; //#endregion //var sqlBaseData = new SqlBaseData(); //var newId = sqlBaseData.PanelNumber() + 1; //var idAsm = 0; //foreach (var сборка in partIds.Select(partId => new AddingPanel //{ // PartId = partId, // PanelTypeName = typeOfPanel[1], // Width = Convert.ToInt32(width), // Height = Convert.ToInt32(height), // PanelMatOut = Convert.ToInt32(materialP1[0]), // PanelMatIn = Convert.ToInt32(materialP2[0]), // PanelThick = 50, // PanelMatThickOut = Convert.ToDouble(materialP1[1].Replace('.', ',')), // PanelMatThickIn = Convert.ToDouble(materialP2[1].Replace('.', ',')), // RalOut = покрытие[0], // RalIn = покрытие[3], // CoatingTypeOut = покрытие[1], // CoatingTypeIn = покрытие[4], // CoatingClassOut = Convert.ToInt32(покрытие[2]), // CoatingClassIn = Convert.ToInt32(покрытие[5]), // Reinforcing = false, // PanelNumber = newId //})) //{ // idAsm = сборка.Add(); //} #endregion //var newPanel50Name = "02-" + typeOfPanel[0] + "-" + idAsm; #endregion var newDestPath = !typeOfPanel[1].Contains("Панель двойная съемная") ? DestinationFolder : Panels0204; var newModNumber = !typeOfPanel[1].Contains("Панель двойная съемная") ? modelName : "02-04"; var newPanel50Name = newModNumber + "-" + width + "-" + height + "-" + modelType; Логгер.Информация("Построение панели - " + newPanel50Name, null, "", "Panels50BuildStr"); var sourceFolder = LocalPath(VaultName); var destinationFolder = LocalPath(DestVaultName); var newPanel50Path = $@"{destinationFolder}{newDestPath}\{newPanel50Name}.SLDASM"; if (File.Exists(new FileInfo(newPanel50Path).FullName)) { if (onlyPath) { return(newPanel50Path); } MessageBox.Show(newPanel50Path, "Данная модель уже находится в базе"); return(""); } #region modelPanelAsmbly var modelPanelAsmbly = $@"{sourceFolder}{modelPanelsPath}\{nameAsm}.SLDASM"; GetLastVersionAsmPdm(modelPanelAsmbly, VaultName); if (!InitializeSw(true)) { return(""); } var swDoc = _swApp.OpenDoc6(modelPanelAsmbly, (int)swDocumentTypes_e.swDocASSEMBLY, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", 0, 0); _swApp.Visible = true; var swAsm = (AssemblyDoc)swDoc; swAsm.ResolveAllLightWeightComponents(false); // Габариты var widthD = Convert.ToDouble(width); var heightD = Convert.ToDouble(height); var halfWidthD = Convert.ToDouble(widthD / 2); // Шаг заклепок const double step = 80; var rivetW = (Math.Truncate(widthD / step) + 1) * 1000; var rivetWd = (Math.Truncate(halfWidthD / step) + 1) * 1000; var rivetH = (Math.Truncate(heightD / step) + 1) * 1000; if (Math.Abs(rivetW - 1000) < 1) { rivetW = 2000; } // Коэффициенты и радиусы гибов const string thiknessStr = "0,8"; var bendParams = BendTable(thiknessStr); var bendRadius = Convert.ToDouble(bendParams[0]); var kFactor = Convert.ToDouble(bendParams[1]); #endregion // Переменные панели с ручками var wR = widthD / 2; // Расстояние межу ручками if (widthD < 1000) { wR = widthD * 0.5; } if (widthD >= 1000) { wR = widthD * 0.45; } if (widthD >= 1300) { wR = widthD * 0.4; } if (widthD >= 1700) { wR = widthD * 0.35; } #region typeOfPanel != "Панель двойная" // Тип панели if (modelName == "02-01" & !typeOfPanel[1].Contains("Панель двойная")) { swDoc.Extension.SelectByID2("Ручка MLA 120-1@02-01", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("SC GOST 17475_gost-1@02-01", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("SC GOST 17475_gost-2@02-01", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Threaded Rivets-5@02-01", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Threaded Rivets-6@02-01", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); // Удаление ненужных элементов панели const int deleteOption = (int)swDeleteSelectionOptions_e.swDelete_Absorbed + (int)swDeleteSelectionOptions_e.swDelete_Children; swDoc.Extension.SelectByID2("Вырез-Вытянуть7@02-01-001-1@02-01", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDoc.Extension.DeleteSelection2(deleteOption); swDoc.Extension.SelectByID2("Ручка MLA 120-5@02-01", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("SC GOST 17475_gost-9@02-01", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("SC GOST 17475_gost-10@02-01", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Threaded Rivets-13@02-01", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Threaded Rivets-14@02-01", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); // Удаление ненужных элементов панели swDoc.Extension.SelectByID2("Вырез-Вытянуть8@02-01-001-1@02-01", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDoc.Extension.DeleteSelection2(deleteOption); } if (modelName == "02-04" || modelName == "02-05") { if (Convert.ToInt32(width) > 750) { swDoc.Extension.SelectByID2("Ручка MLA 120-1@02-01", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("SC GOST 17475_gost-1@02-01", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("SC GOST 17475_gost-2@02-01", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Threaded Rivets-5@02-01", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Threaded Rivets-6@02-01", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); // Удаление ненужных элементов панели const int deleteOption = (int)swDeleteSelectionOptions_e.swDelete_Absorbed + (int)swDeleteSelectionOptions_e.swDelete_Children; swDoc.Extension.SelectByID2("Вырез-Вытянуть7@02-01-001-1@02-01", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDoc.Extension.DeleteSelection2(deleteOption); } else { swDoc.Extension.SelectByID2("Ручка MLA 120-5@02-01", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("SC GOST 17475_gost-9@02-01", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("SC GOST 17475_gost-10@02-01", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Threaded Rivets-13@02-01", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Threaded Rivets-14@02-01", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); // Удаление ненужных элементов панели const int deleteOption = (int)swDeleteSelectionOptions_e.swDelete_Absorbed + (int)swDeleteSelectionOptions_e.swDelete_Children; swDoc.Extension.SelectByID2("Вырез-Вытянуть8@02-01-001-1@02-01", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDoc.Extension.DeleteSelection2(deleteOption); } } if (!typeOfPanel[1].Contains("Панель двойная")) { var newName = $"{modelName}-01-{width}-{height}-50-{materialP1[3]}{(materialP1[3] == "AZ" ? "" : materialP1[1])}"; var newPartPath = $@"{destinationFolder}{DestinationFolder}\{newName}.SLDPRT"; if (File.Exists(newPartPath)) //ExistFileInPdmBase(newName + ".SLDPRT") { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2("02-01.SLDASM", true, 0))); swDoc.Extension.SelectByID2("02-01-001-1@02-01", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", false, true); _swApp.CloseDoc("02-01-001.SLDPRT"); } else if (!File.Exists(newPartPath)) { SwPartParamsChangeWithNewName("02-01-001", $@"{destinationFolder}{DestinationFolder}\{newName}", new[, ] { { "D1@Эскиз1", (heightD).ToString() }, { "D2@Эскиз1", (widthD).ToString() }, { "D1@Кривая2", (rivetH).ToString() }, { "D1@Кривая1", (rivetW).ToString() }, { "D4@Эскиз30", (wR).ToString() }, { "Толщина@Листовой металл", materialP1[1].Replace('.', ',') } }, false); try { VentsMatdll(materialP1, new[] { покрытие[6], покрытие[1], покрытие[2] }, newName); } catch (Exception e) { MessageBox.Show(e.ToString()); } _swApp.CloseDoc(newName); } //Панель внутреняя var modelnewname = modelName; var modelPath = DestinationFolder; if (modelName == "02-04") { modelnewname = "02-01"; modelPath = Panels0201; } #region //newName = String.Format("{0}{1}{2}{3}", //modelnewname + "-02-" + width + "-" + height + "-" + "50-" + materialP2[0]; // //string.IsNullOrEmpty(покрытие[6]) ? "" : "-" + покрытие[6], // //string.IsNullOrEmpty(покрытие[1]) ? "" : "-" + покрытие[1], // //string.IsNullOrEmpty(покрытие[2]) ? "" : "-" + покрытие[2] // ); //newName = панельВнутренняя.NewName; //newName = modelnewname + "-02-" + width + "-" + height + "-" + "50-" + materialP2[3] + materialP2[3] == "AZ" ? "" : materialP2[1]; #endregion newName = $"{modelnewname}-02-{width}-{height}-50-{materialP2[3]}{(materialP2[3] == "AZ" ? "" : materialP2[1])}"; newPartPath = $@"{destinationFolder}{modelPath}\{newName}.SLDPRT"; if (File.Exists(newPartPath)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2("02-01.SLDASM", true, 0))); swDoc.Extension.SelectByID2("02-01-002-1@02-01", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", false, true); _swApp.CloseDoc("02-01-002.SLDPRT"); } else if (!File.Exists(newPartPath)) { #region before //SetMeterial(materialP2[0], _swApp.ActivateDoc2("02-01-002.SLDPRT", true, 0), ""); //try //{ // var setMaterials = new SetMaterials(); // _swApp.ActivateDoc2("02-11-01-40-.SLDPRT", true, 0); // setMaterials.SetColor("00", покрытие[7], покрытие[4], покрытие[5], _swApp);// setMaterials.SetColor("00", "F6F6F6", "Шаргень", "2", _swApp); //} //catch (Exception e) //{ // MessageBox.Show(e.StackTrace); //} #endregion SwPartParamsChangeWithNewName("02-01-002", $@"{destinationFolder}{modelPath}\{newName}", new[, ] { { "D1@Эскиз1", (heightD - 10).ToString() }, { "D2@Эскиз1", (widthD - 10).ToString() }, { "D1@Кривая2", (rivetH).ToString() }, { "D1@Кривая1", (rivetW).ToString() }, { "Толщина@Листовой металл", materialP2[1].Replace('.', ',') }, { "D1@Листовой металл", (bendRadius).ToString() }, { "D2@Листовой металл", (kFactor * 1000).ToString() } }, false); try { VentsMatdll(materialP2, new[] { покрытие[7], покрытие[4], покрытие[5] }, newName); } catch (Exception e) { MessageBox.Show(e.ToString()); } _swApp.CloseDoc(newName); } //Панель теплошумоизоляции if (modelName == "02-05") { modelPath = Panels0201; } newName = "02-03-" + width + "-" + height; //newName = теплоизоляция.NewName; newPartPath = $@"{destinationFolder}{modelPath}\{newName}.SLDPRT"; if (File.Exists(newPartPath)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2("02-01.SLDASM", true, 0))); swDoc.Extension.SelectByID2("02-01-003-1@02-01", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", false, true); _swApp.CloseDoc("02-01-003.SLDPRT"); } else if (File.Exists(newPartPath) != true) { SwPartParamsChangeWithNewName("02-01-003", $@"{destinationFolder}{DestinationFolder}\{newName}", new[, ] { { "D1@Эскиз1", (heightD - 10).ToString() }, { "D2@Эскиз1", (widthD - 10).ToString() } }, false); _swApp.CloseDoc(newName); } //Уплотнитель newName = "02-04-" + width + "-" + height; //newName = уплотнитель.NewName; newPartPath = $@"{destinationFolder}{modelPath}\{newName}.SLDPRT"; if (File.Exists(newPartPath)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2("02-01.SLDASM", true, 0))); swDoc.Extension.SelectByID2("02-01-004-1@02-01", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", false, true); _swApp.CloseDoc("02-01-004.SLDPRT"); } else if (File.Exists(newPartPath) != true) { SwPartParamsChangeWithNewName("02-01-004", $@"{destinationFolder}{DestinationFolder}\{newName}", new[, ] { { "D6@Эскиз1", (heightD - 10).ToString() }, { "D3@Эскиз1", (widthD - 10).ToString() } }, false); _swApp.CloseDoc(newName); } } #endregion #region typeOfPanel == "Панель двойная несъемная" if (typeOfPanel[1].Contains("Панель двойная")) { #region before // Панель внешняя //var newName = String.Format("{0}{1}{2}{3}", // modelName + "-01-" + width + "-" + height + "-" + "50-" + materialP1 // //string.IsNullOrEmpty(покрытие[6]) ? "" : "-" + покрытие[6], // //string.IsNullOrEmpty(покрытие[1]) ? "" : "-" + покрытие[1], // //string.IsNullOrEmpty(покрытие[2]) ? "" : "-" + покрытие[2] // ); //var newName = панельВнешняя.NewName; //var newName = modelName + "-01-" + width + "-" + height + "-" + "50-" + materialP1[3] + materialP1[3] == "AZ" ? "" : materialP1[1]; #endregion var currDestPath = typeOfPanel[1].Contains("несъемная") ? DestinationFolder : Panels0204; var curNumber = typeOfPanel[1].Contains("несъемная") ? "01" : "04"; //MessageBox.Show("currDestPath - " + currDestPath + " curNumber -" + curNumber + " -- " + typeOfPanel[1].Contains("несъемная")); if (typeOfPanel[1].Contains("несъемная")) { //MessageBox.Show("Не съемная - " + typeOfPanel[1]); swDoc.Extension.SelectByID2("Ручка MLA 120-1@02-104-50", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("SC GOST 17475_gost-1@02-104-50", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("SC GOST 17475_gost-2@02-104-50", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Threaded Rivets-1@02-104-50", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Threaded Rivets-2@02-104-50", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); // Удаление ненужных элементов панели const int deleteOption = (int)swDeleteSelectionOptions_e.swDelete_Absorbed + (int)swDeleteSelectionOptions_e.swDelete_Children; swDoc.Extension.SelectByID2("Вырез-Вытянуть11@02-01-101-50-1@02-104-50", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDoc.Extension.DeleteSelection2(deleteOption); //MessageBox.Show("Удалилось"); } var newName = $"{modelName}-{curNumber}-{width}-{height}-50-{materialP1[3]}{(materialP1[3] == "AZ" ? "" : materialP1[1])}"; var newPartPath = $@"{destinationFolder}{currDestPath}\{newName}.SLDPRT"; MessageBox.Show("newPartPath -" + newPartPath); if (File.Exists(newPartPath)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2("02-104-50.SLDASM", true, 0))); swDoc.Extension.SelectByID2("02-01-101-50-1@02-104-50", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", false, true); _swApp.CloseDoc("02-01-101-50.SLDPRT"); } else if (File.Exists(newPartPath) != true) { SwPartParamsChangeWithNewName("02-01-101-50", $@"{destinationFolder}{currDestPath}\{newName}", new[, ] { { "D1@Эскиз1", (heightD).ToString() }, { "D2@Эскиз1", (widthD / 2).ToString() }, { "D1@Кривая4", (rivetH).ToString() }, { "D1@Кривая3", (rivetWd).ToString() }, { "D1@Кривая5", (rivetH).ToString() }, { "D2@Эскиз47", (wR / 2).ToString() }, { "Толщина@Листовой металл", materialP1[1].Replace('.', ',') }, { "D1@Листовой металл", (bendRadius).ToString() }, { "D2@Листовой металл", (kFactor * 1000).ToString() } }, false); try { VentsMatdll(materialP1, new[] { покрытие[6], покрытие[1], покрытие[2] }, newName); } catch (Exception e) { MessageBox.Show(e.ToString()); } _swApp.CloseDoc(newName); } #region Name before //Панель внутреняя //newName = String.Format("{0}{1}{2}{3}", // modelName + "-02-" + width + "-" + height + "-" + "50-" + materialP1 // //string.IsNullOrEmpty(покрытие[7]) ? "" : "-" + покрытие[7], // //string.IsNullOrEmpty(покрытие[3]) ? "" : "-" + покрытие[3], // //string.IsNullOrEmpty(покрытие[4]) ? "" : "-" + покрытие[4] // ); //newName = панельВнутренняя.NewName; //newName = modelName + "-02-" + width + "-" + height + "-" + "50-" + materialP2[3] + materialP2[3] == "AZ" ? "" : materialP2[1]; #endregion newName = $"{modelName}-02-{width}-{height}-50-{materialP2[3]}{(materialP2[3] == "AZ" ? "" : materialP2[1])}"; newPartPath = $@"{destinationFolder}{DestinationFolder}\{newName}.SLDPRT"; if (File.Exists(newPartPath)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2("02-104-50.SLDASM", true, 0))); swDoc.Extension.SelectByID2("02-01-102-50-1@02-104-50", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", false, true); _swApp.CloseDoc("02-01-102-50.SLDPRT"); } else if (File.Exists(newPartPath) != true) { SwPartParamsChangeWithNewName("02-01-102-50", $@"{destinationFolder}{DestinationFolder}\{newName}", new[, ] { { "D1@Эскиз1", (heightD - 10).ToString() }, { "D2@Эскиз1", ((widthD - 10) / 2).ToString() }, { "D1@Кривая3", (rivetH).ToString() }, { "D1@Кривая2", (rivetH).ToString() }, { "D1@Кривая1", (rivetWd).ToString() }, { "Толщина@Листовой металл", materialP2[1].Replace('.', ',') }, { "D1@Листовой металл", (bendRadius).ToString() }, { "D2@Листовой металл", (kFactor * 1000).ToString() } }, false); try { VentsMatdll(materialP1, new[] { покрытие[7], покрытие[4], покрытие[5] }, newName); } catch (Exception e) { MessageBox.Show(e.ToString()); } _swApp.CloseDoc(newName); } #region // Профиль 02-01-103-50 //newName = деталь103.NewName; // modelName + "-03-" + width + "-" + height + "-" + "50-" + materialP2[3] + materialP2[3] == "AZ" ? "" : materialP2[1]; #endregion newName = $"{modelName}-03-{width}-{height}-50-{materialP2[3]}{(materialP2[3] == "AZ" ? "" : materialP2[1])}"; newPartPath = $@"{destinationFolder}{DestinationFolder}\{newName}.SLDPRT"; if (File.Exists(newPartPath)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2("02-104-50.SLDASM", true, 0))); swDoc.Extension.SelectByID2("02-01-103-50-1@02-104-50", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", false, true); _swApp.CloseDoc("02-01-103-50.SLDPRT"); } else if (File.Exists(newPartPath) != true) { SwPartParamsChangeWithNewName("02-01-103-50", $@"{destinationFolder}{DestinationFolder}\{newName}", newParams: new[, ] { { "D1@Эскиз1", (heightD - 15).ToString() }, { "D1@Кривая1", (rivetH).ToString() }, { "Толщина@Листовой металл", thiknessStr }, { "D1@Листовой металл", (bendRadius).ToString() }, { "D2@Листовой металл", (kFactor * 1000).ToString() } }, newFuncOfAdding: false); _swApp.CloseDoc(newName); } //Панель теплошумоизоляции //newName = теплоизоляция.NewName; newName = "02-03-" + width + "-" + height; newPartPath = $@"{destinationFolder}{DestinationFolder}\{newName}.SLDPRT"; if (File.Exists(newPartPath)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2("02-104-50.SLDASM", true, 0))); swDoc.Extension.SelectByID2("02-01-003-1@02-104-50", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", false, true); _swApp.CloseDoc("02-01-003.SLDPRT"); } else if (File.Exists(newPartPath) != true) { SwPartParamsChangeWithNewName("02-01-003", $@"{destinationFolder}{DestinationFolder}\{newName}", new[, ] { { "D1@Эскиз1", Convert.ToString(heightD - 10) }, { "D2@Эскиз1", Convert.ToString(widthD - 10) } }, false); _swApp.CloseDoc(newName); } //Уплотнитель //newName = уплотнитель.NewName; newName = "02-04-" + width + "-" + height; newPartPath = $@"{destinationFolder}{DestinationFolder}\{newName}.SLDPRT"; if (File.Exists(newPartPath)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2("02-104-50.SLDASM", true, 0))); swDoc.Extension.SelectByID2("02-01-004-1@02-104-50", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", false, true); _swApp.CloseDoc("02-01-004.SLDPRT"); } else if (File.Exists(newPartPath) != true) { SwPartParamsChangeWithNewName("02-01-004", $@"{destinationFolder}{DestinationFolder}\{newName}", new[, ] { { "D6@Эскиз1", Convert.ToString(heightD - 10) }, { "D3@Эскиз1", Convert.ToString(widthD - 10) } }, false); _swApp.CloseDoc(newName); } } #endregion #region Несъемная //switch (typeOfPanel[1]) //{ // case "Несъемная": // case "Съемная": // typeOfPanel[1] = typeOfPanel[1] + " панель"; // break; // case "Панель теплообменника": // case "Панель двойная": // break; //} #endregion swDoc = ((ModelDoc2)(_swApp.ActivateDoc2(nameAsm, true, 0))); var swModelDocExt = swDoc.Extension; var swCustPropForDescription = swModelDocExt.CustomPropertyManager[""]; swCustPropForDescription.Set("Наименование", typeOfPanel[1]); swCustPropForDescription.Set("Description", typeOfPanel[1]); GabaritsForPaintingCamera(swDoc); swDoc.EditRebuild3(); swDoc.ForceRebuild3(true); swDoc.SaveAs2(new FileInfo(newPanel50Path).FullName, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); NewComponents.Add( new VaultSystem.VentsCadFile { LocalPartFileInfo = newPanel50Path }); _swApp.CloseDoc(new FileInfo(newPanel50Path).Name); _swApp.Visible = true; List <VaultSystem.VentsCadFile> newFilesList; VaultSystem.CheckInOutPdmNew(NewComponents, true, //DestVaultName, out newFilesList); foreach (var newComponent in NewComponents) { //PartInfoToXml(newComponent.LocalPartFileInfo); } if (onlyPath) { return(newPanel50Path); } MessageBox.Show(newPanel50Path, "Модель построена"); return(newPanel50Path); }
static void AddInSqlBaseSpigot(string fileName, int?idPdm, int?typeOfSpigot, int?height, int?width) { using (var con = new SqlConnection(ConnectionToSql)) { try { con.Open(); var sqlCommand = new SqlCommand("AirVents.Spigot", con) { CommandType = CommandType.StoredProcedure }; var sqlParameter = sqlCommand.Parameters; if (fileName == null) { sqlParameter.AddWithValue("@Filename", DBNull.Value); } else { sqlParameter.AddWithValue("@Filename", fileName); } if (idPdm == null) { sqlParameter.AddWithValue("@IDPDM", DBNull.Value); } else { sqlParameter.AddWithValue("@IDPDM", idPdm); } if (typeOfSpigot == null) { sqlParameter.AddWithValue("@Type", DBNull.Value); } else { sqlParameter.AddWithValue("@Type", typeOfSpigot); } if (height == null) { sqlParameter.AddWithValue("@Hight", DBNull.Value); } else { sqlParameter.AddWithValue("@Hight", height); } if (width == null) { sqlParameter.AddWithValue("@Width", DBNull.Value); } else { sqlParameter.AddWithValue("@Width", width); } sqlCommand.ExecuteNonQuery(); } catch (Exception exception) { Логгер.Информация("Введите корректные данные! " + exception.Message + $"\nIDPDM - {idPdm} Type - {typeOfSpigot}", null, "", "AddInSqlBaseSpigot"); } finally { con.Close(); } } }