private void AddsSecondariesDrawingObjectsToTreeNode(Assembly assembly, List <SZMK.TeklaInteraction.Shared.Models.Detail> Details, int CountMarks) { string Error = "Ошибка написания позиции детали"; try { ArrayList secondaries = assembly.GetSecondaries(); string _position = ""; for (int i = 0; i < secondaries.Count; i++) { ModelObject modelObject = secondaries[i] as ModelObject; modelObject.GetReportProperty("PART_POS", ref _position); long CountDetail = 0; if (Details.Where(p => p.Position == _position).Count() > 0) { CountDetail = Details.Where(p => p.Position == _position).FirstOrDefault().Count *CountMarks; Details.RemoveAll(p => p.Position == _position); } Details.Add(GetDetailAttribute(assembly, modelObject, CountDetail + 1)); } } catch (Exception E) { throw new Exception(Error, E); } }
private String GetNameDetail(Assembly assembly, ModelObject modelObject) { string _name = ""; modelObject.GetReportProperty("ADVANCED_OPTION.XS_DRAWING_PLOT_FILE_NAME_W", ref _name); string temp = _name; while (true) { temp = temp.Remove(0, _name.IndexOf('%') + 1); string parm = temp.Substring(0, temp.IndexOf('%')); _name = _name.Replace($"%{parm}%", GetParametersDetail(assembly, modelObject, parm)); temp = _name; if (temp.IndexOf('%') == -1) { break; } } return(_name); }
/// <summary>Get string report property from this model object</summary> /// <param name="name">Name of the report property</param> /// <returns>Return value of report property or string.Empty if not fided report property</returns> public static string GetStringReportProperty(this TSM.ModelObject modelObject, string name) { string value = string.Empty; modelObject.GetReportProperty(name, ref value); return(value); }
/// <summary>Get double report property from this model object</summary> /// <param name="name">Name of the report property</param> /// <returns>Return value of report property or int.MinValue if not fided report property</returns> public static double GetDoubleReportProperty(this TSM.ModelObject modelObject, string name) { double value = int.MinValue; modelObject.GetReportProperty(name, ref value); return(value); }
/// <summary>Get int report property from this model object</summary> /// <param name="name">Name of the report property</param> /// <returns>Return value of report property or int.MinValue if not fided report property</returns> public static int GetIntegerReportProperty(this TSM.ModelObject modelObject, string name) { int value = int.MinValue; modelObject.GetReportProperty(name, ref value); return(value); }
private String GetMethodOfPainting(ModelObject modelObject) { try { string StringAnswer = ""; modelObject.GetReportProperty("ASSEMBLY.MAINPART.FINISH", ref StringAnswer); if (StringAnswer == "") { modelObject.GetReportProperty("USERDEFINED.Obrabotka", ref StringAnswer); return(StringAnswer); } else { return(StringAnswer); } } catch (Exception E) { throw new Exception(E.Message, E); } }
private String GetMachining(ModelObject modelObject) { try { string StringAnswer = ""; modelObject.GetReportProperty("PROFILE_TYPE", ref StringAnswer); string tempA = ""; string tempB = ""; if (StringAnswer == "B") { modelObject.GetReportProperty("VOLUME", ref tempA); modelObject.GetReportProperty("VOLUME_NET", ref tempB); if (tempA == tempB) { StringAnswer = ""; } else { StringAnswer = "Фаска/Стр. "; } } else { StringAnswer = ""; } modelObject.GetReportProperty("USERDEFINED.comment", ref tempA); if (tempA == "0") { return(StringAnswer += ""); } else { return(StringAnswer += tempA); } } catch (Exception E) { throw new Exception(E.Message, E); } }
private List <string> readBarInformation(ReinforcementBase dwgRebar) { List <string> info = new List <string>(); TSM.Model MyModel = new TSM.Model(); TSM.ModelObject modelRebar = MyModel.SelectModelObject(dwgRebar.ModelIdentifier); TSM.Phase rebarPhase = new TSM.Phase(); modelRebar.GetPhase(out rebarPhase); info.Add(rebarPhase.PhaseName); string shapeCode = null; bool gotProperty = modelRebar.GetReportProperty("REBAR_POS", ref shapeCode); info.Add(shapeCode); return(info); }
private String GetDiscriptrion(ModelObject modelObject) { try { int IntAnswer = 0; modelObject.GetReportProperty("HAS_HOLES", ref IntAnswer); if (IntAnswer == 0) { return(""); } else { return("Отв. "); } } catch (Exception E) { throw new Exception(E.Message, E); } }
private String GetParametersDetail(Assembly assembly, ModelObject modelObject, string parm) { string strdata = ""; int intdata = 0; double dbldata = 0; if (parm == "NAME" || parm == "DRAWING_NAME") { string prefix = ""; modelObject.GetReportProperty("PART_PREFIX", ref prefix); if (prefix != "") { modelObject.GetReportProperty("PART_POS", ref strdata); return(prefix + "_" + strdata); } else { modelObject.GetReportProperty("PART_POS", ref strdata); return(strdata); } } if (parm == "NAME.-" || parm == "DRAWING_NAME.-") { string prefix = ""; modelObject.GetReportProperty("PART_PREFIX", ref prefix); if (prefix != "") { modelObject.GetReportProperty("PART_POS", ref strdata); return(prefix + "-" + strdata); } else { modelObject.GetReportProperty("PART_POS", ref strdata); return(strdata); } } if (parm == "NAME." || parm == "DRAWING_NAME.") { string prefix = ""; modelObject.GetReportProperty("PART_PREFIX", ref prefix); if (prefix != "") { modelObject.GetReportProperty("PART_POS", ref strdata); return(prefix + strdata); } else { modelObject.GetReportProperty("PART_POS", ref strdata); return(strdata); } } if (parm == "REV" || parm == "REVISION" || parm == "DRAWING_REVISION") { modelObject.GetReportProperty("DRAWING.REVISION.NUMBER", ref intdata); return(intdata.ToString()); } if (parm == "REV_MARK" || parm == "REVISION_MARK" || parm == "DRAWING_REVISION_MARK") { modelObject.GetReportProperty("DRAWING.REVISION.MARK", ref strdata); return(strdata); } if (parm == "TITLE" || parm == "DRAWING_TITLE") { modelObject.GetReportProperty("DRAWING.TITLE", ref strdata); return(strdata); } if (parm.IndexOf("UDA:") != -1) { modelObject.GetReportProperty("DRAWING." + parm.Remove(0, 4), ref strdata); if (strdata != "") { return(strdata); } modelObject.GetReportProperty("DRAWING." + parm.Remove(0, 4), ref intdata); if (intdata != 0) { return(intdata.ToString()); } modelObject.GetReportProperty("DRAWING." + parm.Remove(0, 4), ref dbldata); if (dbldata != 0) { return(dbldata.ToString()); } } if (parm.IndexOf("REV? - ") != -1) { int rev = 0; modelObject.GetReportProperty("DRAWING.REVISION.NUMBER", ref rev); if (rev != 0) { strdata = parm.Remove(0, 8); return(strdata.Remove(strdata.Length - 1)); } else { return(""); } } if (parm.IndexOf("REVISION? - ") != -1) { int rev = 0; modelObject.GetReportProperty("DRAWING.REVISION.NUMBER", ref rev); if (rev != 0) { strdata = parm.Remove(0, 13); return(strdata.Remove(strdata.Length - 1)); } else { return(""); } } if (parm.IndexOf("DRAWING_REVISION? - ") != -1) { int rev = 0; modelObject.GetReportProperty("DRAWING.REVISION.NUMBER", ref rev); if (rev != 0) { strdata = parm.Remove(0, 21); return(strdata.Remove(strdata.Length - 1)); } else { return(""); } } if (parm.IndexOf("TPL:") != -1) { modelObject.GetReportProperty("DRAWING." + parm.Remove(0, 4), ref strdata); if (strdata != "") { return(strdata); } modelObject.GetReportProperty("DRAWING." + parm.Remove(0, 4), ref intdata); if (intdata == 0) { return(intdata.ToString()); } modelObject.GetReportProperty("DRAWING." + parm.Remove(0, 4), ref dbldata); if (dbldata == 0) { return(dbldata.ToString()); } } return(""); }
private Shared.Models.Detail GetDetailAttribute(Assembly assembly, ModelObject modelObject, Int64 CountDetail) { try { string _name = ""; int _startnumber = 0; string _position = ""; string _profile = ""; double _width = 0; double _lenght = 0; double _weight = 0; double _height = 0; string _diameter = ""; string _markSteel = ""; string _discription = ""; double _gmlenght = 0; double _gmwidth = 0; double _gmheight = 0; string _machining = ""; string _methodOfPaintingRAL = ""; double _paintingArea = 0; string _gostName = ""; string _flangeThickness = ""; string _plateThickness = ""; _name = GetNameDetail(assembly, modelObject); modelObject.GetReportProperty("PART_START_NUMBER", ref _startnumber); modelObject.GetReportProperty("PART_POS", ref _position); modelObject.GetReportProperty("PROFILE", ref _profile); modelObject.GetReportProperty("WIDTH", ref _width); modelObject.GetReportProperty("LENGTH", ref _lenght); modelObject.GetReportProperty("CUSTOM.SZ_PartWeight", ref _weight); modelObject.GetReportProperty("PROFILE.HEIGHT", ref _height); modelObject.GetReportProperty("PROFILE.DIAMETER", ref _diameter); modelObject.GetReportProperty("MATERIAL", ref _markSteel); _discription = GetDiscriptrion(modelObject); modelObject.GetReportProperty("ASSEMBLY.LENGTH", ref _gmlenght); modelObject.GetReportProperty("ASSEMBLY.WIDTH", ref _gmwidth); modelObject.GetReportProperty("ASSEMBLY.HEIGHT", ref _gmheight); _machining = GetMachining(modelObject); _methodOfPaintingRAL = GetMethodOfPainting(modelObject); modelObject.GetReportProperty("ASSEMBLY.AREA", ref _paintingArea); modelObject.GetReportProperty("PROFILE.GOST_NAME", ref _gostName); modelObject.GetReportProperty("PROFILE.FLANGE_THICKNESS_1", ref _flangeThickness); modelObject.GetReportProperty("PROFILE.PLATE_THICKNESS", ref _plateThickness); DetailViewModel detailViewModel = new DetailViewModel(_name, _position, CountDetail.ToString(), _profile, _width, _lenght, _weight, _height, _diameter, _markSteel, _discription, _gmlenght, _gmwidth, _gmheight, _machining, _methodOfPaintingRAL, _paintingArea, _gostName, _flangeThickness, _plateThickness); return(new Shared.Models.Detail { StartNumber = _startnumber, Name = detailViewModel.Name, Position = detailViewModel.Position, Count = CountDetail, Profile = detailViewModel.Profile, Width = Convert.ToDouble(detailViewModel.Width.ToString("F2")), Lenght = Convert.ToDouble(detailViewModel.Lenght.ToString("F2")), Weight = Convert.ToDouble(detailViewModel.Weight.ToString("F2")), Height = Convert.ToDouble(detailViewModel.Height.ToString("F2")), Diameter = detailViewModel.Diameter, SubtotalWeight = Convert.ToDouble(detailViewModel.SubTotalWeight.ToString("F2")), MarkSteel = detailViewModel.MarkSteel, Discription = detailViewModel.Discription, GMlenght = Convert.ToDouble(detailViewModel.GMLenght.ToString("F2")), GMwidth = Convert.ToDouble(detailViewModel.GMWidth.ToString("F2")), GMheight = Convert.ToDouble(detailViewModel.GMHeight.ToString("F2")), Machining = detailViewModel.Machining, MethodOfPaintingRAL = detailViewModel.MethodOfPaintiongRAL, PaintingArea = Convert.ToDouble((detailViewModel.PaintingArea / 1000000).ToString("F2")), GostName = detailViewModel.GostName, FlangeThickness = detailViewModel.FlangeThickness, PlateThickness = detailViewModel.PlateThickness }); } catch (Exception E) { throw new Exception(E.Message, E); } }
private void RenameDrawingTitle(DrawingEnumerator DrawingList) { this.progressBar1.Maximum = DrawingList.GetSize(); int num = 1; int num2 = 0; int num3 = 0; int num4 = 0; bool needsUpdating = false; while (DrawingList.MoveNext()) { this.progressBar1.Value++; this.CurrentNo.Text = num++.ToString() + '/' + DrawingList.GetSize().ToString(); this.CurrentNo.Refresh(); string mainpartname = ""; string existingDrawingname = ""; // Name of the drawing before modify Tekla.Structures.Model.ModelObject modelObject = null; Drawing currentDrawing = DrawingList.Current; if (currentDrawing.UpToDateStatus.ToString() != "DrawingIsUpToDate") { needsUpdating = true; continue; } if (DrawingList.Current is AssemblyDrawing) { AssemblyDrawing assemblyDrawing = DrawingList.Current as AssemblyDrawing; Identifier assemblyIdentifier = assemblyDrawing.AssemblyIdentifier; modelObject = this.My_model.SelectModelObject(assemblyIdentifier); modelObject.GetReportProperty("ASSEMBLY_NAME", ref mainpartname); num2++; } if (DrawingList.Current is SinglePartDrawing) { SinglePartDrawing singlePartDrawing = DrawingList.Current as SinglePartDrawing; Identifier partIdentifier = singlePartDrawing.PartIdentifier; modelObject = this.My_model.SelectModelObject(partIdentifier); modelObject.GetReportProperty("NAME", ref mainpartname); } if (modelObject != null) { // Check if drawing name already contains the automatic drawing name: existingDrawingname = DrawingList.Current.Name; bool drawingNameMatch = existingDrawingname.Contains(mainpartname); if ((drawingNameMatch == true) || (drawingNameMatch = existingDrawingname.Contains("DS"))) { num4++; } if (drawingNameMatch == false) { DrawingList.Current.Name = mainpartname; DrawingList.Current.Modify(); num3++; } } } if (needsUpdating == true) { MessageBox.Show("Some of the drawings are not up to date!\n\nNames were not updated for that drawings.", Variables.title); } MessageBox.Show(string.Concat(new object[] { num3, " Drawing's name changed \n", num4, " Drawings kept the existing name" }), Variables.title); }