public override bool Run(List <InputDefinition> input) { try { Tekla.Structures.Identifier id = (Tekla.Structures.Identifier)(input[0]).GetInput(); Tekla.Structures.Model.Model model = new TSM.Model(); TSM.Beam beam = (TSM.Beam)model.SelectModelObject(id); model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TSM.TransformationPlane()); TSM.TransformationPlane currentTP = model.GetWorkPlaneHandler().GetCurrentTransformationPlane(); CoordinateSystem coordenadasMuro = beam.GetCoordinateSystem(); model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TSM.TransformationPlane(coordenadasMuro)); ParametrosPanel p = new ParametrosPanel(beam); p.dx = data.dx; p.dy = data.dy; p.diametroBarras = data.diametroBarras; p.diametroDiagonal = data.diametroDiagonales; p.adicionalDerecha = data.largoDerecha; p.adicionalIzquierda = data.largoIzquierda; p.adicionalSuperior = data.largoSuperior; p.adicionalInferior = data.largoInferior; PanelMoldar panel = new PanelMoldar(p); panel.fabricar(); model.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentTP); } catch (Exception ex) { ErrorDialog.Show("Exception", ex.Message, ErrorDialog.Severity.ERROR); } return(true); }
private void btn_multiBeams_Click(object sender, EventArgs e) { try { Picker picker = new Picker(); ArrayList points = picker.PickPoints(Picker.PickPointEnum.PICK_POLYGON); if (points.Count >= 3) { TSG.Point start = new TSG.Point(0, 0, 0); TSG.Point middle = new TSG.Point(0, 0, 0); TSG.Point end = new TSG.Point(0, 0, 0); TSG.Vector vectorFit = new TSG.Vector(); TSG.Vector vectorZ = new TSG.Vector(); TSG.Vector vectorOne = new TSG.Vector(); TSG.Vector vectorTwo = new TSG.Vector(); ArrayList listBeams = new ArrayList(); ArrayList listPlates = new ArrayList(); double angelDegree = 0.0; for (int i = 0; i < points.Count - 1; i++) { TSM.Beam beam = BeamFirst(points[i] as TSG.Point, points[i + 1] as TSG.Point); beam.Insert(); listBeams.Add(beam); this.model.CommitChanges(); } double primaryWidth = 0.0; double primaryHeight = 0.0; for (int i = 0; i < points.Count - 1; i++) { try { start = points[i] as TSG.Point; middle = points[i + 1] as TSG.Point; end = points[i + 2] as TSG.Point; } catch { } vectorOne = new TSG.Vector(middle.X - start.X, middle.Y - start.Y, middle.Z - start.Z); vectorOne.Normalize(); vectorTwo = new TSG.Vector(middle.X - end.X, middle.Y - end.Y, middle.Z - end.Z); vectorTwo.Normalize(); double angle = vectorOne.GetAngleBetween(vectorTwo); angelDegree = angle * 180 / Math.PI; //TSG.Vector vectorFit = new TSG.Vector(1 * Math.Cos(angle / 2), 1 * Math.Cos(angle / 2), 0); vectorFit = new TSG.Vector(vectorOne.X + vectorTwo.X, vectorOne.Y + vectorTwo.Y, vectorOne.Z + vectorTwo.Z); vectorZ = vectorOne.Cross(vectorTwo); TSG.CoordinateSystem coordinateSystem = new TSG.CoordinateSystem(); double thick; if (tb_thcikPlates.Text != string.Empty) { double.TryParse(tb_thcikPlates.Text, out thick); } else { thick = 20.0; } double offset = thick; double angleFD = 90 - (angelDegree / 2); double angleFR = Math.PI * angleFD / 180; double width = 0.0; double heigth = 0.0; double x = Math.Round(vectorFit.X, 2, MidpointRounding.ToEven); double y = Math.Round(vectorFit.Y, 2, MidpointRounding.ToEven); double z = Math.Round(vectorFit.Z, 2, MidpointRounding.ToEven); TSM.Beam beam1 = listBeams[i] as TSM.Beam; TSM.Beam beam2 = listBeams[i + 1] as TSM.Beam; beam1.GetReportProperty("WIDTH", ref primaryWidth); beam1.GetReportProperty("HEIGHT", ref primaryHeight); if (x == 0.0 && y == 0.0 && z == 0.0) { TSG.Vector bAxisX = beam1.GetCoordinateSystem().AxisX; TSG.Vector bAxisY = beam1.GetCoordinateSystem().AxisY; TSG.Vector bAxisZ = bAxisY.Cross(bAxisX); coordinateSystem = new TSG.CoordinateSystem(middle, bAxisZ, bAxisY); } else { coordinateSystem = new TSG.CoordinateSystem( middle, vectorFit, vectorZ); } TSM.WorkPlaneHandler planeHandler = model.GetWorkPlaneHandler(); TSM.TransformationPlane original = planeHandler.GetCurrentTransformationPlane(); TSM.TransformationPlane beamPlane = new TSM.TransformationPlane(coordinateSystem); planeHandler.SetCurrentTransformationPlane(beamPlane); FitBeam(beam1, -offset); FitBeam(beam2, offset); if (z != 0) { vectorZ = vectorTwo.Cross(vectorOne); planeHandler.SetCurrentTransformationPlane(original); TSG.CoordinateSystem coordinatePlate = new TSG.CoordinateSystem( middle, vectorZ, vectorFit); TSM.TransformationPlane beamPlate = new TSM.TransformationPlane(coordinatePlate); planeHandler.SetCurrentTransformationPlane(beamPlate); width = primaryWidth; heigth = 50 + primaryHeight / (Math.Cos(angleFR)); } else { width = 50 + primaryWidth / (Math.Cos(angleFR)); heigth = primaryHeight; } bool positionPlate = true; for (int k = 0; k < 2; k++) { TSM.ContourPlate plate = PlateFirst(width, heigth, offset); if (positionPlate) { plate.Position.Depth = TSM.Position.DepthEnum.BEHIND; positionPlate = false; } else { plate.Position.Depth = TSM.Position.DepthEnum.FRONT; } plate.Insert(); listPlates.Add(plate); } TSM.ContourPlate plate1 = listPlates[0] as TSM.ContourPlate; TSM.ContourPlate plate2 = listPlates[1] as TSM.ContourPlate; BoltPlatetoPlate(plate1, plate2, heigth, width); WeldBeamToPlate(beam1, plate1); WeldBeamToPlate(beam2, plate2); planeHandler.SetCurrentTransformationPlane(original); this.model.CommitChanges(); listPlates.Clear(); } this.model.CommitChanges(); listBeams.Clear(); } else { MessageBox.Show(Tekla.Structures.Dialog.UIControls.LocalizeForm.Localization.GetText("albl_Invalid_input_parts"));//translation of text in message box } } catch { } }