public void GetProperties() { ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects(); if (modelObjectEnum.GetSize() == 1) { while (modelObjectEnum.MoveNext()) { if (modelObjectEnum.Current is Tekla.Structures.Model.Grid) { Grid grid = (Grid)modelObjectEnum.Current; coordinateX = grid.CoordinateX; coordinateY = grid.CoordinateY; coordinateZ = grid.CoordinateZ; labelX = grid.LabelX; labelY = grid.LabelY; labelZ = grid.LabelZ; } } } if (modelObjectEnum.GetSize() > 1) { coordinateX = ""; coordinateY = ""; coordinateZ = ""; labelX = ""; labelY = ""; labelZ = ""; } }
public static void Run(Tekla.Technology.Akit.IScript akit) { Model model = new Model(); ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects(); Tekla.Structures.Model.UI.Picker picker = new Tekla.Structures.Model.UI.Picker(); if (modelObjectEnum.GetSize() == 0) { modelObjectEnum = picker.PickObjects(Tekla.Structures.Model.UI.Picker.PickObjectsEnum.PICK_N_PARTS); } ArrayList arrayPoints = picker.PickPoints(Tekla.Structures.Model.UI.Picker.PickPointEnum.PICK_TWO_POINTS); Point point1 = (Tekla.Structures.Geometry3d.Point)arrayPoints[0]; Point point2 = (Tekla.Structures.Geometry3d.Point)arrayPoints[1]; Line line = new Tekla.Structures.Geometry3d.Line(point1, point2); while (modelObjectEnum.MoveNext()) { if (modelObjectEnum.Current is Beam) { Beam beam = (Beam)modelObjectEnum.Current; Line line2 = new Line(beam.StartPoint, beam.EndPoint); Point intersection = Intersection.LineToLine(line, line2).Point1; Tekla.Structures.Model.Operations.Operation.Split(beam, intersection); } } model.CommitChanges(); }
public static void Run(Tekla.Technology.Akit.IScript akit) { try { Model model = new Model(); ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects(); System.Collections.ArrayList array = new System.Collections.ArrayList(); if (modelObjectEnum.GetSize() == 0) { Picker picker = new Picker(); Part part = (Part)picker.PickObject(Tekla.Structures.Model.UI.Picker.PickObjectEnum.PICK_ONE_PART); part.Insert(); array.Add(part); } else { while (modelObjectEnum.MoveNext()) { if (modelObjectEnum.Current is Part) { Part part = (Part)modelObjectEnum.Current; part.Insert(); array.Add(part); } } } model.CommitChanges(); Tekla.Structures.Model.UI.ModelObjectSelector modelobjsel = new Tekla.Structures.Model.UI.ModelObjectSelector(); modelobjsel.Select(array); } catch { } }
public static void Run(Tekla.Technology.Akit.IScript akit) { try { Model model = new Model(); TransformationPlane transformationplane = model.GetWorkPlaneHandler().GetCurrentTransformationPlane(); model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane()); ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects(); if (modelObjectEnum.GetSize() == 1) { while (modelObjectEnum.MoveNext()) { if (modelObjectEnum.Current is Tekla.Structures.Model.Part) { Tekla.Structures.Model.Part part = modelObjectEnum.Current as Tekla.Structures.Model.Part; double level = 0; part.GetReportProperty("TOP_LEVEL_UNFORMATTED", ref level); akit.CommandStart("ail_create_basic_view", "", "main_frame"); akit.ValueChange("Modelling create view", "v1_coordinate", level.ToString("F02")); akit.PushButton("v1_create", "Modelling create view"); } } } model.GetWorkPlaneHandler().SetCurrentTransformationPlane(transformationplane); } catch { } }
public static void Run(Tekla.Technology.Akit.IScript akit) { try { Model model = new Model(); ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects(); if (modelObjectEnum.GetSize() > 0) { while (modelObjectEnum.MoveNext()) { if (modelObjectEnum.Current is Tekla.Structures.Model.Part) { Tekla.Structures.Model.Part part = (Tekla.Structures.Model.Part)modelObjectEnum.Current; string mark = ""; Hashtable strProps = new Hashtable(); ArrayList PartStrRepPropNames = new ArrayList(); PartStrRepPropNames.Add("ASSEMBLY_POS"); part.GetStringReportProperties(PartStrRepPropNames, ref strProps); if ((mark = (string)strProps["ASSEMBLY_POS"]) == null) { mark = ""; } mark = mark.Replace("(?)", ""); part.SetUserProperty("USER_FIELD_4", mark); part.Modify(); } } model.CommitChanges(); MessageBox.Show("Process Complete"); } } catch { } }
} // 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; }
public static void Run(Tekla.Technology.Akit.IScript akit) { try { Model model = new Model(); ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects(); if (modelObjectEnum.GetSize() > 0) { while (modelObjectEnum.MoveNext()) { if (modelObjectEnum.Current is Tekla.Structures.Model.Part) { Tekla.Structures.Model.Part part = (Tekla.Structures.Model.Part)modelObjectEnum.Current; string USER_FIELD_3 = "", USER_FIELD_4 = "", PRELIM_MARK = ""; part.GetUserProperty("USER_FIELD_3", ref USER_FIELD_3); part.GetUserProperty("USER_FIELD_4", ref USER_FIELD_4); part.GetUserProperty("PRELIM_MARK", ref PRELIM_MARK); USER_FIELD_4 = USER_FIELD_4.Replace("(?)", ""); if (USER_FIELD_3 == "Z") { part.SetUserProperty("USER_FIELD_2", PRELIM_MARK); part.SetUserProperty("PRELIM_MARK", USER_FIELD_3 + USER_FIELD_4); part.Modify(); } } } model.CommitChanges(); MessageBox.Show("Process Complete"); } } catch { } }
public string GetInfo() { Model model = new Model(); Tekla.Structures.Model.UI.ModelObjectSelector selector = new Tekla.Structures.Model.UI.ModelObjectSelector(); ModelObjectEnumerator enumerator = selector.GetSelectedObjects(); return(enumerator.GetSize().ToString()); }
public static List <ModelObject> ToList(this ModelObjectEnumerator enumerator, bool selectInstances = false) { enumerator.SelectInstances = selectInstances; var output = new List <ModelObject>(enumerator.GetSize()); while (enumerator.MoveNext()) { output.Add(enumerator.Current); } return(output); }
private void MallinnaLaatta() { ModelObjectSelector mSelector = malli.GetModelObjectSelector(); ModelObjectEnumerator enumer = mSelector.GetAllObjects(); for (int i = 0; i < enumer.GetSize(); i++) { ModelObject obj = enumer.Current; if (obj is ContourPlate) { if (((ContourPlate)obj).Name == "LASKETTU_LAATTA") { ContourPlate laattaTemp = (ContourPlate)obj; laattaTemp.Contour.ContourPoints[0] = new ContourPoint(new Point(0, 0, 3000), null); laattaTemp.Contour.ContourPoints[1] = new ContourPoint(new Point(0, laatanKorkeus, 3000), null); laattaTemp.Contour.ContourPoints[2] = new ContourPoint(new Point(laatanLeveys, laatanKorkeus, 3000), null); laattaTemp.Contour.ContourPoints[3] = new ContourPoint(new Point(laatanLeveys, 0, 3000), null); PoistaRaudoitus(laattaTemp); laattaTemp.Modify(); malli.CommitChanges(); return; } } enumer.MoveNext(); } ContourPlate laatta = new ContourPlate(); laatta.Name = "LASKETTU_LAATTA"; ContourPoint vasenAlanurkka = new ContourPoint(new Point(0, 0, 3000), null); ContourPoint vasenYlanurkka = new ContourPoint(new Point(0, laatanKorkeus, 3000), null); ContourPoint oikeaYlanurkka = new ContourPoint(new Point(laatanLeveys, laatanKorkeus, 3000), null); ContourPoint oikeaAlanurkka = new ContourPoint(new Point(laatanLeveys, 0, 3000), null); laatta.AddContourPoint(vasenAlanurkka); laatta.AddContourPoint(vasenYlanurkka); laatta.AddContourPoint(oikeaYlanurkka); laatta.AddContourPoint(oikeaAlanurkka); laatta.Profile.ProfileString = Asetukset.LaatanPaksuus.ToString(); if (!string.IsNullOrWhiteSpace(Asetukset.BetoninLujuus.ToString())) { laatta.Material.MaterialString = betonimateriaalit[Asetukset.BetoninLujuus]; } else { laatta.Material.MaterialString = "Concrete_Undefined"; } laatta.Position.Depth = Position.DepthEnum.FRONT; laatta.Insert(); malli.CommitChanges(); }
public static void main() { ModelObjectEnumerator selectedObjects = getSelectedObjects(); ArrayList selectedParts = getSelectedParts(selectedObjects); foreach (Part currentPart in selectedParts) { changePartName(currentPart); } MessageBox.Show("Valitud " + selectedObjects.GetSize() + " objekti." + Environment.NewLine + "Muudetud " + selectedParts.Count.ToString() + " elemendi nime."); }
public void GetProperties() { ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects(); if (modelObjectEnum.GetSize() == 1) { while (modelObjectEnum.MoveNext()) { if (modelObjectEnum.Current is Tekla.Structures.Model.Connection) { Connection connection = (Connection)modelObjectEnum.Current; code = connection.Code; name = connection.Name; //connection.Number); //connection.SetAttribute } } } if (modelObjectEnum.GetSize() > 1) { } }
private void PoistaRaudoitus(ModelObject laatta) { ModelObjectEnumerator rautaEnum = malli.GetModelObjectSelector().GetAllObjects(); for (int j = 0; j < rautaEnum.GetSize(); j++) { if (rautaEnum.Current != null && rautaEnum.Current is RebarMesh) { ((RebarMesh)rautaEnum.Current).Delete(); } rautaEnum.MoveNext(); } }
public void LuetteleObjektit() { ModelObjectEnumerator objEnum = malli.GetModelObjectSelector().GetAllObjects(); string objektit = ""; for (int i = 0; i < objEnum.GetSize(); i++) { if (objEnum.Current != null) { objektit += objEnum.Current.ToString() + "\n"; } objEnum.MoveNext(); } System.Windows.Forms.MessageBox.Show(objektit); }
public static List <T> ToList <T>(this ModelObjectEnumerator enumerator, bool selectInstances = false) where T : ModelObject { enumerator.SelectInstances = selectInstances; var output = new List <T>(enumerator.GetSize()); while (enumerator.MoveNext()) { if (enumerator.Current is T t) { output.Add(t); } } return(output); }
private ModelObject HaeLaattaMallista() { ModelObjectEnumerator objEnum = malli.GetModelObjectSelector().GetAllObjects(); ModelObject palautus = null; for (int i = 0; i < objEnum.GetSize(); i++) { if (objEnum.Current is ContourPlate && ((ContourPlate)objEnum.Current).Name == "LASKETTU_LAATTA") { palautus = (ModelObject)objEnum.Current; break; } objEnum.MoveNext(); } return(palautus); }
public static Dictionary <int, ModelObject> ToDictionaryId(this ModelObjectEnumerator enumerator, bool selectInstances = false) { enumerator.SelectInstances = selectInstances; var output = new Dictionary <int, ModelObject>(enumerator.GetSize()); while (enumerator.MoveNext()) { var modelObject = enumerator.Current; if (!output.ContainsKey(modelObject.Identifier.ID)) { output.Add(modelObject.Identifier.ID, enumerator.Current); } } return(output); }
private bool OnkoSeinaJoMallinnettu(Point p1, Point p2) { ModelObjectEnumerator objEnum = malli.GetModelObjectSelector().GetAllObjects(); for (int i = 0; i < objEnum.GetSize(); i++) { if (objEnum.Current is Beam) { Beam seinaTemp = (Beam)objEnum.Current; if (seinaTemp.StartPoint == p1 && seinaTemp.EndPoint == p2) { return(true); } } objEnum.MoveNext(); } return(false); }
public static Dictionary <Guid, T> ToDictionaryGuid <T>(this ModelObjectEnumerator enumerator, bool selectInstances = false) where T : ModelObject { enumerator.SelectInstances = selectInstances; var output = new Dictionary <Guid, T>(enumerator.GetSize()); while (enumerator.MoveNext()) { var modelObject = enumerator.Current; if (modelObject is T t) { if (!output.ContainsKey(modelObject.Identifier.GUID)) { output.Add(modelObject.Identifier.GUID, t); } } } return(output); }
private void getEnumerator() { modelObjectEnumerator = selector.GetSelectedObjects(); if (modelObjectEnumerator.GetSize() > 0) { return; } else { try { modelObjectEnumerator = picker.PickObjects(Picker.PickObjectsEnum.PICK_N_REINFORCEMENTS); } catch (Exception) { MessageBox.Show("No rebars selected"); return; } } }
public void TyhjennaMalli() { ModelObjectEnumerator objEnum = malli.GetModelObjectSelector().GetAllObjects(); for (int i = 0; i < objEnum.GetSize(); i++) { if (objEnum.Current is ContourPlate) { ((ContourPlate)objEnum.Current).Delete(); } else if (objEnum.Current is Beam) { ((Beam)objEnum.Current).Delete(); } objEnum.MoveNext(); } seinat.Clear(); idNumerot.Clear(); malli.CommitChanges(); }
public void GetProperties() { ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects(); if (modelObjectEnum.GetSize() == 1) { while (modelObjectEnum.MoveNext()) { if (modelObjectEnum.Current is Tekla.Structures.Model.BoltGroup) { BoltGroup boltGroup = (BoltGroup)modelObjectEnum.Current; boltSize = boltGroup.BoltSize.ToString(); boltStandard = boltGroup.BoltStandard.ToString(); if (boltGroup.BoltType == BoltGroup.BoltTypeEnum.BOLT_TYPE_SITE) { boltType = BoltTypeEnum.Site; } else if (boltGroup.BoltType == BoltGroup.BoltTypeEnum.BOLT_TYPE_WORKSHOP) { boltType = BoltTypeEnum.Workshop; } if (boltGroup.ThreadInMaterial == BoltGroup.BoltThreadInMaterialEnum.THREAD_IN_MATERIAL_YES) { threadMaterial = ThreadMaterialEnum.Yes; } else if (boltGroup.ThreadInMaterial == BoltGroup.BoltThreadInMaterialEnum.THREAD_IN_MATERIAL_NO) { threadMaterial = ThreadMaterialEnum.No; } cutLength = boltGroup.CutLength.ToString(); extraLength = boltGroup.ExtraLength.ToString(); boltGroupShape = boltGroup.GetType().Name; if (boltGroup is BoltArray) { BoltArray boltArray = (BoltArray)boltGroup; string boltPositionX = ""; for (int i = 0; i < boltArray.GetBoltDistXCount(); i++) { boltPositionX = boltPositionX + boltArray.GetBoltDistX(i).ToString() + " "; } boltDistX = boltPositionX.Trim(); string boltPositionY = ""; for (int i = 0; i < boltArray.GetBoltDistYCount(); i++) { boltPositionY = boltPositionY + boltArray.GetBoltDistY(i).ToString() + " "; } boltDistY = boltPositionY.Trim(); } else if (boltGroup is BoltXYList) { BoltXYList boltXYList = (BoltXYList)boltGroup; string boltPositionX = ""; for (int i = 0; i < boltXYList.GetBoltDistXCount(); i++) { boltPositionX = boltPositionX + boltXYList.GetBoltDistX(i).ToString() + " "; } boltDistX = boltPositionX.Trim(); string boltPositionY = ""; for (int i = 0; i < boltXYList.GetBoltDistYCount(); i++) { boltPositionY = boltPositionY + boltXYList.GetBoltDistY(i).ToString() + " "; } boltDistY = boltPositionY.Trim(); } else if (boltGroup is BoltCircle) { BoltCircle boltCircle = (BoltCircle)boltGroup; boltDistX = boltCircle.NumberOfBolts.ToString(); boltDistY = boltCircle.Diameter.ToString(); } tolerance = boltGroup.Tolerance.ToString(); if (boltGroup.HoleType == BoltGroup.BoltHoleTypeEnum.HOLE_TYPE_SLOTTED) { holeType = HoleTypeEnum.Slotted; } else if (boltGroup.HoleType == BoltGroup.BoltHoleTypeEnum.HOLE_TYPE_OVERSIZED) { holeType = HoleTypeEnum.Oversized; } slottedHoleX = boltGroup.SlottedHoleX.ToString(); slottedHoleY = boltGroup.SlottedHoleY.ToString(); if (boltGroup.RotateSlots == BoltGroup.BoltRotateSlotsEnum.ROTATE_SLOTS_ODD) { rotateSlots = RotateSlotEnum.Odd; } else if (boltGroup.RotateSlots == BoltGroup.BoltRotateSlotsEnum.ROTATE_SLOTS_EVEN) { rotateSlots = RotateSlotEnum.Even; } else if (boltGroup.RotateSlots == BoltGroup.BoltRotateSlotsEnum.ROTATE_SLOTS_PARALLEL) { rotateSlots = RotateSlotEnum.Parallel; } if (boltGroup.Position.Plane == Position.PlaneEnum.LEFT) { positionOnPlane = PositionPlaneEnum.Left; } else if (boltGroup.Position.Plane == Position.PlaneEnum.MIDDLE) { positionOnPlane = PositionPlaneEnum.Middle; } else if (boltGroup.Position.Plane == Position.PlaneEnum.RIGHT) { positionOnPlane = PositionPlaneEnum.Right; } positionOnPlaneOffset = boltGroup.Position.PlaneOffset.ToString("F02"); if (boltGroup.Position.Rotation == Position.RotationEnum.FRONT) { positionRotation = PositionRotationEnum.Front; } else if (boltGroup.Position.Rotation == Position.RotationEnum.TOP) { positionRotation = PositionRotationEnum.Top; } else if (boltGroup.Position.Rotation == Position.RotationEnum.BACK) { positionRotation = PositionRotationEnum.Back; } else if (boltGroup.Position.Rotation == Position.RotationEnum.BELOW) { positionRotation = PositionRotationEnum.Below; } positionRotationOffset = boltGroup.Position.RotationOffset.ToString("F02"); if (boltGroup.Position.Depth == Position.DepthEnum.BEHIND) { positionAtDepth = PositionDepthEnum.Behind; } else if (boltGroup.Position.Depth == Position.DepthEnum.FRONT) { positionAtDepth = PositionDepthEnum.Front; } else if (boltGroup.Position.Depth == Position.DepthEnum.MIDDLE) { positionAtDepth = PositionDepthEnum.Middle; } positionAtDepthOffset = boltGroup.Position.DepthOffset.ToString("F02"); offsetFromStartX = boltGroup.StartPointOffset.Dx.ToString("F02"); offsetFromStartY = boltGroup.StartPointOffset.Dy.ToString("F02"); offsetFromStartZ = boltGroup.StartPointOffset.Dz.ToString("F02"); offsetFromEndX = boltGroup.EndPointOffset.Dx.ToString("F02"); offsetFromEndY = boltGroup.EndPointOffset.Dy.ToString("F02"); offsetFromEndZ = boltGroup.EndPointOffset.Dz.ToString("F02"); if (boltGroup.Hole1) { hole1 = Bool.True; } else { hole1 = Bool.False; } if (boltGroup.Hole2) { hole2 = Bool.True; } else { hole2 = Bool.False; } if (boltGroup.Hole3) { hole3 = Bool.True; } else { hole3 = Bool.False; } if (boltGroup.Hole4) { hole4 = Bool.True; } else { hole4 = Bool.False; } if (boltGroup.Hole5) { hole5 = Bool.True; } else { hole5 = Bool.False; } if (boltGroup.Washer1) { washer1 = Bool.True; } else { washer1 = Bool.False; } if (boltGroup.Washer2) { washer2 = Bool.True; } else { washer2 = Bool.False; } if (boltGroup.Washer3) { washer3 = Bool.True; } else { washer3 = Bool.False; } if (boltGroup.Nut1) { nut1 = Bool.True; } else { nut1 = Bool.False; } if (boltGroup.Nut2) { nut2 = Bool.True; } else { nut2 = Bool.False; } if (boltGroup.Bolt) { boltShaft = Bool.True; } else { boltShaft = Bool.False; } } } } if (modelObjectEnum.GetSize() > 1) { boltSize = ""; boltStandard = ""; boltType = new BoltTypeEnum(); threadMaterial = new ThreadMaterialEnum(); cutLength = ""; extraLength = ""; boltGroupShape = ""; boltDistX = ""; boltDistY = ""; tolerance = ""; slottedHoleX = ""; slottedHoleY = ""; rotateSlots = new RotateSlotEnum(); holeType = new HoleTypeEnum(); positionOnPlane = new PositionPlaneEnum(); positionOnPlaneOffset = ""; positionRotation = new PositionRotationEnum(); positionRotationOffset = ""; positionAtDepth = new PositionDepthEnum(); positionAtDepthOffset = ""; offsetFromStartX = ""; offsetFromStartY = ""; offsetFromStartZ = ""; offsetFromEndX = ""; offsetFromEndY = ""; offsetFromEndZ = ""; hole1 = new Bool(); hole2 = new Bool(); hole3 = new Bool(); hole4 = new Bool(); hole5 = new Bool(); boltShaft = new Bool(); washer1 = new Bool(); washer2 = new Bool(); washer3 = new Bool(); nut1 = new Bool(); nut2 = new Bool(); } }
public void GetProperties() { Model model = new Model(); Tekla.Structures.Model.UI.ModelObjectSelector modelObjectSelector = new Tekla.Structures.Model.UI.ModelObjectSelector(); ModelObjectEnumerator modelObjectEnum = modelObjectSelector.GetSelectedObjects(); if (modelObjectEnum.GetSize() == 1) { while (modelObjectEnum.MoveNext()) { if (modelObjectEnum.Current is Tekla.Structures.Model.BaseWeld) { BaseWeld weld = (BaseWeld)modelObjectEnum.Current; refText = weld.ReferenceText; if (weld.AroundWeld) { around = Bool.True; } else { around = Bool.False; } sizeAbove = weld.SizeAbove.ToString(); if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_NONE) { weldTypeAbove = WeldType.WELD_TYPE_NONE; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_FILLET) { weldTypeAbove = WeldType.WELD_TYPE_FILLET; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_BEVEL_GROOVE_SINGLE_V_BUTT) { weldTypeAbove = WeldType.WELD_TYPE_BEVEL_GROOVE_SINGLE_V_BUTT; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_BEVEL_GROOVE_SINGLE_BEVEL_BUTT) { weldTypeAbove = WeldType.WELD_TYPE_BEVEL_GROOVE_SINGLE_BEVEL_BUTT; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_SQUARE_GROOVE_SQUARE_BUTT) { weldTypeAbove = WeldType.WELD_TYPE_SQUARE_GROOVE_SQUARE_BUTT; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_SINGLE_V_BUTT_WITH_BROAD_ROOT_FACE) { weldTypeAbove = WeldType.WELD_TYPE_SINGLE_V_BUTT_WITH_BROAD_ROOT_FACE; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_SINGLE_BEVEL_BUTT_WITH_BROAD_ROOT_FACE) { weldTypeAbove = WeldType.WELD_TYPE_SINGLE_BEVEL_BUTT_WITH_BROAD_ROOT_FACE; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_U_GROOVE_SINGLE_U_BUTT) { weldTypeAbove = WeldType.WELD_TYPE_U_GROOVE_SINGLE_U_BUTT; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_J_GROOVE_J_BUTT) { weldTypeAbove = WeldType.WELD_TYPE_J_GROOVE_J_BUTT; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_FLARE_V_GROOVE) { weldTypeAbove = WeldType.WELD_TYPE_FLARE_V_GROOVE; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_FLARE_BEVEL_GROOVE) { weldTypeAbove = WeldType.WELD_TYPE_FLARE_BEVEL_GROOVE; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_EDGE_FLANGE) { weldTypeAbove = WeldType.WELD_TYPE_EDGE_FLANGE; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_CORNER_FLANGE) { weldTypeAbove = WeldType.WELD_TYPE_CORNER_FLANGE; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_PLUG) { weldTypeAbove = WeldType.WELD_TYPE_PLUG; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_BEVEL_BACKING) { weldTypeAbove = WeldType.WELD_TYPE_BEVEL_BACKING; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_SPOT) { weldTypeAbove = WeldType.WELD_TYPE_SPOT; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_SEAM) { weldTypeAbove = WeldType.WELD_TYPE_SEAM; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_SLOT) { weldTypeAbove = WeldType.WELD_TYPE_SLOT; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_PARTIAL_PENETRATION_SINGLE_BEVEL_BUTT_PLUS_FILLET) { weldTypeAbove = WeldType.WELD_TYPE_PARTIAL_PENETRATION_SINGLE_BEVEL_BUTT_PLUS_FILLET; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_PARTIAL_PENETRATION_SQUARE_GROOVE_PLUS_FILLET) { weldTypeAbove = WeldType.WELD_TYPE_PARTIAL_PENETRATION_SQUARE_GROOVE_PLUS_FILLET; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_MELT_THROUGH) { weldTypeAbove = WeldType.WELD_TYPE_MELT_THROUGH; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_V_BUTT) { weldTypeAbove = WeldType.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_V_BUTT; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_BEVEL_BUTT) { weldTypeAbove = WeldType.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_BEVEL_BUTT; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_EDGE) { weldTypeAbove = WeldType.WELD_TYPE_EDGE; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_ISO_SURFACING) { weldTypeAbove = WeldType.WELD_TYPE_ISO_SURFACING; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_FOLD) { weldTypeAbove = WeldType.WELD_TYPE_FOLD; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_INCLINED) { weldTypeAbove = WeldType.WELD_TYPE_INCLINED; } else { Console.WriteLine(weld.TypeAbove); } if (weld.ContourAbove == BaseWeld.WeldContourEnum.WELD_CONTOUR_NONE) { contourTypeAbove = ContourType.None; } else if (weld.ContourAbove == BaseWeld.WeldContourEnum.WELD_CONTOUR_FLUSH) { contourTypeAbove = ContourType.Flush; } sizeBelow = weld.SizeBelow.ToString(); if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_NONE) { weldTypeBelow = WeldType.WELD_TYPE_NONE; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_FILLET) { weldTypeBelow = WeldType.WELD_TYPE_FILLET; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_BEVEL_GROOVE_SINGLE_V_BUTT) { weldTypeBelow = WeldType.WELD_TYPE_BEVEL_GROOVE_SINGLE_V_BUTT; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_BEVEL_GROOVE_SINGLE_BEVEL_BUTT) { weldTypeBelow = WeldType.WELD_TYPE_BEVEL_GROOVE_SINGLE_BEVEL_BUTT; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_SQUARE_GROOVE_SQUARE_BUTT) { weldTypeBelow = WeldType.WELD_TYPE_SQUARE_GROOVE_SQUARE_BUTT; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_SINGLE_V_BUTT_WITH_BROAD_ROOT_FACE) { weldTypeBelow = WeldType.WELD_TYPE_SINGLE_V_BUTT_WITH_BROAD_ROOT_FACE; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_SINGLE_BEVEL_BUTT_WITH_BROAD_ROOT_FACE) { weldTypeBelow = WeldType.WELD_TYPE_SINGLE_BEVEL_BUTT_WITH_BROAD_ROOT_FACE; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_U_GROOVE_SINGLE_U_BUTT) { weldTypeBelow = WeldType.WELD_TYPE_U_GROOVE_SINGLE_U_BUTT; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_J_GROOVE_J_BUTT) { weldTypeBelow = WeldType.WELD_TYPE_J_GROOVE_J_BUTT; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_FLARE_V_GROOVE) { weldTypeBelow = WeldType.WELD_TYPE_FLARE_V_GROOVE; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_FLARE_BEVEL_GROOVE) { weldTypeBelow = WeldType.WELD_TYPE_FLARE_BEVEL_GROOVE; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_EDGE_FLANGE) { weldTypeBelow = WeldType.WELD_TYPE_EDGE_FLANGE; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_CORNER_FLANGE) { weldTypeBelow = WeldType.WELD_TYPE_CORNER_FLANGE; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_PLUG) { weldTypeBelow = WeldType.WELD_TYPE_PLUG; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_BEVEL_BACKING) { weldTypeBelow = WeldType.WELD_TYPE_BEVEL_BACKING; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_SPOT) { weldTypeBelow = WeldType.WELD_TYPE_SPOT; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_SEAM) { weldTypeBelow = WeldType.WELD_TYPE_SEAM; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_SLOT) { weldTypeBelow = WeldType.WELD_TYPE_SLOT; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_PARTIAL_PENETRATION_SINGLE_BEVEL_BUTT_PLUS_FILLET) { weldTypeBelow = WeldType.WELD_TYPE_PARTIAL_PENETRATION_SINGLE_BEVEL_BUTT_PLUS_FILLET; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_PARTIAL_PENETRATION_SQUARE_GROOVE_PLUS_FILLET) { weldTypeBelow = WeldType.WELD_TYPE_PARTIAL_PENETRATION_SQUARE_GROOVE_PLUS_FILLET; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_MELT_THROUGH) { weldTypeBelow = WeldType.WELD_TYPE_MELT_THROUGH; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_V_BUTT) { weldTypeBelow = WeldType.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_V_BUTT; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_BEVEL_BUTT) { weldTypeBelow = WeldType.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_BEVEL_BUTT; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_EDGE) { weldTypeBelow = WeldType.WELD_TYPE_EDGE; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_ISO_SURFACING) { weldTypeBelow = WeldType.WELD_TYPE_ISO_SURFACING; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_FOLD) { weldTypeBelow = WeldType.WELD_TYPE_FOLD; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_INCLINED) { weldTypeBelow = WeldType.WELD_TYPE_INCLINED; } else { Console.WriteLine(weld.TypeBelow); } if (weld.ContourBelow == BaseWeld.WeldContourEnum.WELD_CONTOUR_NONE) { contourTypeBelow = ContourType.None; } else if (weld.ContourBelow == BaseWeld.WeldContourEnum.WELD_CONTOUR_FLUSH) { contourTypeBelow = ContourType.Flush; } } } } else { sizeAbove = ""; weldTypeAbove = new WeldType(); contourTypeAbove = new ContourType(); sizeBelow = ""; weldTypeBelow = new WeldType(); contourTypeBelow = new ContourType(); refText = ""; around = new Bool(); } }
public void GetProperties() { ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects(); if (modelObjectEnum.GetSize() == 1) { while (modelObjectEnum.MoveNext()) { if (modelObjectEnum.Current is Tekla.Structures.Model.ContourPlate) { Tekla.Structures.Model.ContourPlate contourPlate = (Tekla.Structures.Model.ContourPlate)modelObjectEnum.Current; TransformationPlane currentTP = new TransformationPlane(); currentTP = model.GetWorkPlaneHandler().GetCurrentTransformationPlane(); model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane()); contourPlate.Select(); Assembly assembly = contourPlate.GetAssembly() as Tekla.Structures.Model.Assembly; assembly.GetReportProperty("ASSEMBLY_POSITION_CODE", ref gridLocation); partType = contourPlate.GetType().Name; partID = contourPlate.Identifier.ID.ToString(); contourPlate.GetReportProperty("OWNER", ref owner); partPrefix = contourPlate.PartNumber.Prefix; partStartNo = contourPlate.PartNumber.StartNumber.ToString(); assemblyPrefix = contourPlate.AssemblyNumber.Prefix; assemblyStartNo = contourPlate.AssemblyNumber.StartNumber.ToString(); Phase CurrentPhase = new Phase(); contourPlate.GetPhase(out CurrentPhase); phase = CurrentPhase.PhaseNumber.ToString(); name = contourPlate.Name; profile = contourPlate.Profile.ProfileString; material = contourPlate.Material.MaterialString; finish = contourPlate.Finish; classValue = contourPlate.Class; if (contourPlate.Position.Plane == Position.PlaneEnum.LEFT) { positionOnPlane = PositionPlaneEnum.Left; } else if (contourPlate.Position.Plane == Position.PlaneEnum.MIDDLE) { positionOnPlane = PositionPlaneEnum.Middle; } else if (contourPlate.Position.Plane == Position.PlaneEnum.RIGHT) { positionOnPlane = PositionPlaneEnum.Right; } positionOnPlaneOffset = contourPlate.Position.PlaneOffset.ToString("F02"); if (contourPlate.Position.Rotation == Position.RotationEnum.BACK) { positionRotation = PositionRotationEnum.Back; } else if (contourPlate.Position.Rotation == Position.RotationEnum.BELOW) { positionRotation = PositionRotationEnum.Below; } else if (contourPlate.Position.Rotation == Position.RotationEnum.FRONT) { positionRotation = PositionRotationEnum.Front; } else if (contourPlate.Position.Rotation == Position.RotationEnum.TOP) { positionRotation = PositionRotationEnum.Top; } positionRotationOffset = contourPlate.Position.RotationOffset.ToString("F02"); if (contourPlate.Position.Depth == Position.DepthEnum.BEHIND) { positionAtDepth = PositionDepthEnum.Behind; } else if (contourPlate.Position.Depth == Position.DepthEnum.FRONT) { positionAtDepth = PositionDepthEnum.Front; } else if (contourPlate.Position.Depth == Position.DepthEnum.MIDDLE) { positionAtDepth = PositionDepthEnum.Middle; } positionAtDepthOffset = contourPlate.Position.DepthOffset.ToString("F02"); contourPlate.GetUserProperty("USER_FIELD_1", ref userfield1); contourPlate.GetUserProperty("USER_FIELD_2", ref userfield2); contourPlate.GetUserProperty("USER_FIELD_3", ref userfield3); contourPlate.GetUserProperty("USER_FIELD_4", ref userfield4); contourPlate.GetUserProperty("comment", ref notesComments); contourPlate.GetUserProperty("FIT_NOTES", ref fittingNotes); contourPlate.GetUserProperty("FIT_NOTES2", ref fittingNotes2); contourPlate.GetUserProperty("cambering", ref cambering); contourPlate.GetUserProperty("PAINT", ref paint); contourPlate.GetUserProperty("PRELIM_MARK", ref preliminaryMark); contourPlate.GetUserProperty("PAINT_WFT", ref paintWFT); contourPlate.GetUserProperty("PAINT_DFT", ref paintDFT); double dblshear1 = 0; contourPlate.GetUserProperty("shear1", ref dblshear1); dblshear1 = dblshear1 * 0.001; shearStart = dblshear1.ToString(); double dblshear2 = 0; contourPlate.GetUserProperty("shear2", ref dblshear2); dblshear2 = dblshear2 * 0.001; shearEnd = dblshear2.ToString(); double dblaxial1 = 0; contourPlate.GetUserProperty("axial1", ref dblaxial1); dblaxial1 = dblaxial1 * 0.001; axialStart = dblaxial1.ToString(); double dblaxial2 = 0; contourPlate.GetUserProperty("axial2", ref dblaxial2); dblaxial2 = dblaxial2 * 0.001; axialEnd = dblaxial2.ToString(); double dblmoment1 = 0; contourPlate.GetUserProperty("moment1", ref dblmoment1); dblmoment1 = dblmoment1 * 0.001; momentStart = dblmoment1.ToString(); double dblmoment2 = 0; contourPlate.GetUserProperty("moment2", ref dblmoment2); dblmoment2 = dblmoment2 * 0.001; momentEnd = dblmoment2.ToString(); contourPlate.GetUserProperty("CONN_CODE_END1", ref connCodeStart); contourPlate.GetUserProperty("CONN_CODE_END2", ref connCodeEnd); model.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentTP); } } } if (modelObjectEnum.GetSize() > 1) { partType = ""; partID = ""; owner = ""; gridLocation = ""; partPrefix = ""; partStartNo = ""; assemblyPrefix = ""; assemblyStartNo = ""; phase = ""; name = ""; profile = ""; material = ""; finish = ""; classValue = ""; userfield1 = ""; userfield2 = ""; userfield3 = ""; userfield4 = ""; notesComments = ""; fittingNotes = ""; fittingNotes2 = ""; cambering = ""; paint = ""; preliminaryMark = ""; paintWFT = ""; paintDFT = ""; shearStart = ""; shearEnd = ""; axialStart = ""; axialEnd = ""; momentStart = ""; momentEnd = ""; connCodeStart = ""; connCodeEnd = ""; positionOnPlane = new PositionPlaneEnum(); positionOnPlaneOffset = ""; positionRotation = new PositionRotationEnum(); positionRotationOffset = ""; positionAtDepth = new PositionDepthEnum(); positionAtDepthOffset = ""; } }
private void UpdateProperties() { if (this.propertyGrid1.InvokeRequired) { UpdatePropertiesCallback d = new UpdatePropertiesCallback(UpdateProperties); this.Invoke(d); } else { Drawing drawing = drawingHandler.GetActiveDrawing(); if (drawing != null) { DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected(); statusLabel.Text = drawingObjectEnum.GetSize().ToString() + " objects selected"; ArrayList arraySelectedObjects = new ArrayList(); if (drawingObjectEnum.GetSize() == 0) { activeDrawing.GetProperties(); propertyGrid1.SelectedObject = activeDrawing; } while (drawingObjectEnum.MoveNext()) { string objectType = drawingObjectEnum.Current.GetType().ToString(); if (!arraySelectedObjects.Contains(objectType)) { arraySelectedObjects.Add(objectType); } } comboBox1.Text = ""; comboBox1.Items.Clear(); arraySelectedObjects.Sort(); foreach (string objectName in arraySelectedObjects) { comboBox1.Items.Add(objectName); } if (arraySelectedObjects.Count == 1) { if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Part") { drawingPart.GetProperties(); propertyGrid1.SelectedObject = drawingPart; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Weld") { drawingWeld.GetProperties(); propertyGrid1.SelectedObject = drawingWeld; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.View") { view.GetProperties(); propertyGrid1.SelectedObject = view; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Bolt") { drawingBolt.GetProperties(); propertyGrid1.SelectedObject = drawingBolt; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.StraightDimensionSet") { straightDim.GetProperties(); propertyGrid1.SelectedObject = straightDim; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.RadiusDimension") { radiusDim.GetProperties(); propertyGrid1.SelectedObject = radiusDim; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.CurvedDimensionSetRadial") { radialDim.GetProperties(); propertyGrid1.SelectedObject = radialDim; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.AngleDimension") { angleDim.GetProperties(); propertyGrid1.SelectedObject = angleDim; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.GridLine") { drawingGrid.GetProperties(); propertyGrid1.SelectedObject = drawingGrid; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Line") { line.GetProperties(); propertyGrid1.SelectedObject = line; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Arc") { arc.GetProperties(); propertyGrid1.SelectedObject = arc; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Polyline") { polyline.GetProperties(); propertyGrid1.SelectedObject = polyline; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Rectangle") { rectangle.GetProperties(); propertyGrid1.SelectedObject = rectangle; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Circle") { circle.GetProperties(); propertyGrid1.SelectedObject = circle; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Polygon") { polygon.GetProperties(); propertyGrid1.SelectedObject = polygon; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Text") { text.GetProperties(); propertyGrid1.SelectedObject = text; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Symbol") { symbol.GetProperties(); propertyGrid1.SelectedObject = symbol; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Drawing.Mark") { mark.GetProperties(); propertyGrid1.SelectedObject = mark; } else { activeDrawing.GetProperties(); propertyGrid1.SelectedObject = activeDrawing; } comboBox1.SelectedText = arraySelectedObjects[0].ToString(); propertyGrid1.Focus(); } if (arraySelectedObjects.Count > 1) { propertyGrid1.SelectedObject = null; } } if (drawing == null) { ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects(); statusLabel.Text = modelObjectEnum.GetSize().ToString() + " objects selected"; ArrayList arraySelectedObjects = new ArrayList(); if (modelObjectEnum.GetSize() == 0) { propertyGrid1.SelectedObject = null; } while (modelObjectEnum.MoveNext()) { string objectType = modelObjectEnum.Current.GetType().ToString(); if (!arraySelectedObjects.Contains(objectType)) { arraySelectedObjects.Add(objectType); } } comboBox1.Text = ""; comboBox1.Items.Clear(); arraySelectedObjects.Sort(); foreach (string objectName in arraySelectedObjects) { comboBox1.Items.Add(objectName); } if (arraySelectedObjects.Count == 0) { Tekla.Structures.Model.UI.ModelViewEnumerator modelViewEnum = Tekla.Structures.Model.UI.ViewHandler.GetSelectedViews(); if (modelViewEnum.Count == 1) { modelView.GetProperties(); propertyGrid1.SelectedObject = modelView; comboBox1.SelectedText = "Tekla.Structures.Model.UI.View"; propertyGrid1.Focus(); } } if (arraySelectedObjects.Count == 1) { if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Model.Beam") { beam.GetProperties(); propertyGrid1.SelectedObject = beam; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Model.ContourPlate") { contourPlate.GetProperties(); propertyGrid1.SelectedObject = contourPlate; } else if (arraySelectedObjects[0].ToString().Contains("Tekla.Structures.Model.Weld")) { modelWeld.GetProperties(); propertyGrid1.SelectedObject = modelWeld; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Model.PolygonWeld") { modelWeld.GetProperties(); propertyGrid1.SelectedObject = modelWeld; } else if (arraySelectedObjects[0].ToString().Contains("Tekla.Structures.Model.Bolt")) { modelBolt.GetProperties(); propertyGrid1.SelectedObject = modelBolt; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Model.Grid") { modelGrid.GetProperties(); propertyGrid1.SelectedObject = modelGrid; } else if (arraySelectedObjects[0].ToString() == "Tekla.Structures.Model.Connection") { modelConnection.GetProperties(); propertyGrid1.SelectedObject = modelConnection; } comboBox1.SelectedText = arraySelectedObjects[0].ToString(); propertyGrid1.Focus(); } if (arraySelectedObjects.Count > 1) { propertyGrid1.SelectedObject = null; } } } }
internal static void Run() { try { Operation.DisplayPrompt("Обработка…"); PleaseWaitForm pleaseWait = new PleaseWaitForm(); pleaseWait.Show(); Application.DoEvents(); Model model = new Model(); Tekla.Structures.Model.UI.ModelObjectSelector selector = new Tekla.Structures.Model.UI.ModelObjectSelector(); ModelObjectEnumerator selectedObjects = selector.GetSelectedObjects(); ModelObjectEnumerator objects; if (selectedObjects.GetSize() > 0) { objects = selectedObjects; } else { objects = model.GetModelObjectSelector().GetAllObjectsWithType(new Type[] { typeof(Assembly) }); } List <Detail> details = new List <Detail>(); List <Detail> unknownDetails = new List <Detail>(); if (objects.GetSize() > 0) { string ru_shifr = string.Empty; //model.GetProjectInfo().GetUserProperty("ru_shifr", ref ru_shifr); model.GetProjectInfo().GetUserProperty("grafa_1", ref ru_shifr); string ru_object_stroit_1 = string.Empty; string ru_object_stroit_2 = string.Empty; string ru_object_stroit_3 = string.Empty; //model.GetProjectInfo().GetUserProperty("ru_objekt_stroit_1", ref ru_object_stroit_1); //model.GetProjectInfo().GetUserProperty("ru_objekt_stroit_2", ref ru_object_stroit_2); //model.GetProjectInfo().GetUserProperty("ru_objekt_stroit_3", ref ru_object_stroit_3); model.GetProjectInfo().GetUserProperty("grafa_2", ref ru_object_stroit_1); string ru_naimen_stroit_1 = string.Empty; string ru_naimen_stroit_2 = string.Empty; string ru_naimen_stroit_3 = string.Empty; //model.GetProjectInfo().GetUserProperty("ru_naimen_stroit_1", ref ru_naimen_stroit_1); //model.GetProjectInfo().GetUserProperty("ru_naimen_stroit_2", ref ru_naimen_stroit_2); //model.GetProjectInfo().GetUserProperty("ru_naimen_stroit_3", ref ru_naimen_stroit_3); model.GetProjectInfo().GetUserProperty("grafa_3", ref ru_naimen_stroit_1); string ru_6 = string.Empty; string ru_7 = string.Empty; string ru_8 = string.Empty; string ru_9 = string.Empty; string ru_10 = string.Empty; string ru_11 = string.Empty; //model.GetProjectInfo().GetUserProperty("ru_6", ref ru_6); //model.GetProjectInfo().GetUserProperty("ru_7", ref ru_7); //model.GetProjectInfo().GetUserProperty("ru_8", ref ru_8); //model.GetProjectInfo().GetUserProperty("ru_9", ref ru_9); //model.GetProjectInfo().GetUserProperty("ru_10", ref ru_10); //model.GetProjectInfo().GetUserProperty("ru_11", ref ru_11); string ru_6_fam = string.Empty; string ru_7_fam = string.Empty; string ru_8_fam = string.Empty; string ru_9_fam = string.Empty; string ru_10_fam = string.Empty; string ru_11_fam = string.Empty; //model.GetProjectInfo().GetUserProperty("ru_6_fam", ref ru_6_fam); //model.GetProjectInfo().GetUserProperty("ru_7_fam", ref ru_7_fam); //model.GetProjectInfo().GetUserProperty("ru_8_fam", ref ru_8_fam); //model.GetProjectInfo().GetUserProperty("ru_9_fam", ref ru_9_fam); //model.GetProjectInfo().GetUserProperty("ru_10_fam", ref ru_10_fam); //model.GetProjectInfo().GetUserProperty("ru_11_fam", ref ru_11_fam); model.GetProjectInfo().GetUserProperty("razrabotal", ref ru_6_fam); model.GetProjectInfo().GetUserProperty("proveril", ref ru_7_fam); model.GetProjectInfo().GetUserProperty("nach_gruppy", ref ru_8_fam); model.GetProjectInfo().GetUserProperty("n_control", ref ru_9_fam); model.GetProjectInfo().GetUserProperty("nach_otdela", ref ru_10_fam); model.GetProjectInfo().GetUserProperty("glav_eng", ref ru_11_fam); string ru_stadiya = string.Empty; //model.GetProjectInfo().GetUserProperty("ru_stadiya", ref ru_stadiya); model.GetProjectInfo().GetUserProperty("grafa_6", ref ru_stadiya); string ru_listov = string.Empty; //model.GetProjectInfo().GetUserProperty("ru_listov", ref ru_listov); model.GetProjectInfo().GetUserProperty("grafa_8", ref ru_listov); int ru_listov_int = 0; int.TryParse(ru_listov, out ru_listov_int); string ru_nazvanie_org_1 = string.Empty; string ru_nazvanie_org_2 = string.Empty; string ru_nazvanie_org_3 = string.Empty; //model.GetProjectInfo().GetUserProperty("ru_nazvanie_org_1", ref ru_nazvanie_org_1); //model.GetProjectInfo().GetUserProperty("ru_nazvanie_org_2", ref ru_nazvanie_org_2); //model.GetProjectInfo().GetUserProperty("ru_nazvanie_org_3", ref ru_nazvanie_org_3); model.GetProjectInfo().GetUserProperty("grafa_9", ref ru_nazvanie_org_1); string[] categories = new string[14]; model.GetProjectInfo().GetUserProperty("cm_kat_5", ref categories[0]); model.GetProjectInfo().GetUserProperty("cm_kat_6", ref categories[1]); model.GetProjectInfo().GetUserProperty("cm_kat_7", ref categories[2]); model.GetProjectInfo().GetUserProperty("cm_kat_8", ref categories[3]); model.GetProjectInfo().GetUserProperty("cm_kat_9", ref categories[4]); model.GetProjectInfo().GetUserProperty("cm_kat_10", ref categories[5]); model.GetProjectInfo().GetUserProperty("cm_kat_11", ref categories[6]); model.GetProjectInfo().GetUserProperty("cm_kat_12", ref categories[7]); model.GetProjectInfo().GetUserProperty("cm_kat_13", ref categories[8]); model.GetProjectInfo().GetUserProperty("cm_kat_14", ref categories[9]); model.GetProjectInfo().GetUserProperty("cm_kat_15", ref categories[10]); model.GetProjectInfo().GetUserProperty("cm_kat_16", ref categories[11]); model.GetProjectInfo().GetUserProperty("cm_kat_17", ref categories[12]); model.GetProjectInfo().GetUserProperty("cm_kat_18", ref categories[13]); bool isNonAssemblyExist = false; while (objects.MoveNext()) { ModelObject obj = objects.Current as ModelObject; if (obj != null) { if (obj is Assembly) { Assembly assy = obj as Assembly; if (assy.GetAssemblyType() == Assembly.AssemblyTypeEnum.STEEL_ASSEMBLY) { int assyCategory = 0; bool result = assy.GetUserProperty("cm_kat", ref assyCategory); if (result) { assyCategory += 5; } List <Part> descendants = new List <Part>(); TeklaUtils.GetDescendants(assy, ref descendants); foreach (Part part in descendants) { string standard = string.Empty; string profile = part.Profile.ProfileString; string material = string.Empty; part.GetReportProperty("MATERIAL", ref material); double weight = 0.0; part.GetReportProperty("WEIGHT", ref weight); weight /= 1000; double length = 0.0; part.GetReportProperty("LENGTH", ref length); int sortOrder = 0; string fireResist = string.Empty; part.GetUserProperty("FIRE_RESIST_VNP", ref fireResist); if ((part is Beam) || (part is PolyBeam)) { string temp = part.Profile.ProfileString.ToUpper(); if (temp.StartsWith("—") || (temp.StartsWith("PL")) || (temp.StartsWith("BL")) || (temp.StartsWith("FL")) || (temp.StartsWith("BPL")) || (temp.StartsWith("FLT")) || (temp.StartsWith("FPL")) || (temp.StartsWith("PLT")) || (temp.StartsWith("PLATE")) || (temp.StartsWith("TANKO")) || (temp.StartsWith("ПОЛОСА"))) { details.Add(new Detail(part, assyCategory, "ГОСТ 19903-74", $"Лист {temp.Substring(temp.IndexOf("*") + 1)}", material, weight, 4, fireResist)); } else if (temp.StartsWith("ПВ")) { details.Add(new Detail(part, assyCategory, "ГОСТ 8706-78", $"Лист {temp.Substring(temp.IndexOf("*") + 1)}", "C235", weight, 13, fireResist)); } else if (temp.StartsWith("РИФ")) { details.Add(new Detail(part, assyCategory, "ГОСТ 8568-77", $"Лист {temp.Substring(temp.IndexOf("*") + 1)}", "C235", weight, 14, fireResist)); } else if (temp.StartsWith("ЧРИФ")) { details.Add(new Detail(part, assyCategory, "ГОСТ 8568-77", $"Лист {temp.Substring(temp.IndexOf("*") + 1)}", "C235", weight, 15, fireResist)); } else { LibraryProfileItem profileItem = new LibraryProfileItem(); profileItem.ProfileName = part.Profile.ProfileString; profileItem.Select(); ArrayList parameters = profileItem.aProfileItemUserParameters; if (parameters.Count > 0) { foreach (ProfileItemParameter parameter in parameters) { if (parameter.Property == "GOST_NAME") { standard = parameter.StringValue; } if (parameter.Property == "TPL_SORT") { int.TryParse(parameter.StringValue, out sortOrder); } } details.Add(new Detail(part, assyCategory, standard, profile, material, weight, sortOrder, fireResist)); } else { unknownDetails.Add(new Detail(part, assyCategory, "???", profile, material, weight, 999, fireResist)); } } } else if (part is ContourPlate) { string temp = part.Profile.ProfileString.ToUpper(); if (temp.StartsWith("—")) { details.Add(new Detail(part, assyCategory, "ГОСТ 19903-74", $"Лист {temp.Substring(1)}", material, weight, 4, fireResist)); } else if ((temp.StartsWith("PL")) || (temp.StartsWith("BL")) || (temp.StartsWith("FL"))) { details.Add(new Detail(part, assyCategory, "ГОСТ 19903-74", $"Лист {temp.Substring(2)}", material, weight, 4, fireResist)); } else if ((temp.StartsWith("BPL")) || (temp.StartsWith("FLT")) || (temp.StartsWith("FPL")) || (temp.StartsWith("PLT"))) { details.Add(new Detail(part, assyCategory, "ГОСТ 19903-74", $"Лист {temp.Substring(3)}", material, weight, 4, fireResist)); } else if ((temp.StartsWith("PLATE")) || (temp.StartsWith("TANKO"))) { details.Add(new Detail(part, assyCategory, "ГОСТ 19903-74", $"Лист {temp.Substring(5)}", material, weight, 4, fireResist)); } else if (temp.StartsWith("ПОЛОСА")) { details.Add(new Detail(part, assyCategory, "ГОСТ 19903-74", $"Лист {temp.Substring(6)}", material, weight, 4, fireResist)); } else if (temp.StartsWith("ПВ")) { details.Add(new Detail(part, assyCategory, "ГОСТ 8706-78", $"Лист {temp.Substring(2)}", "C235", weight, 13, fireResist)); } else if (temp.StartsWith("РИФ")) { details.Add(new Detail(part, assyCategory, "ГОСТ 8568-77", $"Лист {temp.Substring(3)}", "C235", weight, 14, fireResist)); } else if (temp.StartsWith("ЧРИФ")) { details.Add(new Detail(part, assyCategory, "ГОСТ 8568-77", $"Лист {temp.Substring(4)}", "C235", weight, 15, fireResist)); } else { unknownDetails.Add(new Detail(part, assyCategory, "???", $"{part.Profile.ProfileString}", material, weight, 999, fireResist)); } } } } } else { if (!(obj is Grid)) { isNonAssemblyExist = true; } } } } if (isNonAssemblyExist == true) { MessageBox.Show("Среди выбранных объектов есть объекты не являющиеся сборками.\r\nВыберите только сборки или не выбирайте ничего и запустите программу снова.", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); pleaseWait.Close(); pleaseWait.Dispose(); Operation.DisplayPrompt("Ошибка."); return; } IEnumerable <StandardGroup> groups = from d in details orderby d.SortOrder group d by d.StandardFull into g select new StandardGroup() { Key = g.Key, materials = from d in g orderby d.MaterialFull group d by d.MaterialFull into g2 select new MaterialGroup() { Key = g2.Key, profiles = from d in g2 orderby d.Profile group d by d.Profile into g3 select new ProfileGroup() { Key = g3.Key, categories = from d in g3 orderby d.Category group d by d.Category into g4 select new CategoryGroup() { Key = g4.Key, fireResists = from d in g4 group d by d.FireResist into g5 select g5 } } } }; JObject json = new JObject( new JProperty("ID", 0), new JProperty("Name", null), new JProperty("Profiles", null), new JProperty("Revision", 0), new JProperty("AntiCor", false), new JProperty("Cipher", ru_shifr), new JProperty("BuildingObject1", ru_object_stroit_1), new JProperty("BuildingObject2", ru_object_stroit_2), new JProperty("BuildingObject3", ru_object_stroit_3), new JProperty("BuildingName1", ru_naimen_stroit_1), new JProperty("BuildingName2", ru_naimen_stroit_2), new JProperty("BuildingName3", ru_naimen_stroit_3), new JProperty("AttName6", ru_6), new JProperty("AttName7", ru_7), new JProperty("AttName8", ru_8), new JProperty("AttName9", ru_9), new JProperty("AttName10", ru_10), new JProperty("AttName11", ru_11), new JProperty("AttValue6", ru_6_fam), new JProperty("AttValue7", ru_7_fam), new JProperty("AttValue8", ru_8_fam), new JProperty("AttValue9", ru_9_fam), new JProperty("AttValue10", ru_10_fam), new JProperty("AttValue11", ru_11_fam), new JProperty("Stage", ru_stadiya), new JProperty("Sheets", ru_listov_int), new JProperty("OrganzitaionName1", ru_nazvanie_org_1), new JProperty("OrganzitaionName2", ru_nazvanie_org_2), new JProperty("OrganzitaionName3", ru_nazvanie_org_3), new JProperty("Headers", new JArray(categories)), new JProperty("Documents", new JArray( from p in groups select new JObject( new JProperty("ID", 0), new JProperty("Name", p.Key), new JProperty("ProfilesTotal", new JArray()), new JProperty("ProfilesCount", 0), new JProperty("TotalWeight", 0), new JProperty("IsSelected", false), new JProperty("IsModified", false), new JProperty("Materials", new JArray( from q in p.materials select new JObject( new JProperty("ID", 0), new JProperty("Name", q.Key), new JProperty("TotalConstructionsWeight", new JArray()), new JProperty("TotalWeight", 0), new JProperty("IsSelected", false), new JProperty("IsModified", false), new JProperty("Profiles", new JArray( from r in q.profiles select new JObject( new JProperty("ID", 0), new JProperty("Name", r.Key), new JProperty("Tag", null), new JProperty("ProfileItems", new JArray()), new JProperty("Weight", 0), new JProperty("IsModified", false), new JProperty("ConstructionTypes", new JArray( new JObject( new JProperty("Name", ""), new JProperty("Constructions", new JArray( from s in r.categories select new JObject( new JProperty("ID", s.Key), new JProperty("Name", ""), new JProperty("Count", GetConstructionWeight(s)), new JProperty("Profiles", null), new JProperty("IsModified", false), new JProperty("FireResists", new JArray( from t in s.fireResists select new JObject( new JProperty("Name", t.Key), new JProperty("Count", GetFireResistWeight(t)) ))))))))))))))))))); string jsonFilePath = $"{Environment.GetEnvironmentVariable("USERPROFILE")}\\TeklaMetalSpec.json"; using (StreamWriter writer = new StreamWriter(jsonFilePath, false, Encoding.UTF8)) { writer.Write(json.ToString()); } } pleaseWait.Close(); pleaseWait.Dispose(); Operation.DisplayPrompt("Завершено."); } catch (Exception ex) { MessageBox.Show($"{ex.StackTrace}\r\n\r\n{ex.Message}"); } }
private void btn_Get_Assembly_Click(object sender, EventArgs e) { TSMUI.Picker thisPicker = new TSMUI.Picker(); Part pickedPart = null; try { pickedPart = thisPicker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART) as Part; } catch { pickedPart = null; } if (pickedPart != null) { Assembly thisAssembly = pickedPart.GetAssembly(); ModelObject mainObject = thisAssembly.GetMainPart(); Part mainPart = mainObject as Part; if (mainPart != null) { mainPart.Class = "2"; mainPart.Modify(); // Don't grab from assembly because it doesn't have one... mainPart.GetCoordinateSystem(); // Set the mainPart of the assembly. // thisAssembly.setMainPart(pickedPart); } else { Assembly mainAssembly = mainObject as Assembly; if (mainAssembly != null) { // You got an assembly... } } // This doesn't do anything, don't use it ModelObjectEnumerator partsOnAssembly = thisAssembly.GetChildren(); int childrenObjects = partsOnAssembly.GetSize(); // Gets Parts ArrayList partsList = thisAssembly.GetSecondaries(); foreach (Part thisPart in partsList) { thisPart.Class = "6"; thisPart.Modify(); } // Neat way to highlight / select objects in the model. TSMUI.ModelObjectSelector selector = new TSMUI.ModelObjectSelector(); selector.Select(partsList); // Gets Sub Assemblies int subAssemblies = thisAssembly.GetSubAssemblies().Count; Tekla.Structures.Model.Operations.Operation.DisplayPrompt(childrenObjects + " Children Objects"); currentModel.CommitChanges(); } }