} // Read protected Dictionary<string, T> ReadModObj<T>() where T : ModelObject { var result = new Dictionary<string, T>(); selector = model.GetModelObjectSelector(); Type[] Types = new Type[1]; Types.SetValue(typeof(T), 0); ModelObjectEnumerator objParts = selector.GetAllObjectsWithType(Types); int totalCnt = objParts.GetSize(); var progress = new Operation.ProgressBar(); bool displayResult = progress.Display(100, "TSmatch", "Reading model. Pass component records:", "Cancel", " "); int iProgress = 0; while(objParts.MoveNext()) { T myObj = objParts.Current as T; if (myObj == null) continue; string guid = string.Empty; myObj.GetReportProperty("GUID", ref guid); result.Add(guid, myObj); iProgress++; if (iProgress % 500 == 0) { progress.SetProgress(iProgress.ToString(), 100 * iProgress / totalCnt); if (progress.Canceled()) break; } } progress.Close(); return result; }
/// <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; }
private void connectParts() { List <BoltGroup> boltGroups = new List <BoltGroup>(); Picker picker = new Picker(); Tekla.Structures.Model.UI.ModelObjectSelector selector = new Tekla.Structures.Model.UI.ModelObjectSelector(); ModelObjectEnumerator enumerator = selector.GetSelectedObjects(); foreach (ModelObject modelObject in enumerator) { BoltGroup boltGroup = (BoltGroup)modelObject; boltGroups.Add(boltGroup); } foreach (BoltGroup group in boltGroups) { int partsBoltedBefore; int partsBoltedAfter; do { Solid solid = group.GetSolid(); partsBoltedBefore = group.GetOtherPartsToBolt().Count; Double boltLength = 0.0; Point maximumPoint = solid.MaximumPoint; Point minimumPoint = solid.MinimumPoint; Tekla.Structures.Model.ModelObjectSelector groupSelector = model.GetModelObjectSelector(); ModelObjectEnumerator collidingObjects = groupSelector.GetObjectsByBoundingBox(minimumPoint, maximumPoint); while (collidingObjects.MoveNext()) { Part part = collidingObjects.Current as Part; if (part != null) { group.AddOtherPartToBolt(part); } } group.BoltStandard = "4017-8.8"; group.Modify(); group.GetReportProperty("LENGTH", ref boltLength); if (group.BoltStandard == "4017-8.8" && boltLength % 10 != 0) { group.BoltStandard = "4014-8.8"; } group.Modify(); partsBoltedAfter = group.GetOtherPartsToBolt().Count; group.CutLength = boltLength + 20; } while (partsBoltedBefore != partsBoltedAfter); } model.CommitChanges(); }
public List<Emb> ReadCustomParts() { List<Emb> result = new List<Emb>(); // TSM.Model model = new TSM.Model(); TSM.ModelObjectSelector selector = this.model.GetModelObjectSelector(); System.Type[] Types = new System.Type[1]; Types.SetValue(typeof(Part), 0); TSM.ModelObjectEnumerator objectList = selector.GetAllObjectsWithType(Types); List<Part> parts = new List<Part>(); while (objectList.MoveNext()) { TSM.Part myPart = objectList.Current as TSM.Part; if (myPart == null) continue; if (myPart.Class != "100" && myPart.Class != "101") continue; parts.Add(myPart); if (myPart.Name.Contains("SBKL")) continue; // var project_code = myPart.GetUserProperty("j_fabricator_name", ref vendorName); } return result; }
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
private void button1_Click(object sender, EventArgs e) { Model _model = new Model(); ArrayList Poinlist = new ArrayList(); int condition = 0; ModelInfo _minfo = _model.GetInfo(); string repPath = _minfo.ModelPath + "\\Reports\\BoltPartCheck.xsr"; //StreamWriter sw = new StreamWriter(repPath); //sw.WriteLine("Bolt Part Error's Report.."); //sw.WriteLine("Part ID, Bolt ID"); Tekla.Structures.Model.UI.ModelObjectSelector mos = new Tekla.Structures.Model.UI.ModelObjectSelector(); TransformationPlane currplane = _model.GetWorkPlaneHandler().GetCurrentTransformationPlane(); ModelObjectEnumerator moe = mos.GetSelectedObjects(); Tekla.Structures.Model.ModelObjectSelector mosb = _model.GetModelObjectSelector(); while (moe.MoveNext()) { Beam angle = moe.Current as Beam; if (angle.StartPoint.Z > angle.EndPoint.Z) { condition = 1; } ModelObjectEnumerator anglebolts = angle.GetBolts(); _model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane(angle.GetCoordinateSystem())); angle.Select(); while (anglebolts.MoveNext()) { BoltArray Bolt = anglebolts.Current as BoltArray; foreach (T3D.Point p in Bolt.BoltPositions) { Poinlist.Add(p); } } T3D.Point Point1 = new T3D.Point(); T3D.Point Point2 = new T3D.Point(); T3D.Point pa = Poinlist[0] as T3D.Point; Point1.Z = 0; Point2.Z = 0; if (pa.X < 150) { Point1 = pa; Point2 = Poinlist[1] as T3D.Point; } else { Point1 = Poinlist[1] as T3D.Point; Point2 = pa; } angle.StartPoint = Point1; angle.StartPoint.X = angle.StartPoint.X - 50; angle.EndPoint = Point2; angle.EndPoint.X = angle.EndPoint.X + 50; angle.Modify(); /* switch (condition) * { * case 1: * * angle.StartPoint = new T3D.Point(Poinlist[1] as T3D.Point); * angle.StartPoint.X = angle.StartPoint.X - 50; * angle.EndPoint = new T3D.Point(Poinlist[0] as T3D.Point); * angle.EndPoint.X = angle.EndPoint.X + 50; * * angle.Modify(); * * break; * * case 0: * angle.StartPoint =new T3D.Point(Poinlist[0] as T3D.Point); * angle.StartPoint.X = angle.StartPoint.X - 50; * angle.EndPoint = new T3D.Point(Poinlist[1] as T3D.Point); * angle.EndPoint.X = angle.EndPoint.X + 50; * * angle.Modify(); * break;*/ Poinlist.Clear(); } _model.GetWorkPlaneHandler().SetCurrentTransformationPlane(currplane); _model.CommitChanges(); }