Exemple #1
0
        /// <summary>Checks if the point is on the line segment. Line segment is the fragment of line in 3d with start point and end point. Method should be private but in public may be usefull</summary>
        /// <param name="lineSegment">The line segment</param>
        /// <param name="point">The point to check</param>
        /// <returns>Return true if point is on the line segment between start and end point. Otherwise return false.</returns>
        public static bool IsThePointOnTheLineSegment(T3D.LineSegment lineSegment, T3D.Point point)
        {
            if (T3D.Distance.PointToPoint(lineSegment.Point1, point) < 0.1)
            {
                return(true);
            }
            if (T3D.Distance.PointToPoint(lineSegment.Point2, point) < 0.1)
            {
                return(true);
            }

            var vector1 = new T3D.Vector(lineSegment.Point1 - point);
            var vector2 = new T3D.Vector(lineSegment.Point2 - point);

            return(Math.Abs(vector1.GetAngleBetween(vector2) - Math.PI) < 0.001);
        }
Exemple #2
0
        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
            {
            }
        }