public static dynamic GetTSObject(BoltCircle dynObject) { if (dynObject is null) { return(null); } return(dynObject.teklaObject); }
public void Modify(PropertyValueChangedEventArgs e) { string label = e.ChangedItem.Label; ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects(); while (modelObjectEnum.MoveNext()) { if (modelObjectEnum.Current is BoltGroup) { BoltGroup bolt = (BoltGroup)modelObjectEnum.Current; if (label == "BoltSize") { bolt.BoltSize = double.Parse(boltSize); } if (label == "BoltStandard") { bolt.BoltStandard = boltStandard; // list to sort } if (label == "BoltType") { if (boltType == BoltTypeEnum.Site) { bolt.BoltType = BoltGroup.BoltTypeEnum.BOLT_TYPE_SITE; } if (boltType == BoltTypeEnum.Workshop) { bolt.BoltType = BoltGroup.BoltTypeEnum.BOLT_TYPE_WORKSHOP; } } if (label == "ThreadMaterial") { if (threadMaterial == ThreadMaterialEnum.No) { bolt.ThreadInMaterial = BoltGroup.BoltThreadInMaterialEnum.THREAD_IN_MATERIAL_NO; } if (threadMaterial == ThreadMaterialEnum.Yes) { bolt.ThreadInMaterial = BoltGroup.BoltThreadInMaterialEnum.THREAD_IN_MATERIAL_YES; } } if (label == "CutLength") { bolt.CutLength = double.Parse(cutLength); } if (label == "ExtraLength") { bolt.ExtraLength = double.Parse(extraLength); } if (label == "BoltShaft") { bolt.Bolt = bool.Parse(boltShaft.ToString()); } if (label == "Washer1") { bolt.Washer1 = bool.Parse(washer1.ToString()); } if (label == "Washer2") { bolt.Washer2 = bool.Parse(washer2.ToString()); } if (label == "Washer3") { bolt.Washer3 = bool.Parse(washer3.ToString()); } if (label == "Nut1") { bolt.Nut1 = bool.Parse(nut1.ToString()); } if (label == "Nut2") { bolt.Nut2 = bool.Parse(nut2.ToString()); } if (label == "BoltDistX") { if (bolt is BoltArray) { BoltArray boltArray = (BoltArray)bolt; int boltArrayCount = boltArray.GetBoltDistXCount(); for (int i = boltArrayCount - 1; i >= 0; i--) { boltArray.RemoveBoltDistX(i); boltArray.Modify(); } if (boltDistX != "") { string[] splitSpaces = boltDistX.Split(new Char[] { ' ' }); System.Collections.ArrayList arr = new System.Collections.ArrayList(); foreach (string stringText in splitSpaces) { if (stringText.Contains("*")) { string[] splitMultiplier = stringText.Split(new Char[] { '*' }); for (int i = 0; i < int.Parse(splitMultiplier[0]); i++) { arr.Add(double.Parse(splitMultiplier[1].ToString())); } } else { arr.Add(double.Parse(stringText)); } } for (int i = 0; i < arr.Count; i++) { boltArray.SetBoltDistX(i, double.Parse(arr[i].ToString())); } } } else if (bolt is BoltXYList) { MessageBox.Show("Buggered"); } else if (bolt is BoltCircle) { BoltCircle boltCircle = (BoltCircle)bolt; boltCircle.NumberOfBolts = double.Parse(boltDistX); } } if (label == "BoltDistY") { if (bolt is BoltArray) { BoltArray boltArray = (BoltArray)bolt; int boltArrayCount = boltArray.GetBoltDistYCount(); for (int i = boltArrayCount - 1; i >= 0; i--) { boltArray.RemoveBoltDistY(i); boltArray.Modify(); } if (boltDistY != "") { string[] splitSpaces = boltDistY.Split(new Char[] { ' ' }); System.Collections.ArrayList arr = new System.Collections.ArrayList(); foreach (string stringText in splitSpaces) { if (stringText.Contains("*")) { string[] splitMultiplier = stringText.Split(new Char[] { '*' }); for (int i = 0; i < int.Parse(splitMultiplier[0]); i++) { arr.Add(double.Parse(splitMultiplier[1].ToString())); } } else { arr.Add(double.Parse(stringText)); } } for (int i = 0; i < arr.Count; i++) { boltArray.SetBoltDistY(i, double.Parse(arr[i].ToString())); } } } else if (bolt is BoltXYList) { MessageBox.Show("Buggered"); } else if (bolt is BoltCircle) { BoltCircle boltCircle = (BoltCircle)bolt; boltCircle.Diameter = double.Parse(boltDistY); } } if (label == "Tolerance") { bolt.Tolerance = double.Parse(tolerance); } if (label == "HoleType") { if (holeType == HoleTypeEnum.Slotted) { bolt.HoleType = BoltGroup.BoltHoleTypeEnum.HOLE_TYPE_SLOTTED; } if (holeType == HoleTypeEnum.Oversized) { bolt.HoleType = BoltGroup.BoltHoleTypeEnum.HOLE_TYPE_OVERSIZED; } } if (label == "SlottedHoleX") { bolt.SlottedHoleX = double.Parse(slottedHoleX); } if (label == "SlottedHoleY") { bolt.SlottedHoleY = double.Parse(slottedHoleY); } if (label == "RotateSlots") { if (rotateSlots == RotateSlotEnum.Even) { bolt.RotateSlots = BoltGroup.BoltRotateSlotsEnum.ROTATE_SLOTS_EVEN; } if (rotateSlots == RotateSlotEnum.Odd) { bolt.RotateSlots = BoltGroup.BoltRotateSlotsEnum.ROTATE_SLOTS_ODD; } if (rotateSlots == RotateSlotEnum.Parallel) { bolt.RotateSlots = BoltGroup.BoltRotateSlotsEnum.ROTATE_SLOTS_PARALLEL; } } if (label == "Hole1") { bolt.Hole1 = bool.Parse(hole1.ToString()); } if (label == "Hole2") { bolt.Hole2 = bool.Parse(hole2.ToString()); } if (label == "Hole3") { bolt.Hole3 = bool.Parse(hole3.ToString()); } if (label == "Hole4") { bolt.Hole4 = bool.Parse(hole4.ToString()); } if (label == "Hole5") { bolt.Hole5 = bool.Parse(hole5.ToString()); } if (label == "OffsetFromStartX") { bolt.StartPointOffset.Dx = double.Parse(offsetFromStartX); } if (label == "OffsetFromStartY") { bolt.StartPointOffset.Dy = double.Parse(offsetFromStartY); } if (label == "OffsetFromStartZ") { bolt.StartPointOffset.Dz = double.Parse(offsetFromStartZ); } if (label == "OffsetFromEndX") { bolt.EndPointOffset.Dx = double.Parse(offsetFromEndX); } if (label == "OffsetFromEndY") { bolt.EndPointOffset.Dy = double.Parse(offsetFromEndY); } if (label == "OffsetFromEndZ") { bolt.EndPointOffset.Dz = double.Parse(offsetFromEndZ); } if (label == "PositionOnPlaneOffset") { bolt.Position.PlaneOffset = double.Parse(positionOnPlaneOffset); } if (label == "PositionRotation") { if (positionRotation == PositionRotationEnum.Back) { bolt.Position.Rotation = Position.RotationEnum.BACK; } if (positionRotation == PositionRotationEnum.Below) { bolt.Position.Rotation = Position.RotationEnum.BELOW; } if (positionRotation == PositionRotationEnum.Front) { bolt.Position.Rotation = Position.RotationEnum.FRONT; } if (positionRotation == PositionRotationEnum.Top) { bolt.Position.Rotation = Position.RotationEnum.TOP; } } if (label == "PositionRotationOffset") { bolt.Position.RotationOffset = double.Parse(positionRotationOffset); } if (label == "At Depth Offset") { bolt.Position.DepthOffset = double.Parse(positionAtDepthOffset); } bolt.Modify(); } } }
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(); } }