public Model UpdateFrTekla() { Log.set(@"UpdateFrTekla()"); // Elm.Elements = TS.Read(); List <Elm> elements = TS.Read(); new Log(@"Модель = " + TS.ModInfo.ModelName + "\t" + Elm.Elements.Count + " компонентов."); string mod_name = TS.ModInfo.ModelName; string mod_dir = TS.ModInfo.ModelPath; string mod_phase = TS.ModInfo.CurrentPhase.ToString(); Model mod = modelListUpdate(mod_name, mod_dir, TS.MyName, Elm.ElementsMD5(), mod_phase); mod.elements = elements; if (mod.wrToFile) { mod.wrModel(Decl.TSMATCHINFO_RAW); mod.wrModel(Decl.TSMATCHINFO_MODELINFO); ////ElmGr.setGroups(); // Group Elements by Materials and Profile ////ElmMGr.setMgr(); // Additionally group Groups by Material setModel(mod.name); // Load price-list for the model //revision 2016.12.05 Mtch.UseRules(mod); // Search for Model Groups matching Components mod.wrModel(Decl.TSMATCHINFO_REPORT); mod.wrModel(Decl.TSMATCHINFO_SUPPLIERS); saveModel(mod.name); // а теперь запишем в Журнал Моделей обновленную информацию } else { new Log("------- Эта модель уже есть в TSmatch. Ничего не записываем --------"); } Elm.Elements.Clear(); mod.wrToFile = false; Log.exit(); return(mod); } // end update
public Serialized_element(Elm elm) { id = elm.guid; mat = elm.mat; mat_type = elm.mat_type; prf = elm.prf; vol = elm.volume; wgt = elm.weight; lng = elm.length; pr = elm.price; }
public List<Elm> Read(string dir = "", string name = "") { Log.set("TS_OpenAPI.Read"); List<Elm> elements = new List<Elm>(); ModInfo = model.GetInfo(); if (dir != "" && ModInfo.ModelPath != dir || name != "" && ModInfo.ModelName != String.Concat(name, ".db1")) Msg.F("Tekla.Read: Another model loaded, not", name); ModInfo.ModelName = ModInfo.ModelName.Replace(".db1", ""); dicParts = ReadModObj<TSM.Part>(); //20/11/17 ArrayList part_string = new ArrayList() { "MATERIAL", "MATERIAL_TYPE", "PROFILE" }; //20/11/17 ArrayList part_double = new ArrayList() { "LENGTH", "WEIGHT", "VOLUME" }; //20/11/17 ArrayList part_int = new ArrayList(); //20/11/17 Hashtable all_val = new Hashtable(); foreach (var part in dicParts) { Elm elm = new Elm(); elm.mat = part.Value.Material.MaterialString; elm.prf = part.Value.Profile.ProfileString; part.Value.GetReportProperty("LENGTH", ref elm.length); part.Value.GetReportProperty("WEIGHT", ref elm.weight); part.Value.GetReportProperty("VOLUME", ref elm.volume); part.Value.GetReportProperty("MATERIAL_TYPE", ref elm.mat_type); //////////////////double lng = 0, weight = 0, vol = 0; //////////////////var p = part.Value; //////////////////p.GetReportProperty("LENGTH", ref lng); //////////////////p.GetReportProperty("WEIGHT", ref weight); //////////////////p.GetReportProperty("VOLUME", ref vol); //////////////////elm.volume = vol; //////////////////elm.weight = weight; //////////////////elm.length = lng; //20/11/17 part.Value.GetAllReportProperties(part_string, part_double, part_int, ref all_val); //20/11/17 elm.mat = (string)all_val[part_string[0]]; //20/11/17elm.mat_type = (string)all_val[part_string[1]]; //20/11/17 elm.prf = (string)all_val[part_string[2]]; //20/11/17 elm.length = (double)all_val[part_double[0]]; //20/11/17elm.weight = (double)all_val[part_double[1]]; //20/11/17elm.volume = (double)all_val[part_double[2]]; elm.guid = part.Key; elements.Add(elm); } Scale(elements); elements.Sort(); Log.exit(); return elements; } // Read
/// <summary> /// Имитация коллекции элементов из САПР - Dictionary<guid, ElmAttSet> Elements /// </summary> internal Dictionary <string, Elm> IM_Elements() { Dictionary <string, Elm> elements = new Dictionary <string, Elm>(); string mat = "c245", matType = "Steel" , matB = "B20", matBtype = "Concrete"; string prf0 = "1900x1600", prf1 = "l20x5", prf2 = "l25x8"; string id1 = "MyId1", id2 = "MyId2", id3 = "MyId3", id4 = "MyId4", id5 = "MyId5"; elements.Clear(); Elm e1 = new Elm(id1, mat, matType, prf1) , e2 = new Elm(id2, mat, matType, prf1) , e3 = new Elm(id3, mat, matType, prf2) , e4 = new Elm(id4, matB, matBtype, prf0) , e5 = new Elm(id5, matB, matBtype, prf0); elements.Add(e1.guid, e1); elements.Add(e2.guid, e2); elements.Add(e3.guid, e3); elements.Add(e4.guid, e4); elements.Add(e5.guid, e5); Assert.AreEqual(elements.Count, 5); return(elements); }