/// <summary> /// HeghlightElements(List<Elm>elements, color) - change color of elements in list /// </summary> /// <param name="elements"></param> /// <param name="color"></param> public void HighlightElements(Dictionary<string, Elm> els, int color = 1) { Log.set("TS_OpenAPI.HighLightElements"); TSM.ModelObjectSelector selector = model.GetModelObjectSelector(); System.Type[] Types = new System.Type[1]; Types.SetValue(typeof(Part), 0); TSM.ModelObjectEnumerator objectList = selector.GetAllObjectsWithType(Types); int totalCnt = objectList.GetSize(); var colorObjects = new List<ModelObject>(); while (objectList.MoveNext()) { TSM.Part myPart = objectList.Current as TSM.Part; if (myPart != null) { string guid = string.Empty; myPart.GetReportProperty("GUID", ref guid); if (els.ContainsKey(guid)) colorObjects.Add(myPart); } } var _color = new Color(0.0, 0.0, 1.0); ModelObjectVisualization.SetTransparencyForAll(TemporaryTransparency.SEMITRANSPARENT); ModelObjectVisualization.SetTemporaryState(colorObjects, _color); log.Info("\tTotal elements without price = " + colorObjects.Count); Log.exit(); }
public int elementsCount() { Log.set("TS_OpenAPI.elementsCount()"); TSM.ModelObjectSelector selector = model.GetModelObjectSelector(); System.Type[] Types = new System.Type[1]; Types.SetValue(typeof(TSM.Part), 0); TSM.ModelObjectEnumerator objectList = selector.GetAllObjectsWithType(Types); Log.exit(); int totalCnt = objectList.GetSize(); return totalCnt; }
public Tekla() { } // конструктор класса Tekla - пока пустой 6.4.17 public List<Elm> Read(string dir = "", string name = "") { Log.set("TS_OpenAPI.Read"); List<Elm> elements = new List<Elm>(); // 6.4.17 //TSM.Model model = new TSM.Model(); ////////////List<Part> parts = new List<Part>(); 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", ""); TSM.ModelObjectSelector selector = model.GetModelObjectSelector(); System.Type[] Types = new System.Type[1]; Types.SetValue(typeof(Part), 0); TSM.ModelObjectEnumerator objectList = selector.GetAllObjectsWithType(Types); int totalCnt = objectList.GetSize(); var progress = new TSM.Operations.Operation.ProgressBar(); bool displayResult = progress.Display(100, "TSmatch", "Reading model. Pass component records:", "Cancel", " "); int ii = 0; while (objectList.MoveNext()) { TSM.Part myPart = objectList.Current as TSM.Part; if (myPart != null) { ii++; double lng = 0.0; double weight = 0.0; double vol = 0.0; string guid = ""; string mat_type = ""; double price = 0.0; myPart.GetReportProperty("GUID", ref guid); myPart.GetReportProperty("LENGTH", ref lng); myPart.GetReportProperty("WEIGHT", ref weight); myPart.GetReportProperty("VOLUME", ref vol); myPart.GetReportProperty("MATERIAL_TYPE", ref mat_type); lng = Math.Round(lng, 0); //string cut = ""; //myPart.GetReportProperty("CAST_UNIT_TYPE", ref cut); //ModAtr.Add(new AttSet(myPart.Material.MaterialString, // profile, lng, weight, vol)); //21/6/2016 в отладке Elm.Elements.Add(new Elm()); elements.Add(new Elm(guid, myPart.Material.MaterialString, mat_type, myPart.Profile.ProfileString, lng, weight, vol, price)); // !! if (ii % 500 == 0) // progress update every 500th items { if (progress.Canceled()) { // new Log("\n\n======= TSmatch pass model CANCEL!! ======= ii=" + ii); // TSD.Show() break; } progress.SetProgress(ii.ToString(), 100 * ii / totalCnt); } } } //while progress.Close(); Scale(elements); elements.Sort(); Log.exit(); return elements; } // Read