private static List<string> GetComponentsNamesOnConfiguration(SwAddin _mSwAddin, ModelDoc2 parentModel, int configNumber) { List<string> elems = new List<string>(); OleDbConnection oleDb; if (_mSwAddin.OpenModelDatabase(parentModel, out oleDb)) { using (oleDb) { OleDbCommand cm = new OleDbCommand("SELECT * FROM decors WHERE Number = " + configNumber, oleDb); OleDbDataReader rd = cm.ExecuteReader(); while (rd.Read()) { elems.Add((string)rd["Element"]); } rd.Close(); } } AssemblyDoc pmAssembly = parentModel as AssemblyDoc; if (pmAssembly != null) { var comps = new LinkedList<Component2>(); _mSwAddin.GetComponents(parentModel.IGetActiveConfiguration().IGetRootComponent2(), comps, true, false); foreach (Component2 comp in comps) { ModelDoc2 model = comp.IGetModelDoc(); AssemblyDoc aDoc = model as AssemblyDoc; if (aDoc != null) elems.AddRange(GetComponentsNamesOnConfiguration(_mSwAddin, model, configNumber)); } } return elems; }
private static void CheckMdbForDecors(SwAddin mSwAddin, ModelDoc2 inModel, List<ModelDoc2> list, Component2 comp, List<ModelDoc2> faulsModels) { OleDbConnection oleDb; if (mSwAddin.OpenModelDatabase(inModel, out oleDb)) { var oleSchem = oleDb.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" }); if (oleSchem.Rows.Cast<DataRow>().Any(row => (string)row["TABLE_NAME"] == "decors")) { if (!list.Contains(inModel)) list.Add(inModel); } else { if (faulsModels != null && !faulsModels.Contains(inModel)) faulsModels.Add(inModel); oleDb.Close(); if (comp != null) { comp = comp.GetParent(); if (comp != null && !comp.IsSuppressed()) { inModel = comp.IGetModelDoc(); if (inModel != null && mSwAddin.OpenModelDatabase(inModel, out oleDb) && !list.Contains(inModel)) { oleSchem = oleDb.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" }); if (oleSchem.Rows.Cast<DataRow>().Any(row => (string)row["TABLE_NAME"] == "decors")) { if (!list.Contains(inModel)) list.Add(inModel); } oleDb.Close(); } } } } if (oleDb != null) oleDb.Close(); } }
public static void Actualization(ModelDoc2 model, SwAddin _mSwAddin) { Component2 _swSelectedComponent = model.ConfigurationManager.ActiveConfiguration.GetRootComponent3(true); OleDbCommand cm; OleDbDataReader rd; OleDbConnection oleDb; if (!_mSwAddin.OpenModelDatabase(model, out oleDb)) return; cm = new OleDbCommand("SELECT * FROM faners ORDER BY FanerName ", oleDb); rd = cm.ExecuteReader(); List<Faner> faners = new List<Faner>(); while (rd.Read()) { if (rd["FanerType"] as string != null) { faners.Add(new Faner((string)rd["FanerName"], (string)rd["FanerType"], (string)rd["DecorGroup"])); } else { faners.Add(new Faner((string)rd["FanerName"], string.Empty, (string)rd["DecorGroup"])); } } rd.Close(); Feature feature; foreach (var faner in faners) { string suffix = faner.FanerName.Substring(faner.FanerName.Length - 2, 2); feature = FindEdge(_swSelectedComponent, faner.AxFanerName); if (feature != null) { if (feature.IsSuppressed()) { _mSwAddin.SetModelProperty(model, "Faner" + suffix, "", swCustomInfoType_e.swCustomInfoText, string.Empty, true); _mSwAddin.SetModelProperty(model, "colorFaner" + suffix, "", swCustomInfoType_e.swCustomInfoText, string.Empty, true); } else { string fieldValue = model.GetCustomInfoValue(string.Empty, "Faner" + suffix); if (fieldValue == string.Empty) { string msgText = "Для данной детали: " + model.GetPathName() + " кромка Faner" + suffix + " в модели не соответствует свойствам файла сборки. Данная кромка не будет импортирована в программу Покупки! Чтобы исправить эту ошибку используйте опцию \"MrDoors - Отделка кромки\""; MessageBox.Show(msgText, @"MrDoors", MessageBoxButtons.OK); } } } } }
public static void SetDefault(OleDbConnection oleDb, ModelDoc2 _swSelModel, string colorName, SwAddin _mSwAddin,string fullFileNameColor) { Component2 _swSelectedComponent =_swSelModel.ConfigurationManager.ActiveConfiguration.GetRootComponent3(true); OleDbCommand cm; OleDbDataReader rd; if (!_mSwAddin.OpenModelDatabase(_swSelModel, out oleDb)) return; cm = new OleDbCommand("SELECT * FROM faners ORDER BY FanerName ", oleDb); rd = cm.ExecuteReader(); List<Faner> faners = new List<Faner>(); while (rd.Read()) { if (rd["FanerType"] as string != null) { faners.Add(new Faner((string)rd["FanerName"], (string)rd["FanerType"], (string)rd["DecorGroup"])); } else { faners.Add(new Faner((string)rd["FanerName"], string.Empty, (string)rd["DecorGroup"])); } } rd.Close(); string value = string.Empty; Feature feature,axfeature; foreach (var faner in faners) { string suffix = faner.FanerName.Substring(faner.FanerName.Length - 2, 2); //красим кромку feature = FindEdge(_swSelectedComponent, faner.FanerName); axfeature = FindEdge(_swSelectedComponent, faner.AxFanerName); if (feature != null && axfeature!=null) { if (!feature.IsSuppressed() && !axfeature.IsSuppressed()) { SetDecors(_swSelModel, feature, fullFileNameColor); _mSwAddin.SetModelProperty(_swSelModel, "Faner"+suffix, "",swCustomInfoType_e.swCustomInfoText,faner.DefaultFanerType, true); _mSwAddin.SetModelProperty(_swSelModel, "colorFaner"+suffix, "",swCustomInfoType_e.swCustomInfoText, colorName, true); } } } }
public static string GetCommentFromProperties(string faner11, string faner12, string faner21, string faner22, double angle, SwAddin _mSwAddin, ModelDoc2 model) { bool fan11exist = !string.IsNullOrEmpty(faner11) && faner11 != "Нет"; bool fan12exist = !string.IsNullOrEmpty(faner12) && faner12 != "Нет"; bool fan21exist = !string.IsNullOrEmpty(faner21) && faner21 != "Нет"; bool fan22exist = !string.IsNullOrEmpty(faner22) && faner22 != "Нет"; FanersBools fb = new FanersBools(); if (fan11exist) fb = fb | FanersBools.Faner11; if (fan12exist) fb = fb | FanersBools.Faner12; if (fan21exist) fb = fb | FanersBools.Faner21; if (fan22exist) fb = fb | FanersBools.Faner22; #region comment from fb and angle if (Math.Abs(angle) < 0.00001) { switch (fb) { case FanersBools.Faner11: return "KROMKOY K SEBE"; case FanersBools.Faner12: return "KROMKOY OT SEBYA"; case FanersBools.Faner21: return "KROMKOY OT UPORA"; case FanersBools.Faner22: return "KROMKOY K UPORU"; case FanersBools.Faner21 | FanersBools.Faner22: case FanersBools.Faner12 | FanersBools.Faner11: case FanersBools.Faner11 | FanersBools.Faner12 | FanersBools.Faner21 | FanersBools.Faner22: OleDbCommand cm; OleDbDataReader rd; OleDbConnection oleDb; if (!_mSwAddin.OpenModelDatabase(model, out oleDb)) return "Error DB Access!"; cm = new OleDbCommand("SELECT * FROM decors_conf ORDER BY id ", oleDb); rd = cm.ExecuteReader(); rd.Read(); bool? textureDirection = rd["Texture direction"] as bool?; string retresult; if (textureDirection == null || textureDirection == false) retresult= "VOLOKNA GORIZONTALNO"; else retresult= "VOLOKNA VERTIKALNO"; if (faner11 == "N") { retresult = retresult + ", GOLOY K SEBE"; } return retresult; case FanersBools.Faner11 | FanersBools.Faner22: return "KROMKOY K UPORU & K SEBE"; case FanersBools.Faner11 | FanersBools.Faner21: return "KROMKOY OT UPORA & K SEBE"; case FanersBools.Faner12 | FanersBools.Faner22: return "KROMKOY K UPORU & OT SEBYA"; case FanersBools.Faner21 | FanersBools.Faner12: return "KROMKOY OT UPORA & OT SEBYA"; case FanersBools.Faner11 | FanersBools.Faner22 | FanersBools.Faner12: return "GOLOY OT UPORA"; case FanersBools.Faner11 | FanersBools.Faner12 | FanersBools.Faner21: return "GOLOY K UPORU"; case FanersBools.Faner11 | FanersBools.Faner21 | FanersBools.Faner22: return "GOLOY OT SEBYA"; case FanersBools.Faner12 | FanersBools.Faner21 | FanersBools.Faner22: return "GOLOY K SEBE"; default: return fb.ToString(); } } else if (Math.Abs(angle + 90) < 0.00001 || Math.Abs(angle - 270) < 0.00001)// { switch (fb) { case FanersBools.Faner11: return "KROMKOY OT UPORA"; case FanersBools.Faner12: return "KROMKOY K UPORU"; case FanersBools.Faner21: return "KROMKOY OT SEBYA"; case FanersBools.Faner22: return "KROMKOY K SEBE"; case FanersBools.Faner21 | FanersBools.Faner22: case FanersBools.Faner12 | FanersBools.Faner11: case FanersBools.Faner11 | FanersBools.Faner12 | FanersBools.Faner21 | FanersBools.Faner22: OleDbCommand cm; OleDbDataReader rd; OleDbConnection oleDb; if (!_mSwAddin.OpenModelDatabase(model, out oleDb)) return "Error DB Access!"; cm = new OleDbCommand("SELECT * FROM decors_conf ORDER BY id ", oleDb); rd = cm.ExecuteReader(); rd.Read(); bool? textureDirection = rd["Texture direction"] as bool?; string retresult; if (textureDirection == null || textureDirection == false) retresult= "VOLOKNA VERTIKALNO"; else retresult= "VOLOKNA GORIZONTALNO"; if (faner11 == "N") { retresult = retresult + ", GOLOY K SEBE"; } return retresult; case FanersBools.Faner11 | FanersBools.Faner22: return "KROMKOY OT UPORA & K SEBE"; case FanersBools.Faner11 | FanersBools.Faner21: return "KROMKOY OT UPORA & OT SEBYA"; case FanersBools.Faner12 | FanersBools.Faner22: return "KROMKOY K UPORU & K SEBE"; case FanersBools.Faner21 | FanersBools.Faner12: return "KROMKOY K UPORU & OT SEBYA"; case FanersBools.Faner11 | FanersBools.Faner22 | FanersBools.Faner12: return "GOLOY OT SEBYA"; case FanersBools.Faner11 | FanersBools.Faner12 | FanersBools.Faner21: return "GOLOY K SEBE"; case FanersBools.Faner11 | FanersBools.Faner21 | FanersBools.Faner22: return "GOLOY K UPORU"; case FanersBools.Faner12 | FanersBools.Faner21 | FanersBools.Faner22: return "GOLOY OT UPORA"; default: return fb.ToString(); } } else if (Math.Abs(angle - 180) < 0.00001 || Math.Abs(angle + 180) < 0.00001) { switch (fb) { case FanersBools.Faner11: return "KROMKOY OT SEBYA"; case FanersBools.Faner12: return "KROMKOY K SEBE"; case FanersBools.Faner21: return "KROMKOY K UPORU"; case FanersBools.Faner22: return "KROMKOY OT UPORA"; case FanersBools.Faner21 | FanersBools.Faner22: case FanersBools.Faner12 | FanersBools.Faner11: case FanersBools.Faner11 | FanersBools.Faner12 | FanersBools.Faner21 | FanersBools.Faner22: OleDbCommand cm; OleDbDataReader rd; OleDbConnection oleDb; if (!_mSwAddin.OpenModelDatabase(model, out oleDb)) return "Error DB Access!"; cm = new OleDbCommand("SELECT * FROM decors_conf ORDER BY id ", oleDb); rd = cm.ExecuteReader(); rd.Read(); bool? textureDirection = rd["Texture direction"] as bool?; string retresult; if (textureDirection == null || textureDirection == false) retresult= "VOLOKNA GORIZONTALNO"; else retresult= "VOLOKNA VERTIKALNO"; if (faner11 == "N") { retresult = retresult + ", GOLOY K SEBE"; } return retresult; case FanersBools.Faner11 | FanersBools.Faner22: return "KROMKOY OT UPORA & OT SEBYA"; case FanersBools.Faner11 | FanersBools.Faner21: return "KROMKOY K UPORU & OT SEBYA"; case FanersBools.Faner12 | FanersBools.Faner22: return "KROMKOY OT UPORA & K SEBE"; case FanersBools.Faner21 | FanersBools.Faner12: return "KROMKOY K UPORU & K SEBE"; case FanersBools.Faner11 | FanersBools.Faner22 | FanersBools.Faner12: return "GOLOY K UPORU"; case FanersBools.Faner11 | FanersBools.Faner12 | FanersBools.Faner21: return "GOLOY OT UPORA"; case FanersBools.Faner11 | FanersBools.Faner21 | FanersBools.Faner22: return "GOLOY K SEBE"; case FanersBools.Faner12 | FanersBools.Faner21 | FanersBools.Faner22: return "GOLOY OT SEBYA"; default: return fb.ToString(); } } else if (Math.Abs(angle - 90) < 0.00001) { switch (fb) { case FanersBools.Faner11: return "KROMKOY K UPORU"; case FanersBools.Faner12: return "KROMKOY OT UPORA"; case FanersBools.Faner21: return "KROMKOY K SEBE"; case FanersBools.Faner22: return "KROMKOY OT SEBYA"; case FanersBools.Faner21 | FanersBools.Faner22: case FanersBools.Faner12 | FanersBools.Faner11: case FanersBools.Faner11 | FanersBools.Faner12 | FanersBools.Faner21 | FanersBools.Faner22: OleDbCommand cm; OleDbDataReader rd; OleDbConnection oleDb; if (!_mSwAddin.OpenModelDatabase(model, out oleDb)) return "Error DB Access!"; cm = new OleDbCommand("SELECT * FROM decors_conf ORDER BY id ", oleDb); rd = cm.ExecuteReader(); rd.Read(); bool? textureDirection = rd["Texture direction"] as bool?; string retresult; if (textureDirection == null || textureDirection == false) retresult= "VOLOKNA VERTIKALNO"; else retresult= "VOLOKNA GORIZONTALNO"; if (faner11 == "N") { retresult = retresult + ", GOLOY K SEBE"; } return retresult; case FanersBools.Faner11 | FanersBools.Faner22: return "KROMKOY K UPORU & OT SEBYA"; case FanersBools.Faner11 | FanersBools.Faner21: return "KROMKOY K UPORU & K SEBE"; case FanersBools.Faner12 | FanersBools.Faner22: return "KROMKOY OT UPORA & OT SEBYA"; case FanersBools.Faner21 | FanersBools.Faner12: return "KROMKOY OT UPORA & K SEBE"; case FanersBools.Faner11 | FanersBools.Faner22 | FanersBools.Faner12: return "GOLOY K SEBE"; case FanersBools.Faner11 | FanersBools.Faner12 | FanersBools.Faner21: return "GOLOY OT SEBYA"; case FanersBools.Faner11 | FanersBools.Faner21 | FanersBools.Faner22: return "GOLOY OT UPORA"; case FanersBools.Faner12 | FanersBools.Faner21 | FanersBools.Faner22: return "GOLOY K UPORU"; default: return fb.ToString(); } } else return "angle ne kraten 90"; #endregion }
public static string GetComment(ModelDoc2 model, double angle, SwAddin _mSwAddin) { //Считать по тому, подавлены они физически или нет. Если Есть св-во Faner11 а тела нет или подавлено то записать в свойство пустую строку //если наоборот Тело есть а Faner11 -нет или пустое, то записать туда H или DefaultValue Component2 _swSelectedComponent =model.ConfigurationManager.ActiveConfiguration.GetRootComponent3(true); OleDbCommand cm; OleDbDataReader rd; OleDbConnection oleDb; if (!_mSwAddin.OpenModelDatabase(model, out oleDb)) return "Error DB Access!"; cm = new OleDbCommand("SELECT * FROM faners ORDER BY FanerName ", oleDb); rd = cm.ExecuteReader(); List<Faner> faners = new List<Faner>(); while (rd.Read()) { if (rd["FanerType"] as string != null) { faners.Add(new Faner((string)rd["FanerName"], (string)rd["FanerType"], (string)rd["DecorGroup"])); } else { faners.Add(new Faner((string)rd["FanerName"], string.Empty, (string)rd["DecorGroup"])); } } rd.Close(); FanersBools fb = new FanersBools(); Feature feature; foreach (var faner in faners) { switch (faner.FanerName.Substring(faner.FanerName.Length - 2, 2)) { case "11": feature = FindEdge(_swSelectedComponent, faner.AxFanerName); if (feature != null) { if (!feature.IsSuppressed()) fb = fb | FanersBools.Faner11; } break; case "12": feature = FindEdge(_swSelectedComponent, faner.AxFanerName); if (feature != null) { if (!feature.IsSuppressed()) fb = fb | FanersBools.Faner12; } break; case "21": feature = FindEdge(_swSelectedComponent, faner.AxFanerName); if (feature != null) { if (!feature.IsSuppressed()) fb = fb | FanersBools.Faner21; } break; case "22": feature = FindEdge(_swSelectedComponent, faner.AxFanerName); if (feature != null) { if (!feature.IsSuppressed()) fb = fb | FanersBools.Faner22; } break; } } if (angle == 0) { switch (fb) { case FanersBools.Faner11: return "KROMKOY K SEBE"; case FanersBools.Faner12: return "KROMKOY OT SEBYA"; case FanersBools.Faner21: return "KROMKOY OT UPORA"; case FanersBools.Faner22: return "KROMKOY K UPORU"; case FanersBools.Faner21 | FanersBools.Faner22: case FanersBools.Faner12 | FanersBools.Faner11: case FanersBools.Faner11 | FanersBools.Faner12 | FanersBools.Faner21 | FanersBools.Faner22: cm = new OleDbCommand("SELECT * FROM decors_conf ORDER BY id ", oleDb); rd = cm.ExecuteReader(); rd.Read(); bool? textureDirection = rd["Texture direction"] as bool?; if (textureDirection == null || textureDirection == false) return "VOLOKNA GORIZONTALNO"; else return "VOLOKNA VERTIKALNO"; case FanersBools.Faner11 | FanersBools.Faner22: return "KROMKOY K UPORU & K SEBE"; case FanersBools.Faner11 | FanersBools.Faner21: return "KROMKOY OT UPORA & K SEBE"; case FanersBools.Faner12 | FanersBools.Faner22: return "KROMKOY K UPORU & OT SEBYA"; case FanersBools.Faner21 | FanersBools.Faner12: return "KROMKOY OT UPORA & OT SEBYA"; case FanersBools.Faner11 | FanersBools.Faner22 | FanersBools.Faner12: return "GOLOY OT UPORA"; case FanersBools.Faner11 | FanersBools.Faner12 | FanersBools.Faner21: return "GOLOY K UPORU"; case FanersBools.Faner11 | FanersBools.Faner21 | FanersBools.Faner22: return "GOLOY OT SEBYA"; case FanersBools.Faner12 | FanersBools.Faner21 | FanersBools.Faner22: return "GOLOY K SEBE"; default: return fb.ToString(); } } else return "angle!=0"; }