public async Task <IActionResult> ReportProduct([FromBody] ProductPlaceViewModel model) { if (ModelState.IsValid) { try { //Init product object var newProductPlace = new ProductPlace(); newProductPlace.CreatedDate = DateTime.Now; //Adding new object to database await _context.ProductPlaces.AddAsync(newProductPlace); await _context.SaveChangesAsync(); if (newProductPlace.PlaceId > 0) { return(Ok("הרשומה נקלטה בהצלחה")); } else { return(NotFound()); } } catch (Exception ex) { return(BadRequest(ex)); } } return(BadRequest()); }
/// <summary> /// Вибровставка прямоугольная /// </summary> /// <param name="type">Тип вибровставки: 20, 30</param> /// <param name="width">200-2000</param> /// <param name="height">200-2000</param> /// <returns></returns> public Spigot(string type, string width, string height) { if (!ConvertToInt(new[] { width, height })) { throw new Exception("Недопустимі розміри"); } Type = type; Width = width; Height = height; modelName = null; switch (type) { case "20": modelName = "12-20"; break; case "30": modelName = "12-30"; break; } if (string.IsNullOrEmpty(modelName)) { throw new Exception("Недопустимий тип"); } ModelName = modelName + "-" + width + "-" + height; ModelPath = $@"{destRootFolder}\{DestinationFolder}\{ModelName}"; Place = GetPlace(); }
/// <summary> /// Монтажная рама /// </summary> /// <param name="width">The width </param> /// <param name="lenght">The lenght </param> /// <param name="typeOfMf">The type of mf.</param> /// <param name="frameOffset">The frame offset.</param> /// <param name="material">The material.</param> /// <returns></returns> public MontageFrame(string type, string width, string lenght, string frameOffset, ProductFactory.Material material) { if (!ConvertToInt(new[] { width, lenght })) { throw new Exception("Недопустимі розміри"); } Type = type; Width = width; Lenght = lenght; FrameOffset = frameOffset; Material = material; addMatName = ""; if (material.Value != "1800" & material.Thikness == "2") { addMatName = "HK"; } #region Проверка введенных значений и открытие сборки typeOfMfs = "-0" + type; if (type == "0") { typeOfMfs = ""; } // Тип рымы internalCrossbeam = false; // Погашение внутренней поперечной балки internalLongitudinalBeam = false; // Погашение внутренней продольной балки var frameOffcetStr = ""; switch (type) { case "1": internalCrossbeam = true; break; case "2": internalLongitudinalBeam = true; break; case "3": internalCrossbeam = true; frameOffcetStr = "-" + frameOffset; break; } ModelName = $"10-{material.Thikness}{addMatName}-{width}-{lenght}{typeOfMfs}{frameOffcetStr}.SLDASM"; ModelPath = $@"{destRootFolder}\{DestinationFolder}\{ModelName}"; Place = GetPlace(); }
/// <summary> /// Монтажная рама /// </summary> /// <param name="width">The width </param> /// <param name="lenght">The lenght </param> /// <param name="typeOfMf">The type of mf.</param> /// <param name="frameOffset">The frame offset.</param> /// <param name="material">The material.</param> /// <returns></returns> public MontageFrame(string type, string width, string lenght, string frameOffset, ProductFactory.Material material) { if (!ConvertToInt(new[] { width, lenght })) throw new Exception("Недопустимі розміри"); Type = type; Width = width; Lenght = lenght; FrameOffset = frameOffset; Material = material; addMatName = ""; if (material.Value != "1800" & material.Thikness == "2") { addMatName = "HK"; } #region Проверка введенных значений и открытие сборки typeOfMfs = "-0" + type; if (type == "0") { typeOfMfs = ""; } // Тип рымы internalCrossbeam = false; // Погашение внутренней поперечной балки internalLongitudinalBeam = false; // Погашение внутренней продольной балки var frameOffcetStr = ""; switch (type) { case "1": internalCrossbeam = true; break; case "2": internalLongitudinalBeam = true; break; case "3": internalCrossbeam = true; frameOffcetStr = "-" + frameOffset; break; } ModelName = $"10-{material.Thikness}{addMatName}-{width}-{lenght}{typeOfMfs}{frameOffcetStr}.SLDASM"; ModelPath = $@"{destRootFolder}\{DestinationFolder}\{ModelName}"; Place = GetPlace(); }
public ProductPlace GetPlace() { if (Place != null) return Place; string path; int fileId; int projectId; GetExistingFile(ModelName, out path, out fileId, out projectId); if (string.IsNullOrEmpty(path)) { Place = null; } else { Place = new ProductPlace(path, fileId, projectId); } return Place; }
public Dumper(string typeOfFlange, string width, string height, bool isOutDoor, string[] material = null) { IsOutDoor = isOutDoor; Width = width; Height = height; TypeOfFlange = typeOfFlange; if (!ConvertToInt(new[] { width, height })) return; switch (typeOfFlange) { case "20": modelName = "11-20"; modelDamperPath = TemplateFolder; nameAsm = "11 - Damper"; break; case "30": modelName = "11-30"; modelDamperPath = TemplateFolder; nameAsm = "11-30"; break; default: modelName = "11-20"; modelDamperPath = TemplateFolder; nameAsm = "11 - Damper"; break; } modelType = $"{(material[3] == "AZ" ? "" : "-" + material[3])}{(material[3] == "AZ" ? "" : material[1])}"; drawing = "11-20"; if (modelName == "11-30") { drawing = modelName; } ModelName = modelName + "-" + width + "-" + height + modelType + (isOutDoor == true ? "-O" : ""); ModelPath = $@"{destRootFolder}\{DestinationFolder}\{ModelName}.SLDDRW"; Place = GetPlace(); }
public ProductPlace GetPlace() { if (Place != null) { return(Place); } string path; int fileId; int projectId; GetExistingFile(ModelName, out path, out fileId, out projectId); if (string.IsNullOrEmpty(path)) { Place = null; } else { Place = new ProductPlace(path, fileId, projectId); } return(Place); }
public async Task <IActionResult> AddProductPlace([FromBody] AddProductPlaceViewModel model) { if (ModelState.IsValid) { try { //Init product place entity var newProductPlace = new ProductPlace(); newProductPlace.ProductId = model.ProductId; newProductPlace.Instruction = model.Instruction; newProductPlace.Count = model.Count; newProductPlace.PlaceId = model.PlaceId; newProductPlace.WarehousesTypeId = 1; newProductPlace.CreatedDate = DateTime.Now; //Adding new entity to database await _context.ProductPlaces.AddAsync(newProductPlace); await _context.SaveChangesAsync(); if (newProductPlace.ProductId > 0) { return(Ok(newProductPlace)); } else { return(NotFound()); } } catch (Exception ex) { return(BadRequest(ex)); } } return(BadRequest()); }
public override void Build() { if (Exist) { return; } NewComponents = null; MessageBox.Show(DateTime.Now.Hour.ToString()); var modelMontageFramePath = $@"{sourceRootFolder}{TemplateFolder}\{"10-4"}.SLDASM"; GetLastVersionAsmPdm(modelMontageFramePath, VaultName); GetLastVersionAsmPdm($@"{sourceRootFolder}{TemplateFolder}\10-02-01-4.SLDPRT", VaultName); var swDocMontageFrame = _swApp.OpenDoc6(modelMontageFramePath, (int)swDocumentTypes_e.swDocASSEMBLY, (int)swOpenDocOptions_e.swOpenDocOptions_LoadModel, "00", 0, 0); _swApp.Visible = true; var swAsm = (AssemblyDoc)swDocMontageFrame; swAsm.ResolveAllLightWeightComponents(false); #endregion #region Основные размеры, величины и переменные // Габариты Ширина меньше ширины установки на 20мм Длина по размеру блока var width = Convert.ToDouble(Width); // Поперечные балки var lenght = Convert.ToDouble(Lenght); // Продольная балка var offsetI = Convert.ToDouble(Convert.ToString(Convert.ToDouble(FrameOffset) * 10)); // Смещение поперечной балки if (offsetI > (lenght - 125) * 10) { offsetI = (lenght - 250) * 10; MessageBox.Show("Смещение превышает допустимое значение! Программой установлено - " + (offsetI / 10)); } #region Металл и х-ки гибки // TODO Коэффициенты и радиусы гибов //var sqlBaseData = new SqlBaseData(); //var bendParams = sqlBaseData.BendTable(Material.Thikness); //var bendRadius = Convert.ToDouble(bendParams[0]); //var kFactor = Convert.ToDouble(bendParams[1]); var bendRadius = Convert.ToDouble("1"); var kFactor = Convert.ToDouble("1"); #endregion #endregion #region Изменение размеров элементов и компонентов сборки var thikness = Convert.ToDouble(Material.Thikness) / 1000; bendRadius = bendRadius / 1000; var w = Convert.ToDouble(width) / 1000; var l = Convert.ToDouble(lenght) / 1000; var offset = Convert.ToDouble(offsetI) / 10000; var offsetMirror = Convert.ToDouble(lenght * 10 - offsetI) / 10000; #region 10-02-4 Зеркальная 10-01-4 if (Type == "3") { swDocMontageFrame.Extension.SelectByID2("10-01-01-4-1@10-4", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm = ((AssemblyDoc)(swDocMontageFrame)); swAsm.ReplaceComponents(sourceRootFolder + TemplateFolder + "\\10-02-01-4.SLDPRT", "", false, true); swAsm.ResolveAllLightWeightComponents(false); //Продольная зеркальная балка (Длина установки) swDocMontageFrame.Extension.SelectByID2("D1@Эскиз1@10-02-01-4-1@10-4", "DIMENSION", 0, 0, 00, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D1@Эскиз[email protected]"))).SystemValue = l; // Длина установки 0.8; swDocMontageFrame.Extension.SelectByID2("D3@Эскиз25@10-02-01-4-1@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D3@Эскиз[email protected]"))).SystemValue = offsetMirror; //Смещение поперечной балки от края; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Листовой металл@10-02-01-4-1@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.ActivateSelectedFeature(); swDocMontageFrame.Extension.SelectByID2("D1@Листовой металл@10-02-01-4-1@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D1@Листовой металл@10-02-01-4.Part"))).SystemValue = bendRadius; // Радиус гиба 0.005; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Листовой металл@10-02-01-4-1@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.ActivateSelectedFeature(); swDocMontageFrame.Extension.SelectByID2("D2@Листовой металл@10-02-01-4-1@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D2@Листовой металл@10-01-01-4.Part"))).SystemValue = kFactor; // K-Factor 0.55; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Толщина@Листовой металл@10-02-01-4-1@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("Толщина@Листовой металл@10-02-01-4.Part"))).SystemValue = thikness; // Толщина Листового металла 0.006; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.ClearSelection2(true); } #endregion //swApp.SendMsgToUser(string.Format("Thikness= {0}, BendRadius= {1}, Ширина= {2}, Длина= {3}, ", Thikness * 1000, BendRadius * 1000, Ширина * 1000, Длина * 1000)); //Продольные балки (Длина установки) #region 10-01-4 swDocMontageFrame.Extension.SelectByID2("D1@Эскиз1@10-01-01-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D1@Эскиз[email protected]"))).SystemValue = l; // Длина установки 0.8; swDocMontageFrame.Extension.SelectByID2("D3@Эскиз25@10-01-01-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D3@Эскиз[email protected]"))).SystemValue = offset; //Смещение поперечной балки от края; swDocMontageFrame.EditRebuild3(); //swApp.SendMsgToUser(Offset.ToString()); swDocMontageFrame.Extension.SelectByID2("Листовой металл@10-01-01-4-2@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.ActivateSelectedFeature(); swDocMontageFrame.Extension.SelectByID2("D1@Листовой металл@10-01-01-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D1@Листовой металл@10-01-01-4.Part"))).SystemValue = bendRadius; // Радиус гиба 0.005; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Листовой металл@10-01-01-4-2@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.ActivateSelectedFeature(); swDocMontageFrame.Extension.SelectByID2("D2@Листовой металл@10-01-01-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D2@Листовой металл@10-01-01-4.Part"))).SystemValue = kFactor; // K-Factor 0.55; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Толщина@Листовой металл@10-01-01-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("Толщина@Листовой металл@10-01-01-4.Part"))).SystemValue = thikness; // Толщина Листового металла 0.006; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.ClearSelection2(true); #endregion #region 10-04-4-2 swDocMontageFrame.Extension.SelectByID2("D1@Эскиз1@10-04-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D1@Эскиз[email protected]"))).SystemValue = (l - 0.14); // Длина установки - 140 0.66; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Листовой металл@10-04-4-2@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.ActivateSelectedFeature(); swDocMontageFrame.Extension.SelectByID2("D1@Листовой металл@10-04-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D1@Листовой металл@10-04-4.Part"))).SystemValue = bendRadius; // Радиус гиба 0.005; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Листовой металл@10-04-4-2@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.ActivateSelectedFeature(); swDocMontageFrame.Extension.SelectByID2("D2@Листовой металл@10-04-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D2@Листовой металл@10-04-4.Part"))).SystemValue = kFactor; // K-Factor 0.55; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Толщина@Листовой металл@10-04-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("Толщина@Листовой металл@10-04-4.Part"))).SystemValue = thikness; // Толщина Листового металла 0.006; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.ClearSelection2(true); #endregion //Поперечная балка (Ширина установки) #region 10-03-4 swDocMontageFrame.Extension.SelectByID2("D2@Эскиз1@10-03-01-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D2@Эскиз[email protected]"))).SystemValue = (w - 0.12); // Ширина установки - 20 - 100 0.88; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Листовой металл@10-03-01-4-2@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.ActivateSelectedFeature(); swDocMontageFrame.Extension.SelectByID2("D1@Листовой металл@10-03-01-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D1@Листовой металл@10-03-01-4.Part"))).SystemValue = bendRadius; // Радиус гиба 0.005; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Листовой металл@10-03-01-4-2@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.ActivateSelectedFeature(); swDocMontageFrame.Extension.SelectByID2("D2@Листовой металл@10-03-01-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D2@Листовой металл@10-03-01-4.Part"))).SystemValue = kFactor; // K-Factor 0.55; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Толщина@Листовой металл@10-03-01-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("Толщина@Листовой металл@10-03-01-4.Part"))).SystemValue = thikness; // Толщина Листового металла 0.006; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.ClearSelection2(true); #endregion #endregion #region Удаление поперечной балки if (internalCrossbeam == false) { swDocMontageFrame.Extension.SelectByID2("10-03-01-4-1@10-4", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 11371_gost-39@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 11371_gost-40@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 6402_gost-23@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Hex Nut 5915_gost-19@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Hex Bolt 7805_gost-22@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 11371_gost-41@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 11371_gost-42@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 6402_gost-24@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Hex Nut 5915_gost-20@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Hex Bolt 7805_gost-23@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 11371_gost-43@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 11371_gost-44@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 6402_gost-25@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Hex Nut 5915_gost-21@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Hex Bolt 7805_gost-24@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 11371_gost-45@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 11371_gost-46@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 6402_gost-26@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Hex Nut 5915_gost-22@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Hex Bolt 7805_gost-25@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Hex Bolt 7805_gost-25@10-4", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.EditDelete(); // Удаление ненужных элементов продольной балки const int deleteOption = (int)swDeleteSelectionOptions_e.swDelete_Absorbed + (int)swDeleteSelectionOptions_e.swDelete_Children; swDocMontageFrame.Extension.SelectByID2("Вырез-Вытянуть8@10-01-01-4-2@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.Extension.DeleteSelection2(deleteOption); } #endregion #region Удаление продольной балки // Погашение внутренней продольной балки if (internalLongitudinalBeam == false) { foreach (var s in new[] { "5", "6", "7", "8", "13" }) { swDocMontageFrame.Extension.SelectByID2("Hex Bolt 7805_gost-" + s + "@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.EditDelete(); } foreach (var s in new[] { "6", "7", "8", "9", "37", "38", "39", "40" }) { swDocMontageFrame.Extension.SelectByID2("Washer 6402_gost-" + s + "@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.EditDelete(); } foreach (var s in new[] { "17", "18", "19", "20", "21", "22", "23", "24", "57", "58", "59", "60" }) { swDocMontageFrame.Extension.SelectByID2("Washer 11371_gost-" + s + "@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.EditDelete(); } swDocMontageFrame.Extension.SelectByID2("10-04-4-2@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.EditDelete(); // Удаление ненужных элементов поперечной балки swDocMontageFrame.Extension.SelectByID2("Регулируемая ножка-10@10-4", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.EditDelete(); swDocMontageFrame.Extension.SelectByID2("Регулируемая ножка-11@10-4", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.EditDelete(); foreach (var s in new[] { "10", "11", "40", "41", "42", "43" }) { swDocMontageFrame.Extension.SelectByID2("Hex Nut 5915_gost-" + s + "@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.EditDelete(); } const int deleteOption = (int)swDeleteSelectionOptions_e.swDelete_Absorbed + (int)swDeleteSelectionOptions_e.swDelete_Children; swDocMontageFrame.Extension.SelectByID2("Вырез-Вытянуть5@10-03-01-4-2@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.Extension.DeleteSelection2(deleteOption); swDocMontageFrame.Extension.SelectByID2("Вырез-Вытянуть4@10-03-01-4-2@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.Extension.DeleteSelection2(deleteOption); } #endregion #region Сохранение элементов и сборки, а также применение материалов #region Детали //Продольные балки (Длина установки) #region 10-01-01-4 - Деталь _swApp.IActivateDoc2("10-01-01-4", false, 0); IModelDoc2 swPartDoc = _swApp.IActiveDoc2; switch (Type) { //case "2": case "0": typeOfMfs = ""; break; case "3": case "2": case "1": typeOfMfs = "-0" + Type; break; } var newPartName = string.Format("10-01-01-{0}{4}-{1}{2}{3}.SLDPRT", Material.Thikness, lenght, FrameOffset, typeOfMfs, addMatName); var newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; if (File.Exists(newPartPath)) { swDocMontageFrame = ((ModelDoc2)(_swApp.ActivateDoc2("10-4.SLDASM", true, 0))); swDocMontageFrame.Extension.SelectByID2("10-01-01-4-2@10-4", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("10-01-01-4.SLDPRT"); } else { swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); AddMaterial(Material, newPartPath); ComponentToAdd(newPartPath); _swApp.CloseDoc(newPartName); } #endregion // #region 10-02-01-4 - Деталь Зеркальная 10-01-01-4 if (Type == "3") { _swApp.IActivateDoc2("10-02-01-4", false, 0); swPartDoc = _swApp.IActiveDoc2; switch (Type) { case "2": case "0": typeOfMfs = ""; break; case "3": case "1": typeOfMfs = "-0" + Type; break; } newPartName = string.Format("10-02-01-{0}{4}-{1}{2}{3}.SLDPRT", Material.Thikness, lenght, FrameOffset, typeOfMfs, addMatName); newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; if (File.Exists(newPartPath)) { swDocMontageFrame = ((ModelDoc2)(_swApp.ActivateDoc2("10-4.SLDASM", true, 0))); swDocMontageFrame.Extension.SelectByID2("10-02-01-4-1@10-4", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", false, true); _swApp.CloseDoc("10-02-01-4.SLDPRT"); } else { swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); AddMaterial(Material, newPartPath); _swApp.CloseDoc(newPartName); ComponentToAdd(newPartName); } #endregion #region 10-04-4 - Деталь if (internalLongitudinalBeam) { _swApp.IActivateDoc2("10-04-4", false, 0); swPartDoc = ((IModelDoc2)(_swApp.ActiveDoc)); newPartName = string.Format("10-04-{0}{2}-{1}.SLDPRT", Material.Thikness, (lenght - 140), addMatName); newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; if (File.Exists(newPartPath)) { swDocMontageFrame = ((ModelDoc2)(_swApp.ActivateDoc2("10-4.SLDASM", true, 0))); swDocMontageFrame.Extension.SelectByID2("10-04-4-2@10-4", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("10-04-4.SLDPRT"); } else { swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); AddMaterial(Material, newPartPath); _swApp.CloseDoc(newPartName); ComponentToAdd(newPartPath); } } else { _swApp.CloseDoc("10-04-4.SLDPRT"); } #endregion //Поперечная балка (Ширина установки) #region 10-03-01-4 - Деталь _swApp.IActivateDoc2("10-03-01-4", false, 0); swPartDoc = ((IModelDoc2)(_swApp.ActiveDoc)); switch (Type) { case "3": case "2": typeOfMfs = "-0" + Type; break; case "1": case "0": typeOfMfs = ""; break; } newPartName = string.Format("10-03-01-{0}{3}-{1}{2}.SLDPRT", Material.Thikness, (width - 120), typeOfMfs, addMatName); newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; var newPrt0202 = string.Format("10-02-01-{0}{3}-{1}{2}.SLDPRT", Material.Thikness, (width - 120), typeOfMfs, addMatName); newPrt0202 = $@"{destRootFolder}\{DestinationFolder}\{newPrt0202}"; if (File.Exists(newPartPath)) { swDocMontageFrame = ((ModelDoc2)(_swApp.ActivateDoc2("10-4.SLDASM", true, 0))); swDocMontageFrame.Extension.SelectByID2("10-03-01-4-2@10-4", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("10-03-01-4.SLDPRT"); } else { swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); AddMaterial(Material, newPartPath); if (Type == "2") { swPartDoc.Extension.SelectByID2("D1@Эскиз28@" + Path.GetFileNameWithoutExtension(newPrt0202) + ".SLDPRT", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swPartDoc.Parameter("D1@Эскиз28"))).SystemValue = -0.05; swPartDoc.EditRebuild3(); swPartDoc.SaveAs2(newPrt0202, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); AddMaterial(Material, newPrt0202); _swApp.CloseDoc(newPrt0202); ComponentToAdd(newPrt0202); } _swApp.CloseDoc(newPartName); } #endregion #endregion _swApp.IActivateDoc2("10-4.SLDASM", false, 0); swDocMontageFrame = ((ModelDoc2)(_swApp.ActiveDoc)); GabaritsForPaintingCamera(swDocMontageFrame); swDocMontageFrame.ForceRebuild3(true); swDocMontageFrame.SaveAs2(ModelPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); ComponentToAdd(ModelPath); #endregion _swApp.CloseDoc(ModelPath); _swApp = null; List <VaultSystem.VentsCadFile> newFilesList; VaultSystem.CheckInOutPdmNew(NewComponents, true, out newFilesList); #region Export To XML foreach (var newComponent in NewComponents) { // ExportXmlSql.Export(newComponent.FullName); } #endregion #region //var drawing = "12-00"; //if (modelName == "12-30") //{ // drawing = modelName; //} //Dimension myDimension; //var modelSpigotDrw = $@"{sourceRootFolder}{TemplateFolder}\{drawing}.SLDDRW"; //GetLastVersionAsmPdm(modelSpigotDrw, VaultName); //if (!InitializeSw(true)) return; //var swDrwSpigot = _swApp.OpenDoc6(modelSpigotDrw, (int)swDocumentTypes_e.swDocDRAWING, // (int)swOpenDocOptions_e.swOpenDocOptions_LoadModel, "", 0, 0); //if (swDrwSpigot == null) return; //ModelDoc2 swDoc = _swApp.ActivateDoc2("12-00", false, 0); //var swAsm = (AssemblyDoc)swDoc; //swAsm.ResolveAllLightWeightComponents(false); //switch (modelName) //{ // case "12-20": // DelEquations(5, swDoc); // DelEquations(4, swDoc); // DelEquations(3, swDoc); // break; // case "12-30": // DelEquations(0, swDoc); // DelEquations(0, swDoc); // DelEquations(0, swDoc); // break; //} //swDoc.ForceRebuild3(true); //string newPartName; //string newPartPath; //IModelDoc2 swPartDoc; //#region Удаление ненужного //string[] itemsToDelete = null; //switch (Type) //{ // case "20": // itemsToDelete = new[] { "12-30-001-1", "12-30-001-2", "12-30-002-1", "12-30-002-2", // "ВНС-96.61.002-1", "ВНС-96.61.002-2", "ВНС-96.61.002-3", "ВНС-96.61.002-4", // "ВНС-96.61.002-5", "ВНС-96.61.002-6", "ВНС-96.61.002-7", "ВНС-96.61.002-8", // "12-30-001-3", "12-30-001-4", "12-30-002-3", "12-30-002-4", // "12-003-2", "Клей-2" }; // break; // case "30": // itemsToDelete = new[] { "12-20-001-1", "12-20-001-2", "12-20-002-1", "12-20-002-2", // "ВНС-96.61.001-1", "ВНС-96.61.001-2", "ВНС-96.61.001-3", "ВНС-96.61.001-4", // "ВНС-96.61.001-5", "ВНС-96.61.001-6", "ВНС-96.61.001-7", "ВНС-96.61.001-8", // "12-20-001-3", "12-20-001-4", "12-20-002-3", "12-20-002-4", // "12-003-1", "Клей-1"}; // break; //} //foreach (var item in itemsToDelete) //{ // DoWithSwDoc(_swApp, CompType.COMPONENT, item, Act.DeletWithOption); //} //DoWithSwDoc(_swApp, CompType.FTRFOLDER, "30", Act.Delete); //DoWithSwDoc(_swApp, CompType.FTRFOLDER, "20", Act.Delete); //#endregion //#region Сохранение и изменение элементов //string path; //int fileId; //int projectId; //var addDimH = 1; //if (modelName == "12-30") //{ // addDimH = 10; //} //var w = (Convert.ToDouble(Width) - 1) / 1000; //var h = Convert.ToDouble((Convert.ToDouble(Height) + addDimH) / 1000); //const double step = 50; //var weldW = Convert.ToDouble((Math.Truncate(Convert.ToDouble(Width) / step) + 1)); //var weldH = Convert.ToDouble((Math.Truncate(Convert.ToDouble(Height) / step) + 1)); //if (modelName == "12-20") //{ // //12-20-001 // _swApp.IActivateDoc2("12-20-001", false, 0); // swPartDoc = _swApp.IActiveDoc2; // newPartName = $"12-20-{Height}.SLDPRT"; // newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; // if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), out path, out fileId, out projectId)) // { // swDoc = ((ModelDoc2)(VentsCad._swApp.ActivateDoc2("12-00.SLDASM", true, 0))); // swDoc.Extension.SelectByID2("12-20-001-1@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0); // swAsm.ReplaceComponents(newPartPath, "", true, true); // _swApp.CloseDoc("12-20-001.SLDPRT"); // } // else // { // swDoc.Extension.SelectByID2("D1@Вытянуть1@12-20-001-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D1@Вытянуть[email protected]"))); // myDimension.SystemValue = h - 0.031; // swDoc.Extension.SelectByID2("D1@Кривая1@12-20-001-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D1@Кривая[email protected]"))); // myDimension.SystemValue = weldH; // swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); // ComponentToAdd(newPartPath); // _swApp.CloseDoc(newPartName); // } // //12-20-002 // _swApp.IActivateDoc2("12-20-002", false, 0); // swPartDoc = _swApp.IActiveDoc2; // newPartName = $"12-20-{Width}.SLDPRT"; // newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; // if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), out path, out fileId, out projectId)) // { // swDoc = ((ModelDoc2)(VentsCad._swApp.ActivateDoc2("12-00.SLDASM", true, 0))); // swDoc.Extension.SelectByID2("12-20-002-1@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0); // swAsm.ReplaceComponents(newPartPath, "", true, true); // _swApp.CloseDoc("12-20-002.SLDPRT"); // } // else // { // swDoc.Extension.SelectByID2("D1@Вытянуть1@12-20-002-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D1@Вытянуть[email protected]"))); // myDimension.SystemValue = w - 0.031; // swDoc.Extension.SelectByID2("D1@Кривая1@12-20-002-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D1@Кривая[email protected]"))); // myDimension.SystemValue = weldW; // swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); // ComponentToAdd(newPartPath); // _swApp.CloseDoc(newPartName); // } // //12-003 // _swApp.IActivateDoc2("12-003", false, 0); // swPartDoc = _swApp.IActiveDoc2; // newPartName = $"12-03-{Width}-{Height}.SLDPRT"; // newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; // if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), out path, out fileId, out projectId)) // { // swDoc = ((ModelDoc2)(VentsCad._swApp.ActivateDoc2("12-00.SLDASM", true, 0))); // swDoc.Extension.SelectByID2("12-003-1@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0); // swAsm.ReplaceComponents(newPartPath, "", true, true); // _swApp.CloseDoc("12-003.SLDPRT"); // } // else // { // swDoc.Extension.SelectByID2("D3@Эскиз1@12-003-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D3@Эскиз[email protected]"))); // myDimension.SystemValue = w; // swDoc.Extension.SelectByID2("D2@Эскиз1@12-003-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D2@Эскиз[email protected]"))); // myDimension.SystemValue = h; // swDoc.EditRebuild3(); // swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); // ComponentToAdd(newPartPath); // _swApp.CloseDoc(newPartName); // } //} //if (modelName == "12-30") //{ // //12-30-001 // _swApp.IActivateDoc2("12-30-001", false, 0); // swPartDoc = _swApp.IActiveDoc2; // newPartName = $"12-30-01-{Height}.SLDPRT"; // newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; // if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), out path, out fileId, out projectId)) // { // swDoc = ((ModelDoc2)(VentsCad._swApp.ActivateDoc2("12-00.SLDASM", true, 0))); // swDoc.Extension.SelectByID2("12-30-001-1@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0); // swAsm.ReplaceComponents(newPartPath, "", true, true); // _swApp.CloseDoc("12-30-001.SLDPRT"); // } // else // { // swDoc.Extension.SelectByID2("D1@Вытянуть1@12-30-001-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D1@Вытянуть[email protected]"))); // myDimension.SystemValue = h - 0.031; // swDoc.Extension.SelectByID2("D1@Кривая1@12-30-001-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D1@Кривая[email protected]"))); // myDimension.SystemValue = weldH; // swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); // ComponentToAdd(newPartPath); // _swApp.CloseDoc(newPartName); // } // //12-30-002 // _swApp.IActivateDoc2("12-30-002", false, 0); // swPartDoc = _swApp.IActiveDoc2; // newPartName = $"12-30-02-{Width}.SLDPRT"; // newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; // if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), out path, out fileId, out projectId)) // { // swDoc = ((ModelDoc2)(VentsCad._swApp.ActivateDoc2("12-00.SLDASM", true, 0))); // swDoc.Extension.SelectByID2("12-30-002-1@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0); // swAsm.ReplaceComponents(newPartPath, "", true, true); // _swApp.CloseDoc("12-30-002.SLDPRT"); // } // else // { // swDoc.Extension.SelectByID2("D1@Вытянуть1@12-30-002-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D1@Вытянуть[email protected]"))); // myDimension.SystemValue = w - 0.031; // swDoc.Extension.SelectByID2("D1@Кривая1@12-30-002-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D1@Кривая[email protected]"))); // myDimension.SystemValue = weldH; // swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); // ComponentToAdd(newPartPath); // _swApp.CloseDoc(newPartName); // } // //12-003 // _swApp.IActivateDoc2("12-003", false, 0); // swPartDoc = _swApp.IActiveDoc2; // newPartName = $"12-03-{Width}-{Height}.SLDPRT"; // newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; // if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), out path, out fileId, out projectId)) // { // swDoc = ((ModelDoc2)(VentsCad._swApp.ActivateDoc2("12-00.SLDASM", true, 0))); // swDoc.Extension.SelectByID2("12-003-2@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0); // swAsm.ReplaceComponents(newPartPath, "", true, true); // _swApp.CloseDoc("12-003.SLDPRT"); // } // else // { // swDoc.Extension.SelectByID2("D3@Эскиз1@12-003-2@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D3@Эскиз[email protected]"))); // myDimension.SystemValue = w; // swDoc.Extension.SelectByID2("D2@Эскиз1@12-003-2@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D2@Эскиз[email protected]"))); // myDimension.SystemValue = h; // swDoc.EditRebuild3(); // swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); // ComponentToAdd(newPartPath); // _swApp.CloseDoc(newPartName); // } //} //#endregion //GabaritsForPaintingCamera(swDoc); //swDoc.ForceRebuild3(true); //swDoc.SaveAs2(ModelPath + ".SLDASM", (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); //_swApp.CloseDoc(ModelName + ".SLDASM"); //swDrwSpigot.Extension.SelectByID2("DRW1", "SHEET", 0, 0, 0, false, 0, null, 0); //var drw = (DrawingDoc)(_swApp.IActivateDoc3(drawing + ".SLDDRW", true, 0)); //drw.ActivateSheet("DRW1"); //var m = 5; //if (Convert.ToInt32(Width) > 500 || Convert.ToInt32(Height) > 500) { m = 10; } //if (Convert.ToInt32(Width) > 850 || Convert.ToInt32(Height) > 850) { m = 15; } //if (Convert.ToInt32(Width) > 1250 || Convert.ToInt32(Height) > 1250) { m = 20; } //drw.SetupSheet5("DRW1", 12, 12, 1, m, true, destRootFolder + @"\Vents-PDM\\Библиотека проектирования\\Templates\\Основные надписи\\A3-A-1.slddrt", 0.42, 0.297, "По умолчанию", false); //var errors = 0; var warnings = 0; //swDrwSpigot.SaveAs4(ModelPath + ".SLDDRW", (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent, ref errors, ref warnings); //ComponentToAdd(new[] { ModelPath + ".SLDDRW", ModelPath + ".SLDASM" }); //_swApp.CloseDoc(ModelPath); //_swApp.ExitApp(); //_swApp = null; //List<VaultSystem.VentsCadFiles> newFilesList; //VaultSystem.CheckInOutPdmNew(NewComponents, true, //DestVaultName, // out newFilesList); //foreach (var item in newFilesList) //{ // if (item.LocalPartFileInfo.ToUpper().Contains(".SLDASM")) // { // AddInSqlBaseSpigot(item.PartName.Remove(item.PartName.LastIndexOf('.')), item.PartIdPdm, // Convert.ToInt32(Type), Convert.ToInt32(Height), Convert.ToInt32(Width)); // } //} //foreach (var newComponent in NewComponents) //{ // PartInfoToXml(newComponent.LocalPartFileInfo); //} #endregion Place = GetPlace(); } }
public override void Build() { if (Exist) return; Dimension myDimension; var modelSpigotDrw = $@"{sourceRootFolder}{TemplateFolder}\{drawing}.SLDDRW"; NewComponents.Clear(); GetLastVersionAsmPdm(modelSpigotDrw, VaultName); if (!InitializeSw(true)) return; var swDrwSpigot = _swApp.OpenDoc6(modelSpigotDrw, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_LoadModel, "", 0, 0); var modelDamperDrw = $@"{destRootFolder}{modelDamperPath}\{drawing}.SLDDRW"; var modelLamel = $@"{sourceRootFolder}{modelDamperPath}\{"11-100"}.SLDDRW"; GetLastVersionAsmPdm(new FileInfo(modelDamperDrw).FullName, VaultName); GetLastVersionAsmPdm(new FileInfo(modelLamel).FullName, VaultName); if (!InitializeSw(true)) return; var swDocDrw = _swApp.OpenDoc6(@modelDamperDrw, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", 0, 0); ModelDoc2 swDoc = _swApp.ActivateDoc2(nameAsm, false, 0); var swAsm = (AssemblyDoc)swDoc; swAsm.ResolveAllLightWeightComponents(false); _swApp.Visible = true; // Габариты var widthD = Convert.ToDouble(Width); var heightD = Convert.ToDouble(Height); // Количество лопастей var countL = (Math.Truncate(heightD / 100)) * 1000; // Шаг заклепок const double step = 140; var rivetW = (Math.Truncate(widthD / step) + 1) * 1000; var rivetH = (Math.Truncate(heightD / step) + 1) * 1000; // Высота уголков var hC = Math.Truncate(7 + 5.02 + (heightD - countL / 10 - 10.04) / 2); // Коэффициенты и радиусы гибов var thiknessStr = material?[1].Replace(".", ",") ?? "0,8"; #region typeOfFlange = "20" if (TypeOfFlange == "20") { if (Convert.ToInt32(countL / 1000) % 2 == 1) //нечетное { swDoc.Extension.SelectByID2("Совпадение5918344", "MATE", 0, 0, 0, true, 0, null, 0); swDoc.Extension.SelectByID2("Совпадение5918345", "MATE", 0, 0, 0, true, 0, null, 0); swDoc.EditSuppress2(); swDoc.Extension.SelectByID2("Совпадение5918355", "MATE", 0, 0, 0, true, 0, null, 0); swDoc.Extension.SelectByID2("Совпадение5918353", "MATE", 0, 0, 0, true, 0, null, 0); swDoc.EditUnsuppress2(); } string newName; string newPartPath; if (IsOutDoor) { swDoc.Extension.SelectByID2("Эскиз1", "SKETCH", 0, 0, 0, false, 0, null, 0); swDoc.EditSuppress2(); swDoc.Extension.SelectByID2("Вырез-Вытянуть10@11-001-7@" + nameAsm, "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Эскиз34@11-001-7@" + nameAsm, "SKETCH", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); #region To Delete swDoc.Extension.SelectByID2("ВНС-901.41.302-1@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Rivet Bralo-130@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Rivet Bralo-131@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Rivet Bralo-129@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Rivet Bralo-128@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Rivet Bralo-127@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Rivet Bralo-126@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); #endregion // 11-005 newName = $"11-05-{Height}-{modelType}"; newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newName}.SLDPRT"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), 1, VaultName)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2(nameAsm + ".SLDASM", true, 0))); swDoc.Extension.SelectByID2("11-005-1@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", false, true); _swApp.CloseDoc("11-005.SLDPRT"); } else { SwPartParamsChangeWithNewName("11-005", $@"{destRootFolder}\{DestinationFolder}\{newName}", new[,] { {"D3@Эскиз1", Convert.ToString(heightD)}, {"D1@Кривая1", Convert.ToString(rivetH)}, {"D1@Кривая1", Convert.ToString(rivetH)}, {"D3@Эскиз37", (Convert.ToInt32(countL / 1000) % 2 == 1) ? "0" : "50"}, {"Толщина@Листовой металл", thiknessStr} }, false, null); AddMaterial(material, newName); ComponentToAdd(newPartPath); } // 11-006 newName = $"11-06-{Height}-{modelType}"; newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newName}.SLDPRT"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), 1, VaultName)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2(nameAsm + ".SLDASM", true, 0))); swDoc.Extension.SelectByID2("11-006-1@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", false, true); _swApp.CloseDoc("11-006.SLDPRT"); } else { SwPartParamsChangeWithNewName("11-006", $@"{destRootFolder}\{DestinationFolder}\{newName}", new[,] { {"D3@Эскиз1", Convert.ToString(heightD)}, {"D1@Кривая1", Convert.ToString(rivetH)}, {"Толщина@Листовой металл", thiknessStr} }, false, null); AddMaterial(material, newName); ComponentToAdd(newPartPath); } } else { swDoc.Extension.SelectByID2("Вырез-Вытянуть11@11-001-7@" + nameAsm, "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Вырез-Вытянуть12@11-001-7@" + nameAsm, "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Эскиз35@11-001-7@" + nameAsm, "SKETCH", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Эскиз36@11-001-7@" + nameAsm, "SKETCH", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Вырез-Вытянуть10@11-003-6@" + nameAsm, "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Вырез-Вытянуть11@11-003-6@" + nameAsm, "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Эскиз34@11-003-6@" + nameAsm, "SKETCH", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Эскиз35@11-003-6@" + nameAsm, "SKETCH", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); #region To Delete swDoc.Extension.SelectByID2("11-005-1@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("11-006-1@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Rivet Bralo-187@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Rivet Bralo-188@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Rivet Bralo-189@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Rivet Bralo-190@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Rivet Bralo-191@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Rivet Bralo-192@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Rivet Bralo-193@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Rivet Bralo-194@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Rivet Bralo-195@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Rivet Bralo-196@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Rivet Bralo-197@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Rivet Bralo-198@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); #endregion } // 11-001 newName = "11-01-" + Height + modelType + (IsOutDoor ? "-O" : ""); newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newName}.SLDPRT"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), 1, VaultName)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2(nameAsm + ".SLDASM", true, 0))); swDoc.Extension.SelectByID2("11-001-7@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", false, true); _swApp.CloseDoc("11-001.SLDPRT"); } else { SwPartParamsChangeWithNewName("11-001", $@"{destRootFolder}\{DestinationFolder}\{newName}", new[,] { {"D2@Эскиз1", Convert.ToString(heightD + 8.04)}, {"D1@Эскиз27", Convert.ToString(countL/10 - 100)}, {"D2@Эскиз27", Convert.ToString(100*Math.Truncate(countL/2000))}, {"D1@Кривая1", Convert.ToString(countL)}, {"D1@Кривая2", Convert.ToString(rivetH)}, {"Толщина@Листовой металл", thiknessStr} }, false, null); AddMaterial(material, newName); ComponentToAdd(newPartPath); } // 11-002 newName = "11-03-" + Width + modelType; newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newName}.SLDPRT"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), 1, VaultName)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2(nameAsm + ".SLDASM", true, 0))); swDoc.Extension.SelectByID2("11-002-4@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("11-002.SLDPRT"); } else { SwPartParamsChangeWithNewName("11-002", $@"{destRootFolder}\{DestinationFolder}\{newName}", new[,] { {"D2@Эскиз1", Convert.ToString(widthD - 3.96)}, {"D1@Кривая1", Convert.ToString(rivetW)}, {"D1@Кривая3", Convert.ToString(rivetH)}, {"Толщина@Листовой металл1", thiknessStr} }, false, null); AddMaterial(material, newName); ComponentToAdd(newPartPath); } // 11-003 newName = "11-02-" + Height + modelType + (IsOutDoor ? "-O" : ""); newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newName}.SLDPRT"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), 1, VaultName)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2(nameAsm + ".SLDASM", true, 0))); swDoc.Extension.SelectByID2("11-003-6@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", false, true); _swApp.CloseDoc("11-003.SLDPRT"); } else { SwPartParamsChangeWithNewName("11-003", $@"{destRootFolder}\{DestinationFolder}\{newName}", new[,] { {"D2@Эскиз1", Convert.ToString(heightD + 8.04)}, {"D1@Эскиз27", Convert.ToString(countL/10 - 100)}, {"D1@Кривая1", Convert.ToString(countL)}, {"D1@Кривая2", Convert.ToString(rivetH)}, {"Толщина@Листовой металл", thiknessStr} }, false, null); AddMaterial(material, newName); ComponentToAdd(newPartPath); } // 11-004 newName = "11-04-" + Width + "-" + hC + modelType; newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newName}.SLDPRT"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), 1, VaultName)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2(nameAsm + ".SLDASM", true, 0))); swDoc.Extension.SelectByID2("11-004-1@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("11-004.SLDPRT"); } else { SwPartParamsChangeWithNewName("11-004", $@"{destRootFolder}\{DestinationFolder}\{newName}", new[,] { {"D2@Эскиз1", Convert.ToString(widthD - 24)}, {"D7@Ребро-кромка1", Convert.ToString(hC)}, {"D1@Кривая1", Convert.ToString(countL)}, {"D1@Кривая5", Convert.ToString(rivetH)}, {"Толщина@Листовой металл1", thiknessStr} }, false, null); AddMaterial(material, newName); ComponentToAdd(newPartPath); } //11-100 Сборка лопасти var newNameAsm = "11-" + Width; var newPartPathAsm = $@"{destRootFolder}{DestinationFolder}\{newNameAsm}.SLDASM"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPathAsm), 0, VaultName)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2(nameAsm + ".SLDASM", true, 0))); swDoc.Extension.SelectByID2("11-100-1@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPathAsm, "", true, true); _swApp.CloseDoc("11-100.SLDASM"); } else { #region 11-101 Профиль лопасти newName = "11-" + (Math.Truncate(widthD - 23)) + "-01" + modelType; newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newName}.SLDPRT"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), 1, VaultName)) { _swApp.IActivateDoc2("10-100", false, 0); swDoc = (ModelDoc2)((IModelDoc2)(_swApp.ActiveDoc)); swDoc.Extension.SelectByID2("11-101-1@11-100", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("11-100.SLDASM"); } else { _swApp.IActivateDoc2("10-100", false, 0); swDoc = (ModelDoc2)((IModelDoc2)(_swApp.ActiveDoc)); swDoc.Extension.SelectByID2("D1@Вытянуть1@11-101-1@11-100", "DIMENSION", 0, 0, 0, false, 0, null, 0); myDimension = ((Dimension)(swDoc.Parameter("D1@Вытянуть[email protected]"))); myDimension.SystemValue = (widthD - 23) / 1000; _swApp.ActivateDoc2("11-101", false, 0); swDoc = ((ModelDoc2)(_swApp.ActiveDoc)); swDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); _swApp.CloseDoc(newName); ComponentToAdd(newPartPath); } #endregion _swApp.ActivateDoc2("11-100", false, 0); swDoc = ((ModelDoc2)(_swApp.ActiveDoc)); swDoc.ForceRebuild3(false); var docDrw100 = _swApp.OpenDoc6(modelLamel, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", 0, 0); swDoc.SaveAs2(newPartPathAsm, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); _swApp.CloseDoc(newNameAsm); docDrw100.ForceRebuild3(false); var drwNewName = $@"{destRootFolder}\{DestinationFolder}\{newNameAsm}.SLDDRW"; docDrw100.SaveAs2(drwNewName, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); _swApp.CloseDoc(Path.GetFileNameWithoutExtension(new FileInfo(drwNewName).FullName) + " - DRW1"); ComponentToAdd(new[] { newPartPath, drwNewName }); } } #endregion #region typeOfFlange = "30" if (TypeOfFlange == "30") { string newName; string newPartPath; if (IsOutDoor) { swDoc.Extension.SelectByID2("Вырез-Вытянуть7@11-30-002-1@" + nameAsm, "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Эскиз27@11-30-002-1@" + nameAsm, "SKETCH", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); var itemsToDelete = new[] { "ВНС-902.49.283-1", "Rivet Bralo-314", "Rivet Bralo-315", "Rivet Bralo-316", "Rivet Bralo-317", "Rivet Bralo-318", "Rivet Bralo-319", "Rivet Bralo-320", "Rivet Bralo-321" }; foreach (var item in itemsToDelete) { DoWithSwDoc(_swApp, CompType.COMPONENT, item, Act.Delete); } #region to delete //swDoc.Extension.SelectByID2("ВНС-902.49.283-1@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); //swDoc.Extension.SelectByID2("Rivet Bralo-314@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); //swDoc.Extension.SelectByID2("Rivet Bralo-323@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); //swDoc.Extension.SelectByID2("Rivet Bralo-322@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); //swDoc.Extension.SelectByID2("Rivet Bralo-321@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); //swDoc.Extension.SelectByID2("Rivet Bralo-320@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); //swDoc.Extension.SelectByID2("Rivet Bralo-315@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); //swDoc.Extension.SelectByID2("Rivet Bralo-316@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); //swDoc.Extension.SelectByID2("Rivet Bralo-317@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); //swDoc.Extension.SelectByID2("Rivet Bralo-318@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); //swDoc.Extension.SelectByID2("Rivet Bralo-319@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); #endregion // 11-005 newName = "11-05-" + Height + modelType; newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newName}.SLDPRT"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), 1, VaultName)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2(nameAsm + ".SLDASM", true, 0))); swDoc.Extension.SelectByID2("11-005-1@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", false, true); _swApp.CloseDoc("11-005.SLDPRT"); } else { SwPartParamsChangeWithNewName("11-005", $@"{destRootFolder}\{DestinationFolder}\{newName}", new[,] { {"D3@Эскиз1", Convert.ToString(heightD)}, {"D1@Кривая1", Convert.ToString(rivetH)}, {"D1@Кривая1", Convert.ToString(rivetH)}, {"D3@Эскиз37", (Convert.ToInt32(countL / 1000) % 2 == 1) ? "0" : "50"}, {"Толщина@Листовой металл", thiknessStr} }, false, null); AddMaterial(material, newName); ComponentToAdd(newPartPath); } // 11-006 newName = "11-06-" + Height + modelType; newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newName}.SLDPRT"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), 1, VaultName)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2(nameAsm + ".SLDASM", true, 0))); swDoc.Extension.SelectByID2("11-006-1@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", false, true); _swApp.CloseDoc("11-006.SLDPRT"); } else { SwPartParamsChangeWithNewName("11-006", $@"{destRootFolder}\{DestinationFolder}\{newName}", new[,] { {"D3@Эскиз1", Convert.ToString(heightD)}, {"D1@Кривая1", Convert.ToString(rivetH)}, {"Толщина@Листовой металл", thiknessStr} }, false, null); AddMaterial(material, newName); ComponentToAdd(newPartPath); } } else { swDoc.Extension.SelectByID2("Вырез-Вытянуть8@11-30-002-1@" + nameAsm, "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Вырез-Вытянуть9@11-30-002-1@" + nameAsm, "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Эскиз28@11-30-002-1@" + nameAsm, "SKETCH", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Эскиз29@11-30-002-1@" + nameAsm, "SKETCH", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Вырез-Вытянуть7@11-30-004-2@" + nameAsm, "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Вырез-Вытянуть8@11-30-004-2@" + nameAsm, "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Эскиз27@11-30-004-2@" + nameAsm, "SKETCH", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("Эскиз28@11-30-004-2@" + nameAsm, "SKETCH", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); var itemsToDelete = new[] { "11-005-1", "11-006-1", "Rivet Bralo-346", "Rivet Bralo-347", "Rivet Bralo-348", "Rivet Bralo-349", "Rivet Bralo-350", "Rivet Bralo-351", "Rivet Bralo-356", "Rivet Bralo-357", "Rivet Bralo-358", "Rivet Bralo-359", "Rivet Bralo-360", "Rivet Bralo-361", "Rivet Bralo-240", "Rivet Bralo-241", "Rivet Bralo-242", "Rivet Bralo-243", "Rivet Bralo-244", "Rivet Bralo-245", "Rivet Bralo-246", "Rivet Bralo-247", "Rivet Bralo-248", "Rivet Bralo-249", "Rivet Bralo-250", "Rivet Bralo-251",}; foreach (var item in itemsToDelete) { DoWithSwDoc(_swApp, CompType.COMPONENT, item, Act.Delete); } } #region Кратность лопастей if (Convert.ToInt32(countL / 1000) % 2 == 0) //четное { swDoc.Extension.SelectByID2("Совпадение5918344", "MATE", 0, 0, 0, true, 0, null, 0); swDoc.Extension.SelectByID2("Совпадение5918345", "MATE", 0, 0, 0, true, 0, null, 0); swDoc.EditSuppress2(); swDoc.Extension.SelectByID2("Совпадение5918355", "MATE", 0, 0, 0, true, 0, null, 0); swDoc.Extension.SelectByID2("Совпадение5918353", "MATE", 0, 0, 0, true, 0, null, 0); swDoc.EditUnsuppress2(); } #endregion var lp = widthD - 50; // Размер профиля 640,5 при ширине двойного 1400 = var lp2 = lp - 11.6; // Длина линии под заклепки профиля var lProfName = Width; // var lProfNameLength = (widthD - 23) / 1000; #region IsDouble var isdouble = widthD > 1000; if (!isdouble) { var itemsToDelete = new[] { "11-30-100-4", "11-100-13", "11-30-003-1", "11-30-003-4", "ВНС-47.91.001-1", "ВНС-96.61.001-2", "ВНС-96.61.001-3", "ВНС-96.61.001-4", "Rivet Bralo-264", "Rivet Bralo-265", "Rivet Bralo-266", "Rivet Bralo-267", "Rivet Bralo-268", "Rivet Bralo-270", "Rivet Bralo-271", "Rivet Bralo-272", "Rivet Bralo-273", "Rivet Bralo-274", "Rivet Bralo-275", "Rivet Bralo-276", "Rivet Bralo-240", "Rivet Bralo-241", "Rivet Bralo-242", "Rivet Bralo-243", "Rivet Bralo-244", "Rivet Bralo-245", "Rivet Bralo-246", "Rivet Bralo-247", "Rivet Bralo-248", "Rivet Bralo-249", "Rivet Bralo-250", "Rivet Bralo-251",}; foreach (var item in itemsToDelete) { DoWithSwDoc(_swApp, CompType.COMPONENT, item, Act.Delete); } #region To delete //swDoc = ((ModelDoc2)(_swApp.ActiveDoc)); // swDoc.Extension.SelectByID2("11-30-100-4@11-30", "COMPONENT", 0, 0, 0, false, 0, null, 0); // swDoc.Extension.SelectByID2("11-30-100-4@11-30", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); //swDoc.Extension.SelectByID2("11-100-13@11-30", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); //swDoc.Extension.SelectByID2("11-30-003-1@11-30", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); // swDoc.Extension.SelectByID2("11-30-003-4@11-30", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); // swDoc.Extension.SelectByID2("ВНС-47.91.001-1@11-30", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); // swDoc.Extension.SelectByID2("Rivet Bralo-267@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); // swDoc.Extension.SelectByID2("Rivet Bralo-268@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); // swDoc.Extension.SelectByID2("Rivet Bralo-270@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); // swDoc.Extension.SelectByID2("Rivet Bralo-271@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); // swDoc.Extension.SelectByID2("Rivet Bralo-272@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); // swDoc.Extension.SelectByID2("Rivet Bralo-273@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDoc.EditDelete(); // swDoc.Extension.SelectByID2("Rivet Bralo-274@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); // swDoc.Extension.SelectByID2("Rivet Bralo-275@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); // swDoc.Extension.SelectByID2("Rivet Bralo-276@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDoc.EditDelete(); // swDoc.Extension.SelectByID2("Rivet Bralo-264@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); // swDoc.Extension.SelectByID2("Rivet Bralo-265@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); // swDoc.Extension.SelectByID2("Rivet Bralo-266@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDoc.EditDelete(); //swDoc.Extension.SelectByID2("Rivet Bralo-243@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); //swDoc.Extension.SelectByID2("Rivet Bralo-244@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); //swDoc.Extension.SelectByID2("Rivet Bralo-245@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); //swDoc.Extension.SelectByID2("Rivet Bralo-246@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); //swDoc.Extension.SelectByID2("Rivet Bralo-247@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); //swDoc.Extension.SelectByID2("Rivet Bralo-248@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDoc.EditDelete(); //swDoc.Extension.SelectByID2("Rivet Bralo-240@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); //swDoc.Extension.SelectByID2("Rivet Bralo-241@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); //swDoc.Extension.SelectByID2("Rivet Bralo-242@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); //swDoc.Extension.SelectByID2("Rivet Bralo-249@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); //swDoc.Extension.SelectByID2("Rivet Bralo-250@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); //swDoc.Extension.SelectByID2("Rivet Bralo-251@11-30", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDoc.EditDelete(); #endregion swDoc.Extension.SelectByID2("ЗеркальныйКомпонент1", "COMPPATTERN", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); swDoc.Extension.SelectByID2("DerivedCrvPattern3", "COMPPATTERN", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); } if (isdouble) { lp = widthD / 2 - 59.5; lp2 = lp - 11.6; lProfName = Convert.ToString(Math.Truncate(Convert.ToDouble(Convert.ToDouble(Width)) / 2 - 9)); lProfNameLength = (widthD / 2 - 23) / 1000; } #endregion #region Детали // 11-30-001 newName = "11-30-03-" + Width + modelType; newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newName}.SLDPRT"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), 1, VaultName)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2(nameAsm + ".SLDASM", true, 0))); swDoc.Extension.SelectByID2("11-30-001-1@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("11-30-001.SLDPRT"); } else { if (!isdouble) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2("11-30-001.SLDPRT", true, 0))); swDoc.Extension.SelectByID2("Эскиз17", "SKETCH", 0, 0, 0, false, 0, null, 0); swDoc.EditSketch(); swDoc.ClearSelection2(true); swDoc.Extension.SelectByID2("D22@Эскиз[email protected]", "DIMENSION", 0, 0, 0, true, 0, null, 0); swDoc.Extension.SelectByID2("D21@Эскиз[email protected]", "DIMENSION", 0, 0, 0, true, 0, null, 0); swDoc.Extension.SelectByID2("D20@Эскиз[email protected]", "DIMENSION", 0, 0, 0, true, 0, null, 0); swDoc.Extension.SelectByID2("D19@Эскиз[email protected]", "DIMENSION", 0, 0, 0, true, 0, null, 0); swDoc.Extension.SelectByID2("D18@Эскиз[email protected]", "DIMENSION", 0, 0, 0, true, 0, null, 0); swDoc.Extension.SelectByID2("D17@Эскиз[email protected]", "DIMENSION", 0, 0, 0, true, 0, null, 0); swDoc.Extension.SelectByID2("D4@Эскиз[email protected]", "DIMENSION", 0, 0, 0, true, 0, null, 0); swDoc.Extension.SelectByID2("D3@Эскиз[email protected]", "DIMENSION", 0, 0, 0, true, 0, null, 0); swDoc.Extension.SelectByID2("D2@Эскиз[email protected]", "DIMENSION", 0, 0, 0, true, 0, null, 0); swDoc.Extension.SelectByID2("D1@Эскиз[email protected]", "DIMENSION", 0, 0, 0, true, 0, null, 0); swDoc.EditDelete(); swDoc.SketchManager.InsertSketch(true); } SwPartParamsChangeWithNewName("11-30-001", $@"{destRootFolder}\{DestinationFolder}\{newName}", new[,] { {"D2@Эскиз1", Convert.ToString(widthD/2 - 0.8)}, {"D3@Эскиз18", Convert.ToString(lp2)}, {"D1@Кривая1", Convert.ToString((Math.Truncate(lp2/step) + 1)*1000)}, {"Толщина@Листовой металл", thiknessStr} }, false, null); AddMaterial(material, newName); ComponentToAdd(newPartPath); } // 11-30-002 newName = "11-30-01-" + Height + modelType + (IsOutDoor ? "-O" : ""); newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newName}.SLDPRT"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), 1, VaultName)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2(nameAsm + ".SLDASM", true, 0))); swDoc.Extension.SelectByID2("11-30-002-1@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", false, true); _swApp.CloseDoc("11-30-002.SLDPRT"); } else { SwPartParamsChangeWithNewName("11-30-002", $@"{destRootFolder}\{DestinationFolder}\{newName}", new[,] { {"D2@Эскиз1", Convert.ToString(heightD + 10)}, {"D3@Эскиз23", Convert.ToString(countL/10 - 100)}, {"D2@Эскиз23", Convert.ToString(100*Math.Truncate(countL/2000))}, {"D1@Кривая2", Convert.ToString(countL)}, {"D1@Кривая3", Convert.ToString(rivetH)}, {"Толщина@Листовой металл", thiknessStr} }, false, null); AddMaterial(material, newName); ComponentToAdd(newPartPath); } // 11-30-004 newName = "11-30-02-" + Height + modelType + (IsOutDoor ? "-O" : ""); newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newName}.SLDPRT"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), 1, VaultName)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2(nameAsm + ".SLDASM", true, 0))); swDoc.Extension.SelectByID2("11-30-004-2@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", false, true); _swApp.CloseDoc("11-30-004.SLDPRT"); } else { SwPartParamsChangeWithNewName("11-30-004", $@"{destRootFolder}\{DestinationFolder}\{newName}", new[,] { {"D2@Эскиз1", Convert.ToString(heightD + 10)}, {"D3@Эскиз23", Convert.ToString(countL/10 - 100)}, {"D2@Эскиз23", Convert.ToString(100*Math.Truncate(countL/2000))}, {"D1@Кривая2", Convert.ToString(countL)}, {"D1@Кривая5", Convert.ToString(rivetH)}, {"Толщина@Листовой металл", thiknessStr} }, false, null); AddMaterial(material, newName); ComponentToAdd(newPartPath); } // 11-30-003 newName = "11-30-04-" + Math.Truncate(lp) + "-" + hC + modelType; newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newName}.SLDPRT"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), 1, VaultName)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2(nameAsm + ".SLDASM", true, 0))); swDoc.Extension.SelectByID2("11-30-003-2@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("11-30-003.SLDPRT"); } else { SwPartParamsChangeWithNewName("11-30-003", $@"{destRootFolder}\{DestinationFolder}\{newName}", new[,] { {"D2@Эскиз1", Convert.ToString(lp)}, {"D7@Ребро-кромка1", Convert.ToString(hC)}, {"D1@Кривая1", Convert.ToString((Math.Truncate(lp2/step) + 1)*1000)}, {"Толщина@Листовой металл1", thiknessStr} }, false, null); AddMaterial(material, newName); ComponentToAdd(newPartPath); } #endregion #region Сборки #region 11-100 Сборка лопасти var newNameAsm = "11-2-" + lProfName; string newPartPathAsm = $@"{destRootFolder}{DestinationFolder}\{newNameAsm}.SLDASM"; if (isdouble) { if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPathAsm), 0, VaultName)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2(nameAsm + ".SLDASM", true, 0))); swDoc.Extension.SelectByID2("11-100-1@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPathAsm, "", true, true); _swApp.CloseDoc("11-100.SLDASM"); } else { #region 11-101 Профиль лопасти newName = "11-" + (Math.Truncate(lProfNameLength * 1000)) + "-01"; newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newName}.SLDPRT"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), 1, VaultName)) { _swApp.IActivateDoc2("10-100", false, 0); swDoc = (ModelDoc2)((IModelDoc2)(_swApp.ActiveDoc)); swDoc.Extension.SelectByID2("11-101-1@11-100", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("11-100.SLDASM"); } else { _swApp.IActivateDoc2("10-100", false, 0); swDoc = (ModelDoc2)((IModelDoc2)(_swApp.ActiveDoc)); swDoc.Extension.SelectByID2("D1@Вытянуть1@11-101-1@11-100", "DIMENSION", 0, 0, 0, false, 0, null, 0); myDimension = ((Dimension)(swDoc.Parameter("D1@Вытянуть[email protected]"))); myDimension.SystemValue = lProfNameLength; _swApp.ActivateDoc2("11-101", false, 0); swDoc = ((ModelDoc2)(_swApp.ActiveDoc)); swDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); _swApp.CloseDoc(newName); ComponentToAdd(newPartPath); } #endregion } } if (!isdouble) { newNameAsm = "11-" + lProfName; newPartPathAsm = $@"{destRootFolder}{DestinationFolder}\{newNameAsm}.SLDASM"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPathAsm), 0, VaultName)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2(nameAsm + ".SLDASM", true, 0))); swDoc.Extension.SelectByID2("11-100-1@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPathAsm, "", true, true); _swApp.CloseDoc("11-100.SLDASM"); } else { #region 11-101 Профиль лопасти newName = "11-" + (Math.Truncate(lProfNameLength * 1000)) + "-01"; newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newName}.SLDPRT"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), 1, VaultName)) { _swApp.IActivateDoc2("10-100", false, 0); swDoc = (ModelDoc2)((IModelDoc2)(_swApp.ActiveDoc)); swDoc.Extension.SelectByID2("11-101-1@11-100", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("11-100.SLDASM"); } else { _swApp.IActivateDoc2("10-100", false, 0); swDoc = (ModelDoc2)((IModelDoc2)(_swApp.ActiveDoc)); swDoc.Extension.SelectByID2("D1@Вытянуть1@11-101-1@11-100", "DIMENSION", 0, 0, 0, false, 0, null, 0); myDimension = ((Dimension)(swDoc.Parameter("D1@Вытянуть[email protected]"))); myDimension.SystemValue = lProfNameLength; _swApp.ActivateDoc2("11-101", false, 0); swDoc = ((ModelDoc2)(_swApp.ActiveDoc)); swDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); _swApp.CloseDoc(newName); ComponentToAdd(newPartPath); } #endregion } } _swApp.ActivateDoc2("11-100", false, 0); swDoc = ((ModelDoc2)(_swApp.ActiveDoc)); if (isdouble) { swDoc.Extension.SelectByID2("Совпадение76", "MATE", 0, 0, 0, false, 0, null, 0); swDoc.EditSuppress2(); swDoc.Extension.SelectByID2("Совпадение77", "MATE", 0, 0, 0, false, 0, null, 0); swDoc.EditUnsuppress2(); swDoc.Extension.SelectByID2("ВНС-47.91.101-2@11-100", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDoc.EditDelete(); } var docDrw100 = _swApp.OpenDoc6($@"{sourceRootFolder}{modelDamperPath}\{"11-100"}.SLDDRW", (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", 0, 0); swDoc.ForceRebuild3(false); swDoc.SaveAs2(newPartPathAsm, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); _swApp.CloseDoc(newNameAsm); docDrw100.ForceRebuild3(false); var drwNewName = $@"{destRootFolder}\{DestinationFolder}\{newNameAsm}.SLDDRW"; docDrw100.SaveAs2(drwNewName, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); _swApp.CloseDoc(Path.GetFileNameWithoutExtension(new FileInfo(drwNewName).FullName) + " - DRW1"); ComponentToAdd(new[] { newPartPathAsm, drwNewName }); #endregion #region 11-30-100 Сборка Перемычки newNameAsm = "11-30-100-" + Height + modelType; newPartPathAsm = $@"{destRootFolder}{DestinationFolder}\{newNameAsm}.SLDASM"; if (isdouble) { if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPathAsm), 0, VaultName)) { swDoc = ((ModelDoc2)(_swApp.ActivateDoc2(nameAsm + ".SLDASM", true, 0))); swDoc.Extension.SelectByID2("11-30-100-4@" + nameAsm, "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPathAsm, "", true, true); _swApp.CloseDoc("11-30-100.SLDASM"); } else { #region 11-30-101 Профиль перемычки newName = "11-30-101-" + Height + modelType; newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newName}.SLDPRT"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), 0, VaultName)) { _swApp.IActivateDoc2("10-30-100", false, 0); swDoc = (ModelDoc2)((IModelDoc2)(_swApp.ActiveDoc)); swDoc.Extension.SelectByID2("11-30-101-2@11-30-100", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("11-30-100.SLDASM"); } else { SwPartParamsChangeWithNewName("11-30-101", $@"{destRootFolder}\{DestinationFolder}\{newName}", new[,] { {"D2@Эскиз1", Convert.ToString(heightD + 10)}, {"D3@Эскиз19", Convert.ToString(countL/10 - 100)}, {"D1@Кривая1", Convert.ToString(countL)}, {"D1@Кривая2", Convert.ToString(rivetH)}, {"Толщина@Листовой металл", thiknessStr} }, false, null); AddMaterial(material, newName); _swApp.CloseDoc(newName); ComponentToAdd(new FileInfo($@"{destRootFolder}\{DestinationFolder}\{newNameAsm}").FullName); } #endregion _swApp.ActivateDoc2("11-30-100", false, 0); swDoc = ((ModelDoc2)(_swApp.ActiveDoc)); swDoc.ForceRebuild3(true); #region 11-30-102 Профиль перемычки newName = "11-30-102-" + Height + modelType; newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newName}.SLDPRT"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), 0, VaultName)) { _swApp.IActivateDoc2("10-30-100", false, 0); swDoc = (ModelDoc2)((IModelDoc2)(_swApp.ActiveDoc)); swDoc.Extension.SelectByID2("11-30-102-2@11-30-100", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("11-30-100.SLDASM"); } else { SwPartParamsChangeWithNewName("11-30-102", $@"{destRootFolder}\{DestinationFolder}\{newName}", new[,] { {"D2@Эскиз1", Convert.ToString(heightD + 10)}, {"D2@Эскиз19", Convert.ToString(countL/10 - 100)}, {"D1@Кривая2", Convert.ToString(countL)}, {"D1@Кривая1", Convert.ToString(rivetH)}, {"Толщина@Листовой металл", thiknessStr} }, false, null); AddMaterial(material, newName); _swApp.CloseDoc(newName); ComponentToAdd(new FileInfo($@"{destRootFolder}\{DestinationFolder}\{newNameAsm}").FullName); } #endregion _swApp.ActivateDoc2("11-30-100", false, 0); swDoc = ((ModelDoc2)(_swApp.ActiveDoc)); swDoc.ForceRebuild3(false); swDoc.ForceRebuild3(true); swDoc.SaveAs2(newPartPathAsm, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); _swApp.CloseDoc(newNameAsm); #endregion } } #endregion } #endregion swDoc = ((ModelDoc2)(_swApp.ActivateDoc2(nameAsm, true, 0))); GabaritsForPaintingCamera(swDoc); swDoc.EditRebuild3(); swDoc.ForceRebuild3(true); var name = $@"{destRootFolder}\{DestinationFolder}\{ModelName}"; var newAsm = name + ".SLDASM"; var newDrw = name + ".SLDDRW"; swDoc.SaveAs2(newAsm, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); _swApp.CloseDoc(Path.GetFileNameWithoutExtension(new FileInfo(newAsm).FullName)); swDocDrw.Extension.SelectByID2("DRW1", "SHEET", 0, 0, 0, false, 0, null, 0); var drw = (DrawingDoc)(_swApp.IActivateDoc3(drawing + ".SLDDRW", true, 0)); drw.ActivateSheet("DRW1"); //var m = 5; //if (Convert.ToInt32(Width) > 850 || Convert.ToInt32(Height) > 850) { m = 15; } //if (Convert.ToInt32(Width) > 1250 || Convert.ToInt32(Height) > 1250) { m = 20; } //drw.SetupSheet5("DRW1", 12, 12, 1, m, true, Settings.Default.DestinationFolder + @"\\srvkb\SolidWorks Admin\Templates\Основные надписи\A2-A-1.slddrt", 0.42, 0.297, "По умолчанию", false); swDocDrw.SaveAs2(newDrw, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); _swApp.CloseDoc(ModelPath); _swApp.ExitApp(); _swApp = null; ComponentToAdd(new[] { newDrw, newAsm }); List<VaultSystem.VentsCadFile> outList; VaultSystem.CheckInOutPdmNew(NewComponents, true, out outList); //if (unloadXml) //{ // foreach (var newComponent in NewComponents) // { // PartInfoToXml(newComponent.LocalPartFileInfo); // } //} Place = GetPlace(); }
public override void Build() { if (Exist) return; NewComponents = null; MessageBox.Show(DateTime.Now.Hour.ToString()); var modelMontageFramePath = $@"{sourceRootFolder}{TemplateFolder}\{"10-4"}.SLDASM"; GetLastVersionAsmPdm(modelMontageFramePath, VaultName); GetLastVersionAsmPdm($@"{sourceRootFolder}{TemplateFolder}\10-02-01-4.SLDPRT", VaultName); var swDocMontageFrame = _swApp.OpenDoc6(modelMontageFramePath, (int)swDocumentTypes_e.swDocASSEMBLY, (int)swOpenDocOptions_e.swOpenDocOptions_LoadModel, "00", 0, 0); _swApp.Visible = true; var swAsm = (AssemblyDoc)swDocMontageFrame; swAsm.ResolveAllLightWeightComponents(false); #endregion #region Основные размеры, величины и переменные // Габариты Ширина меньше ширины установки на 20мм Длина по размеру блока var width = Convert.ToDouble(Width); // Поперечные балки var lenght = Convert.ToDouble(Lenght); // Продольная балка var offsetI = Convert.ToDouble(Convert.ToString(Convert.ToDouble(FrameOffset) * 10)); // Смещение поперечной балки if (offsetI > (lenght - 125) * 10) { offsetI = (lenght - 250) * 10; MessageBox.Show("Смещение превышает допустимое значение! Программой установлено - " + (offsetI / 10)); } #region Металл и х-ки гибки // TODO Коэффициенты и радиусы гибов //var sqlBaseData = new SqlBaseData(); //var bendParams = sqlBaseData.BendTable(Material.Thikness); //var bendRadius = Convert.ToDouble(bendParams[0]); //var kFactor = Convert.ToDouble(bendParams[1]); var bendRadius = Convert.ToDouble("1"); var kFactor = Convert.ToDouble("1"); #endregion #endregion #region Изменение размеров элементов и компонентов сборки var thikness = Convert.ToDouble(Material.Thikness) / 1000; bendRadius = bendRadius / 1000; var w = Convert.ToDouble(width) / 1000; var l = Convert.ToDouble(lenght) / 1000; var offset = Convert.ToDouble(offsetI) / 10000; var offsetMirror = Convert.ToDouble(lenght * 10 - offsetI) / 10000; #region 10-02-4 Зеркальная 10-01-4 if (Type == "3") { swDocMontageFrame.Extension.SelectByID2("10-01-01-4-1@10-4", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm = ((AssemblyDoc)(swDocMontageFrame)); swAsm.ReplaceComponents(sourceRootFolder + TemplateFolder + "\\10-02-01-4.SLDPRT", "", false, true); swAsm.ResolveAllLightWeightComponents(false); //Продольная зеркальная балка (Длина установки) swDocMontageFrame.Extension.SelectByID2("D1@Эскиз1@10-02-01-4-1@10-4", "DIMENSION", 0, 0, 00, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D1@Эскиз[email protected]"))).SystemValue = l; // Длина установки 0.8; swDocMontageFrame.Extension.SelectByID2("D3@Эскиз25@10-02-01-4-1@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D3@Эскиз[email protected]"))).SystemValue = offsetMirror; //Смещение поперечной балки от края; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Листовой металл@10-02-01-4-1@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.ActivateSelectedFeature(); swDocMontageFrame.Extension.SelectByID2("D1@Листовой металл@10-02-01-4-1@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D1@Листовой металл@10-02-01-4.Part"))).SystemValue = bendRadius; // Радиус гиба 0.005; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Листовой металл@10-02-01-4-1@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.ActivateSelectedFeature(); swDocMontageFrame.Extension.SelectByID2("D2@Листовой металл@10-02-01-4-1@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D2@Листовой металл@10-01-01-4.Part"))).SystemValue = kFactor; // K-Factor 0.55; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Толщина@Листовой металл@10-02-01-4-1@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("Толщина@Листовой металл@10-02-01-4.Part"))).SystemValue = thikness; // Толщина Листового металла 0.006; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.ClearSelection2(true); } #endregion //swApp.SendMsgToUser(string.Format("Thikness= {0}, BendRadius= {1}, Ширина= {2}, Длина= {3}, ", Thikness * 1000, BendRadius * 1000, Ширина * 1000, Длина * 1000)); //Продольные балки (Длина установки) #region 10-01-4 swDocMontageFrame.Extension.SelectByID2("D1@Эскиз1@10-01-01-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D1@Эскиз[email protected]"))).SystemValue = l; // Длина установки 0.8; swDocMontageFrame.Extension.SelectByID2("D3@Эскиз25@10-01-01-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D3@Эскиз[email protected]"))).SystemValue = offset; //Смещение поперечной балки от края; swDocMontageFrame.EditRebuild3(); //swApp.SendMsgToUser(Offset.ToString()); swDocMontageFrame.Extension.SelectByID2("Листовой металл@10-01-01-4-2@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.ActivateSelectedFeature(); swDocMontageFrame.Extension.SelectByID2("D1@Листовой металл@10-01-01-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D1@Листовой металл@10-01-01-4.Part"))).SystemValue = bendRadius; // Радиус гиба 0.005; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Листовой металл@10-01-01-4-2@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.ActivateSelectedFeature(); swDocMontageFrame.Extension.SelectByID2("D2@Листовой металл@10-01-01-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D2@Листовой металл@10-01-01-4.Part"))).SystemValue = kFactor; // K-Factor 0.55; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Толщина@Листовой металл@10-01-01-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("Толщина@Листовой металл@10-01-01-4.Part"))).SystemValue = thikness; // Толщина Листового металла 0.006; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.ClearSelection2(true); #endregion #region 10-04-4-2 swDocMontageFrame.Extension.SelectByID2("D1@Эскиз1@10-04-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D1@Эскиз[email protected]"))).SystemValue = (l - 0.14); // Длина установки - 140 0.66; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Листовой металл@10-04-4-2@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.ActivateSelectedFeature(); swDocMontageFrame.Extension.SelectByID2("D1@Листовой металл@10-04-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D1@Листовой металл@10-04-4.Part"))).SystemValue = bendRadius; // Радиус гиба 0.005; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Листовой металл@10-04-4-2@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.ActivateSelectedFeature(); swDocMontageFrame.Extension.SelectByID2("D2@Листовой металл@10-04-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D2@Листовой металл@10-04-4.Part"))).SystemValue = kFactor; // K-Factor 0.55; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Толщина@Листовой металл@10-04-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("Толщина@Листовой металл@10-04-4.Part"))).SystemValue = thikness; // Толщина Листового металла 0.006; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.ClearSelection2(true); #endregion //Поперечная балка (Ширина установки) #region 10-03-4 swDocMontageFrame.Extension.SelectByID2("D2@Эскиз1@10-03-01-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D2@Эскиз[email protected]"))).SystemValue = (w - 0.12); // Ширина установки - 20 - 100 0.88; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Листовой металл@10-03-01-4-2@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.ActivateSelectedFeature(); swDocMontageFrame.Extension.SelectByID2("D1@Листовой металл@10-03-01-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D1@Листовой металл@10-03-01-4.Part"))).SystemValue = bendRadius; // Радиус гиба 0.005; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Листовой металл@10-03-01-4-2@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.ActivateSelectedFeature(); swDocMontageFrame.Extension.SelectByID2("D2@Листовой металл@10-03-01-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("D2@Листовой металл@10-03-01-4.Part"))).SystemValue = kFactor; // K-Factor 0.55; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.Extension.SelectByID2("Толщина@Листовой металл@10-03-01-4-2@10-4", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swDocMontageFrame.Parameter("Толщина@Листовой металл@10-03-01-4.Part"))).SystemValue = thikness; // Толщина Листового металла 0.006; swDocMontageFrame.EditRebuild3(); swDocMontageFrame.ClearSelection2(true); #endregion #endregion #region Удаление поперечной балки if (internalCrossbeam == false) { swDocMontageFrame.Extension.SelectByID2("10-03-01-4-1@10-4", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 11371_gost-39@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 11371_gost-40@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 6402_gost-23@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Hex Nut 5915_gost-19@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Hex Bolt 7805_gost-22@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 11371_gost-41@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 11371_gost-42@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 6402_gost-24@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Hex Nut 5915_gost-20@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Hex Bolt 7805_gost-23@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 11371_gost-43@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 11371_gost-44@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 6402_gost-25@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Hex Nut 5915_gost-21@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Hex Bolt 7805_gost-24@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 11371_gost-45@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 11371_gost-46@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Washer 6402_gost-26@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Hex Nut 5915_gost-22@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Hex Bolt 7805_gost-25@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.Extension.SelectByID2("Hex Bolt 7805_gost-25@10-4", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.EditDelete(); // Удаление ненужных элементов продольной балки const int deleteOption = (int)swDeleteSelectionOptions_e.swDelete_Absorbed + (int)swDeleteSelectionOptions_e.swDelete_Children; swDocMontageFrame.Extension.SelectByID2("Вырез-Вытянуть8@10-01-01-4-2@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.Extension.DeleteSelection2(deleteOption); } #endregion #region Удаление продольной балки // Погашение внутренней продольной балки if (internalLongitudinalBeam == false) { foreach (var s in new[] { "5", "6", "7", "8", "13" }) { swDocMontageFrame.Extension.SelectByID2("Hex Bolt 7805_gost-" + s + "@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.EditDelete(); } foreach (var s in new[] { "6", "7", "8", "9", "37", "38", "39", "40" }) { swDocMontageFrame.Extension.SelectByID2("Washer 6402_gost-" + s + "@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.EditDelete(); } foreach (var s in new[] { "17", "18", "19", "20", "21", "22", "23", "24", "57", "58", "59", "60" }) { swDocMontageFrame.Extension.SelectByID2("Washer 11371_gost-" + s + "@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.EditDelete(); } swDocMontageFrame.Extension.SelectByID2("10-04-4-2@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.EditDelete(); // Удаление ненужных элементов поперечной балки swDocMontageFrame.Extension.SelectByID2("Регулируемая ножка-10@10-4", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.EditDelete(); swDocMontageFrame.Extension.SelectByID2("Регулируемая ножка-11@10-4", "COMPONENT", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.EditDelete(); foreach (var s in new[] { "10", "11", "40", "41", "42", "43" }) { swDocMontageFrame.Extension.SelectByID2("Hex Nut 5915_gost-" + s + "@10-4", "COMPONENT", 0, 0, 0, true, 0, null, 0); swDocMontageFrame.EditDelete(); } const int deleteOption = (int)swDeleteSelectionOptions_e.swDelete_Absorbed + (int)swDeleteSelectionOptions_e.swDelete_Children; swDocMontageFrame.Extension.SelectByID2("Вырез-Вытянуть5@10-03-01-4-2@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.Extension.DeleteSelection2(deleteOption); swDocMontageFrame.Extension.SelectByID2("Вырез-Вытянуть4@10-03-01-4-2@10-4", "BODYFEATURE", 0, 0, 0, false, 0, null, 0); swDocMontageFrame.Extension.DeleteSelection2(deleteOption); } #endregion #region Сохранение элементов и сборки, а также применение материалов #region Детали //Продольные балки (Длина установки) #region 10-01-01-4 - Деталь _swApp.IActivateDoc2("10-01-01-4", false, 0); IModelDoc2 swPartDoc = _swApp.IActiveDoc2; switch (Type) { //case "2": case "0": typeOfMfs = ""; break; case "3": case "2": case "1": typeOfMfs = "-0" + Type; break; } var newPartName = string.Format("10-01-01-{0}{4}-{1}{2}{3}.SLDPRT", Material.Thikness, lenght, FrameOffset, typeOfMfs, addMatName); var newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; if (File.Exists(newPartPath)) { swDocMontageFrame = ((ModelDoc2)(_swApp.ActivateDoc2("10-4.SLDASM", true, 0))); swDocMontageFrame.Extension.SelectByID2("10-01-01-4-2@10-4", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("10-01-01-4.SLDPRT"); } else { swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); AddMaterial(Material, newPartPath); ComponentToAdd(newPartPath); _swApp.CloseDoc(newPartName); } #endregion // #region 10-02-01-4 - Деталь Зеркальная 10-01-01-4 if (Type == "3") { _swApp.IActivateDoc2("10-02-01-4", false, 0); swPartDoc = _swApp.IActiveDoc2; switch (Type) { case "2": case "0": typeOfMfs = ""; break; case "3": case "1": typeOfMfs = "-0" + Type; break; } newPartName = string.Format("10-02-01-{0}{4}-{1}{2}{3}.SLDPRT", Material.Thikness, lenght, FrameOffset, typeOfMfs, addMatName); newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; if (File.Exists(newPartPath)) { swDocMontageFrame = ((ModelDoc2)(_swApp.ActivateDoc2("10-4.SLDASM", true, 0))); swDocMontageFrame.Extension.SelectByID2("10-02-01-4-1@10-4", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", false, true); _swApp.CloseDoc("10-02-01-4.SLDPRT"); } else { swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); AddMaterial(Material, newPartPath); _swApp.CloseDoc(newPartName); ComponentToAdd(newPartName); } #endregion #region 10-04-4 - Деталь if (internalLongitudinalBeam) { _swApp.IActivateDoc2("10-04-4", false, 0); swPartDoc = ((IModelDoc2)(_swApp.ActiveDoc)); newPartName = string.Format("10-04-{0}{2}-{1}.SLDPRT", Material.Thikness, (lenght - 140), addMatName); newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; if (File.Exists(newPartPath)) { swDocMontageFrame = ((ModelDoc2)(_swApp.ActivateDoc2("10-4.SLDASM", true, 0))); swDocMontageFrame.Extension.SelectByID2("10-04-4-2@10-4", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("10-04-4.SLDPRT"); } else { swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); AddMaterial(Material, newPartPath); _swApp.CloseDoc(newPartName); ComponentToAdd(newPartPath); } } else { _swApp.CloseDoc("10-04-4.SLDPRT"); } #endregion //Поперечная балка (Ширина установки) #region 10-03-01-4 - Деталь _swApp.IActivateDoc2("10-03-01-4", false, 0); swPartDoc = ((IModelDoc2)(_swApp.ActiveDoc)); switch (Type) { case "3": case "2": typeOfMfs = "-0" + Type; break; case "1": case "0": typeOfMfs = ""; break; } newPartName = string.Format("10-03-01-{0}{3}-{1}{2}.SLDPRT", Material.Thikness, (width - 120), typeOfMfs, addMatName); newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; var newPrt0202 = string.Format("10-02-01-{0}{3}-{1}{2}.SLDPRT", Material.Thikness, (width - 120), typeOfMfs, addMatName); newPrt0202 = $@"{destRootFolder}\{DestinationFolder}\{newPrt0202}"; if (File.Exists(newPartPath)) { swDocMontageFrame = ((ModelDoc2)(_swApp.ActivateDoc2("10-4.SLDASM", true, 0))); swDocMontageFrame.Extension.SelectByID2("10-03-01-4-2@10-4", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("10-03-01-4.SLDPRT"); } else { swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); AddMaterial(Material, newPartPath); if (Type == "2") { swPartDoc.Extension.SelectByID2("D1@Эскиз28@" + Path.GetFileNameWithoutExtension(newPrt0202) + ".SLDPRT", "DIMENSION", 0, 0, 0, false, 0, null, 0); ((Dimension)(swPartDoc.Parameter("D1@Эскиз28"))).SystemValue = -0.05; swPartDoc.EditRebuild3(); swPartDoc.SaveAs2(newPrt0202, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); AddMaterial(Material, newPrt0202); _swApp.CloseDoc(newPrt0202); ComponentToAdd(newPrt0202); } _swApp.CloseDoc(newPartName); } #endregion #endregion _swApp.IActivateDoc2("10-4.SLDASM", false, 0); swDocMontageFrame = ((ModelDoc2)(_swApp.ActiveDoc)); GabaritsForPaintingCamera(swDocMontageFrame); swDocMontageFrame.ForceRebuild3(true); swDocMontageFrame.SaveAs2(ModelPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); ComponentToAdd(ModelPath); #endregion _swApp.CloseDoc(ModelPath); _swApp = null; List<VaultSystem.VentsCadFile> newFilesList; VaultSystem.CheckInOutPdmNew(NewComponents, true, out newFilesList); #region Export To XML foreach (var newComponent in NewComponents) { // ExportXmlSql.Export(newComponent.FullName); } #endregion #region //var drawing = "12-00"; //if (modelName == "12-30") //{ // drawing = modelName; //} //Dimension myDimension; //var modelSpigotDrw = $@"{sourceRootFolder}{TemplateFolder}\{drawing}.SLDDRW"; //GetLastVersionAsmPdm(modelSpigotDrw, VaultName); //if (!InitializeSw(true)) return; //var swDrwSpigot = _swApp.OpenDoc6(modelSpigotDrw, (int)swDocumentTypes_e.swDocDRAWING, // (int)swOpenDocOptions_e.swOpenDocOptions_LoadModel, "", 0, 0); //if (swDrwSpigot == null) return; //ModelDoc2 swDoc = _swApp.ActivateDoc2("12-00", false, 0); //var swAsm = (AssemblyDoc)swDoc; //swAsm.ResolveAllLightWeightComponents(false); //switch (modelName) //{ // case "12-20": // DelEquations(5, swDoc); // DelEquations(4, swDoc); // DelEquations(3, swDoc); // break; // case "12-30": // DelEquations(0, swDoc); // DelEquations(0, swDoc); // DelEquations(0, swDoc); // break; //} //swDoc.ForceRebuild3(true); //string newPartName; //string newPartPath; //IModelDoc2 swPartDoc; //#region Удаление ненужного //string[] itemsToDelete = null; //switch (Type) //{ // case "20": // itemsToDelete = new[] { "12-30-001-1", "12-30-001-2", "12-30-002-1", "12-30-002-2", // "ВНС-96.61.002-1", "ВНС-96.61.002-2", "ВНС-96.61.002-3", "ВНС-96.61.002-4", // "ВНС-96.61.002-5", "ВНС-96.61.002-6", "ВНС-96.61.002-7", "ВНС-96.61.002-8", // "12-30-001-3", "12-30-001-4", "12-30-002-3", "12-30-002-4", // "12-003-2", "Клей-2" }; // break; // case "30": // itemsToDelete = new[] { "12-20-001-1", "12-20-001-2", "12-20-002-1", "12-20-002-2", // "ВНС-96.61.001-1", "ВНС-96.61.001-2", "ВНС-96.61.001-3", "ВНС-96.61.001-4", // "ВНС-96.61.001-5", "ВНС-96.61.001-6", "ВНС-96.61.001-7", "ВНС-96.61.001-8", // "12-20-001-3", "12-20-001-4", "12-20-002-3", "12-20-002-4", // "12-003-1", "Клей-1"}; // break; //} //foreach (var item in itemsToDelete) //{ // DoWithSwDoc(_swApp, CompType.COMPONENT, item, Act.DeletWithOption); //} //DoWithSwDoc(_swApp, CompType.FTRFOLDER, "30", Act.Delete); //DoWithSwDoc(_swApp, CompType.FTRFOLDER, "20", Act.Delete); //#endregion //#region Сохранение и изменение элементов //string path; //int fileId; //int projectId; //var addDimH = 1; //if (modelName == "12-30") //{ // addDimH = 10; //} //var w = (Convert.ToDouble(Width) - 1) / 1000; //var h = Convert.ToDouble((Convert.ToDouble(Height) + addDimH) / 1000); //const double step = 50; //var weldW = Convert.ToDouble((Math.Truncate(Convert.ToDouble(Width) / step) + 1)); //var weldH = Convert.ToDouble((Math.Truncate(Convert.ToDouble(Height) / step) + 1)); //if (modelName == "12-20") //{ // //12-20-001 // _swApp.IActivateDoc2("12-20-001", false, 0); // swPartDoc = _swApp.IActiveDoc2; // newPartName = $"12-20-{Height}.SLDPRT"; // newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; // if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), out path, out fileId, out projectId)) // { // swDoc = ((ModelDoc2)(VentsCad._swApp.ActivateDoc2("12-00.SLDASM", true, 0))); // swDoc.Extension.SelectByID2("12-20-001-1@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0); // swAsm.ReplaceComponents(newPartPath, "", true, true); // _swApp.CloseDoc("12-20-001.SLDPRT"); // } // else // { // swDoc.Extension.SelectByID2("D1@Вытянуть1@12-20-001-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D1@Вытянуть[email protected]"))); // myDimension.SystemValue = h - 0.031; // swDoc.Extension.SelectByID2("D1@Кривая1@12-20-001-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D1@Кривая[email protected]"))); // myDimension.SystemValue = weldH; // swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); // ComponentToAdd(newPartPath); // _swApp.CloseDoc(newPartName); // } // //12-20-002 // _swApp.IActivateDoc2("12-20-002", false, 0); // swPartDoc = _swApp.IActiveDoc2; // newPartName = $"12-20-{Width}.SLDPRT"; // newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; // if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), out path, out fileId, out projectId)) // { // swDoc = ((ModelDoc2)(VentsCad._swApp.ActivateDoc2("12-00.SLDASM", true, 0))); // swDoc.Extension.SelectByID2("12-20-002-1@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0); // swAsm.ReplaceComponents(newPartPath, "", true, true); // _swApp.CloseDoc("12-20-002.SLDPRT"); // } // else // { // swDoc.Extension.SelectByID2("D1@Вытянуть1@12-20-002-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D1@Вытянуть[email protected]"))); // myDimension.SystemValue = w - 0.031; // swDoc.Extension.SelectByID2("D1@Кривая1@12-20-002-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D1@Кривая[email protected]"))); // myDimension.SystemValue = weldW; // swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); // ComponentToAdd(newPartPath); // _swApp.CloseDoc(newPartName); // } // //12-003 // _swApp.IActivateDoc2("12-003", false, 0); // swPartDoc = _swApp.IActiveDoc2; // newPartName = $"12-03-{Width}-{Height}.SLDPRT"; // newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; // if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), out path, out fileId, out projectId)) // { // swDoc = ((ModelDoc2)(VentsCad._swApp.ActivateDoc2("12-00.SLDASM", true, 0))); // swDoc.Extension.SelectByID2("12-003-1@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0); // swAsm.ReplaceComponents(newPartPath, "", true, true); // _swApp.CloseDoc("12-003.SLDPRT"); // } // else // { // swDoc.Extension.SelectByID2("D3@Эскиз1@12-003-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D3@Эскиз[email protected]"))); // myDimension.SystemValue = w; // swDoc.Extension.SelectByID2("D2@Эскиз1@12-003-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D2@Эскиз[email protected]"))); // myDimension.SystemValue = h; // swDoc.EditRebuild3(); // swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); // ComponentToAdd(newPartPath); // _swApp.CloseDoc(newPartName); // } //} //if (modelName == "12-30") //{ // //12-30-001 // _swApp.IActivateDoc2("12-30-001", false, 0); // swPartDoc = _swApp.IActiveDoc2; // newPartName = $"12-30-01-{Height}.SLDPRT"; // newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; // if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), out path, out fileId, out projectId)) // { // swDoc = ((ModelDoc2)(VentsCad._swApp.ActivateDoc2("12-00.SLDASM", true, 0))); // swDoc.Extension.SelectByID2("12-30-001-1@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0); // swAsm.ReplaceComponents(newPartPath, "", true, true); // _swApp.CloseDoc("12-30-001.SLDPRT"); // } // else // { // swDoc.Extension.SelectByID2("D1@Вытянуть1@12-30-001-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D1@Вытянуть[email protected]"))); // myDimension.SystemValue = h - 0.031; // swDoc.Extension.SelectByID2("D1@Кривая1@12-30-001-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D1@Кривая[email protected]"))); // myDimension.SystemValue = weldH; // swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); // ComponentToAdd(newPartPath); // _swApp.CloseDoc(newPartName); // } // //12-30-002 // _swApp.IActivateDoc2("12-30-002", false, 0); // swPartDoc = _swApp.IActiveDoc2; // newPartName = $"12-30-02-{Width}.SLDPRT"; // newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; // if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), out path, out fileId, out projectId)) // { // swDoc = ((ModelDoc2)(VentsCad._swApp.ActivateDoc2("12-00.SLDASM", true, 0))); // swDoc.Extension.SelectByID2("12-30-002-1@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0); // swAsm.ReplaceComponents(newPartPath, "", true, true); // _swApp.CloseDoc("12-30-002.SLDPRT"); // } // else // { // swDoc.Extension.SelectByID2("D1@Вытянуть1@12-30-002-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D1@Вытянуть[email protected]"))); // myDimension.SystemValue = w - 0.031; // swDoc.Extension.SelectByID2("D1@Кривая1@12-30-002-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D1@Кривая[email protected]"))); // myDimension.SystemValue = weldH; // swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); // ComponentToAdd(newPartPath); // _swApp.CloseDoc(newPartName); // } // //12-003 // _swApp.IActivateDoc2("12-003", false, 0); // swPartDoc = _swApp.IActiveDoc2; // newPartName = $"12-03-{Width}-{Height}.SLDPRT"; // newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; // if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), out path, out fileId, out projectId)) // { // swDoc = ((ModelDoc2)(VentsCad._swApp.ActivateDoc2("12-00.SLDASM", true, 0))); // swDoc.Extension.SelectByID2("12-003-2@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0); // swAsm.ReplaceComponents(newPartPath, "", true, true); // _swApp.CloseDoc("12-003.SLDPRT"); // } // else // { // swDoc.Extension.SelectByID2("D3@Эскиз1@12-003-2@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D3@Эскиз[email protected]"))); // myDimension.SystemValue = w; // swDoc.Extension.SelectByID2("D2@Эскиз1@12-003-2@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); // myDimension = ((Dimension)(swDoc.Parameter("D2@Эскиз[email protected]"))); // myDimension.SystemValue = h; // swDoc.EditRebuild3(); // swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); // ComponentToAdd(newPartPath); // _swApp.CloseDoc(newPartName); // } //} //#endregion //GabaritsForPaintingCamera(swDoc); //swDoc.ForceRebuild3(true); //swDoc.SaveAs2(ModelPath + ".SLDASM", (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); //_swApp.CloseDoc(ModelName + ".SLDASM"); //swDrwSpigot.Extension.SelectByID2("DRW1", "SHEET", 0, 0, 0, false, 0, null, 0); //var drw = (DrawingDoc)(_swApp.IActivateDoc3(drawing + ".SLDDRW", true, 0)); //drw.ActivateSheet("DRW1"); //var m = 5; //if (Convert.ToInt32(Width) > 500 || Convert.ToInt32(Height) > 500) { m = 10; } //if (Convert.ToInt32(Width) > 850 || Convert.ToInt32(Height) > 850) { m = 15; } //if (Convert.ToInt32(Width) > 1250 || Convert.ToInt32(Height) > 1250) { m = 20; } //drw.SetupSheet5("DRW1", 12, 12, 1, m, true, destRootFolder + @"\Vents-PDM\\Библиотека проектирования\\Templates\\Основные надписи\\A3-A-1.slddrt", 0.42, 0.297, "По умолчанию", false); //var errors = 0; var warnings = 0; //swDrwSpigot.SaveAs4(ModelPath + ".SLDDRW", (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent, ref errors, ref warnings); //ComponentToAdd(new[] { ModelPath + ".SLDDRW", ModelPath + ".SLDASM" }); //_swApp.CloseDoc(ModelPath); //_swApp.ExitApp(); //_swApp = null; //List<VaultSystem.VentsCadFiles> newFilesList; //VaultSystem.CheckInOutPdmNew(NewComponents, true, //DestVaultName, // out newFilesList); //foreach (var item in newFilesList) //{ // if (item.LocalPartFileInfo.ToUpper().Contains(".SLDASM")) // { // AddInSqlBaseSpigot(item.PartName.Remove(item.PartName.LastIndexOf('.')), item.PartIdPdm, // Convert.ToInt32(Type), Convert.ToInt32(Height), Convert.ToInt32(Width)); // } //} //foreach (var newComponent in NewComponents) //{ // PartInfoToXml(newComponent.LocalPartFileInfo); //} #endregion Place = GetPlace(); } }
public override void Build() { if (Exist) { return; } // MessageBox.Show(DateTime.Now.Hour.ToString()); var drawing = "12-00"; if (modelName == "12-30") { drawing = modelName; } Dimension myDimension; var modelSpigotDrw = $@"{sourceRootFolder}{TemplateFolder}\{drawing}.SLDDRW"; GetLastVersionAsmPdm(modelSpigotDrw, VaultName); if (!InitializeSw(true)) { return; } var swDrwSpigot = _swApp.OpenDoc6(modelSpigotDrw, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_LoadModel, "", 0, 0); if (swDrwSpigot == null) { return; } ModelDoc2 swDoc = _swApp.ActivateDoc2("12-00", false, 0); var swAsm = (AssemblyDoc)swDoc; swAsm.ResolveAllLightWeightComponents(false); switch (modelName) { case "12-20": DelEquations(5, swDoc); DelEquations(4, swDoc); DelEquations(3, swDoc); break; case "12-30": DelEquations(0, swDoc); DelEquations(0, swDoc); DelEquations(0, swDoc); break; } swDoc.ForceRebuild3(true); string newPartName; string newPartPath; IModelDoc2 swPartDoc; #region Удаление ненужного string[] itemsToDelete = null; switch (Type) { case "20": itemsToDelete = new[] { "12-30-001-1", "12-30-001-2", "12-30-002-1", "12-30-002-2", "ВНС-96.61.002-1", "ВНС-96.61.002-2", "ВНС-96.61.002-3", "ВНС-96.61.002-4", "ВНС-96.61.002-5", "ВНС-96.61.002-6", "ВНС-96.61.002-7", "ВНС-96.61.002-8", "12-30-001-3", "12-30-001-4", "12-30-002-3", "12-30-002-4", "12-003-2", "Клей-2" }; break; case "30": itemsToDelete = new[] { "12-20-001-1", "12-20-001-2", "12-20-002-1", "12-20-002-2", "ВНС-96.61.001-1", "ВНС-96.61.001-2", "ВНС-96.61.001-3", "ВНС-96.61.001-4", "ВНС-96.61.001-5", "ВНС-96.61.001-6", "ВНС-96.61.001-7", "ВНС-96.61.001-8", "12-20-001-3", "12-20-001-4", "12-20-002-3", "12-20-002-4", "12-003-1", "Клей-1" }; break; } foreach (var item in itemsToDelete) { DoWithSwDoc(_swApp, CompType.COMPONENT, item, Act.DeletWithOption); } DoWithSwDoc(_swApp, CompType.FTRFOLDER, "30", Act.Delete); DoWithSwDoc(_swApp, CompType.FTRFOLDER, "20", Act.Delete); #endregion #region Сохранение и изменение элементов string path; int fileId; int projectId; var addDimH = 1; if (modelName == "12-30") { addDimH = 10; } var w = (Convert.ToDouble(Width) - 1) / 1000; var h = Convert.ToDouble((Convert.ToDouble(Height) + addDimH) / 1000); const double step = 50; var weldW = Convert.ToDouble((Math.Truncate(Convert.ToDouble(Width) / step) + 1)); var weldH = Convert.ToDouble((Math.Truncate(Convert.ToDouble(Height) / step) + 1)); if (modelName == "12-20") { //12-20-001 _swApp.IActivateDoc2("12-20-001", false, 0); swPartDoc = _swApp.IActiveDoc2; newPartName = $"12-20-{Height}.SLDPRT"; newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), out path, out fileId, out projectId)) { swDoc = ((ModelDoc2)(VentsCad._swApp.ActivateDoc2("12-00.SLDASM", true, 0))); swDoc.Extension.SelectByID2("12-20-001-1@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("12-20-001.SLDPRT"); } else { swDoc.Extension.SelectByID2("D1@Вытянуть1@12-20-001-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); myDimension = ((Dimension)(swDoc.Parameter("D1@Вытянуть[email protected]"))); myDimension.SystemValue = h - 0.031; swDoc.Extension.SelectByID2("D1@Кривая1@12-20-001-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); myDimension = ((Dimension)(swDoc.Parameter("D1@Кривая[email protected]"))); myDimension.SystemValue = weldH; swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); ComponentToAdd(newPartPath); _swApp.CloseDoc(newPartName); } //12-20-002 _swApp.IActivateDoc2("12-20-002", false, 0); swPartDoc = _swApp.IActiveDoc2; newPartName = $"12-20-{Width}.SLDPRT"; newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), out path, out fileId, out projectId)) { swDoc = ((ModelDoc2)(VentsCad._swApp.ActivateDoc2("12-00.SLDASM", true, 0))); swDoc.Extension.SelectByID2("12-20-002-1@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("12-20-002.SLDPRT"); } else { swDoc.Extension.SelectByID2("D1@Вытянуть1@12-20-002-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); myDimension = ((Dimension)(swDoc.Parameter("D1@Вытянуть[email protected]"))); myDimension.SystemValue = w - 0.031; swDoc.Extension.SelectByID2("D1@Кривая1@12-20-002-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); myDimension = ((Dimension)(swDoc.Parameter("D1@Кривая[email protected]"))); myDimension.SystemValue = weldW; swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); ComponentToAdd(newPartPath); _swApp.CloseDoc(newPartName); } //12-003 _swApp.IActivateDoc2("12-003", false, 0); swPartDoc = _swApp.IActiveDoc2; newPartName = $"12-03-{Width}-{Height}.SLDPRT"; newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), out path, out fileId, out projectId)) { swDoc = ((ModelDoc2)(VentsCad._swApp.ActivateDoc2("12-00.SLDASM", true, 0))); swDoc.Extension.SelectByID2("12-003-1@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("12-003.SLDPRT"); } else { swDoc.Extension.SelectByID2("D3@Эскиз1@12-003-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); myDimension = ((Dimension)(swDoc.Parameter("D3@Эскиз[email protected]"))); myDimension.SystemValue = w; swDoc.Extension.SelectByID2("D2@Эскиз1@12-003-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); myDimension = ((Dimension)(swDoc.Parameter("D2@Эскиз[email protected]"))); myDimension.SystemValue = h; swDoc.EditRebuild3(); swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); ComponentToAdd(newPartPath); _swApp.CloseDoc(newPartName); } } if (modelName == "12-30") { //12-30-001 _swApp.IActivateDoc2("12-30-001", false, 0); swPartDoc = _swApp.IActiveDoc2; newPartName = $"12-30-01-{Height}.SLDPRT"; newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), out path, out fileId, out projectId)) { swDoc = ((ModelDoc2)(VentsCad._swApp.ActivateDoc2("12-00.SLDASM", true, 0))); swDoc.Extension.SelectByID2("12-30-001-1@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("12-30-001.SLDPRT"); } else { swDoc.Extension.SelectByID2("D1@Вытянуть1@12-30-001-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); myDimension = ((Dimension)(swDoc.Parameter("D1@Вытянуть[email protected]"))); myDimension.SystemValue = h - 0.031; swDoc.Extension.SelectByID2("D1@Кривая1@12-30-001-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); myDimension = ((Dimension)(swDoc.Parameter("D1@Кривая[email protected]"))); myDimension.SystemValue = weldH; swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); ComponentToAdd(newPartPath); _swApp.CloseDoc(newPartName); } //12-30-002 _swApp.IActivateDoc2("12-30-002", false, 0); swPartDoc = _swApp.IActiveDoc2; newPartName = $"12-30-02-{Width}.SLDPRT"; newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), out path, out fileId, out projectId)) { swDoc = ((ModelDoc2)(VentsCad._swApp.ActivateDoc2("12-00.SLDASM", true, 0))); swDoc.Extension.SelectByID2("12-30-002-1@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("12-30-002.SLDPRT"); } else { swDoc.Extension.SelectByID2("D1@Вытянуть1@12-30-002-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); myDimension = ((Dimension)(swDoc.Parameter("D1@Вытянуть[email protected]"))); myDimension.SystemValue = w - 0.031; swDoc.Extension.SelectByID2("D1@Кривая1@12-30-002-1@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); myDimension = ((Dimension)(swDoc.Parameter("D1@Кривая[email protected]"))); myDimension.SystemValue = weldH; swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); ComponentToAdd(newPartPath); _swApp.CloseDoc(newPartName); } //12-003 _swApp.IActivateDoc2("12-003", false, 0); swPartDoc = _swApp.IActiveDoc2; newPartName = $"12-03-{Width}-{Height}.SLDPRT"; newPartPath = $@"{destRootFolder}\{DestinationFolder}\{newPartName}"; if (GetExistingFile(Path.GetFileNameWithoutExtension(newPartPath), out path, out fileId, out projectId)) { swDoc = ((ModelDoc2)(VentsCad._swApp.ActivateDoc2("12-00.SLDASM", true, 0))); swDoc.Extension.SelectByID2("12-003-2@12-00", "COMPONENT", 0, 0, 0, false, 0, null, 0); swAsm.ReplaceComponents(newPartPath, "", true, true); _swApp.CloseDoc("12-003.SLDPRT"); } else { swDoc.Extension.SelectByID2("D3@Эскиз1@12-003-2@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); myDimension = ((Dimension)(swDoc.Parameter("D3@Эскиз[email protected]"))); myDimension.SystemValue = w; swDoc.Extension.SelectByID2("D2@Эскиз1@12-003-2@12-00", "DIMENSION", 0, 0, 0, false, 0, null, 0); myDimension = ((Dimension)(swDoc.Parameter("D2@Эскиз[email protected]"))); myDimension.SystemValue = h; swDoc.EditRebuild3(); swPartDoc.SaveAs2(newPartPath, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); ComponentToAdd(newPartPath); _swApp.CloseDoc(newPartName); } } #endregion GabaritsForPaintingCamera(swDoc); swDoc.ForceRebuild3(true); swDoc.SaveAs2(ModelPath + ".SLDASM", (int)swSaveAsVersion_e.swSaveAsCurrentVersion, false, true); _swApp.CloseDoc(ModelName + ".SLDASM"); swDrwSpigot.Extension.SelectByID2("DRW1", "SHEET", 0, 0, 0, false, 0, null, 0); var drw = (DrawingDoc)(_swApp.IActivateDoc3(drawing + ".SLDDRW", true, 0)); drw.ActivateSheet("DRW1"); var m = 5; if (Convert.ToInt32(Width) > 500 || Convert.ToInt32(Height) > 500) { m = 10; } if (Convert.ToInt32(Width) > 850 || Convert.ToInt32(Height) > 850) { m = 15; } if (Convert.ToInt32(Width) > 1250 || Convert.ToInt32(Height) > 1250) { m = 20; } drw.SetupSheet5("DRW1", 12, 12, 1, m, true, destRootFolder + @"\Vents-PDM\\Библиотека проектирования\\Templates\\Основные надписи\\A3-A-1.slddrt", 0.42, 0.297, "По умолчанию", false); var errors = 0; var warnings = 0; swDrwSpigot.SaveAs4(ModelPath + ".SLDDRW", (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent, ref errors, ref warnings); ComponentToAdd(new[] { ModelPath + ".SLDDRW", ModelPath + ".SLDASM" }); _swApp.CloseDoc(ModelPath); _swApp.ExitApp(); _swApp = null; List <VaultSystem.VentsCadFile> newFilesList; VaultSystem.CheckInOutPdmNew(NewComponents, true, //DestVaultName, out newFilesList); foreach (var item in newFilesList) { if (item.LocalPartFileInfo.ToUpper().Contains(".SLDASM")) { AddInSqlBaseSpigot(item.PartName.Remove(item.PartName.LastIndexOf('.')), item.PartIdPdm, Convert.ToInt32(Type), Convert.ToInt32(Height), Convert.ToInt32(Width)); } } foreach (var newComponent in NewComponents) { PartInfoToXml(newComponent.LocalPartFileInfo); } Place = GetPlace(); }