public void CK10_ApplyFitting()
        {
            // Current Workplane. Reminder how the user had the model before you did stuff.
            TransformationPlane CurrentPlane = Model.GetWorkPlaneHandler().GetCurrentTransformationPlane();

            Picker Picker     = new Picker();
            Beam   PickedBeam = null;

            try
            {
                PickedBeam = (Beam)Picker.PickObject(Picker.PickObjectEnum.PICK_ONE_PART);
            }
            catch { PickedBeam = null; }
            if (PickedBeam != null)
            {
                // Change the workplane to the coordinate system of the Beam
                var psk = new TransformationPlane(PickedBeam.GetCoordinateSystem());
                Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(psk);

                // Applyfitting
                Fitting BeamFitting = new Fitting();
                BeamFitting.Father = PickedBeam;
                Plane FittingPlane = new Plane();
                FittingPlane.Origin = new T3D.Point(500, 0, 0);
                FittingPlane.AxisX  = new T3D.Vector(0, 0, 500);
                FittingPlane.AxisY  = new T3D.Vector(0, -500, 0);
                BeamFitting.Plane   = FittingPlane;
                BeamFitting.Insert();

                // Apply Line Cut
                CutPlane BeamLineCut = new CutPlane();
                BeamLineCut.Father = PickedBeam;
                Plane BeamCutPlane = new Plane();
                BeamCutPlane.Origin = new T3D.Point(200, 0, 0);
                BeamCutPlane.AxisX  = new T3D.Vector(0, 0, 500);
                // Changing the positive vs. negative value here determines which direction
                // the line cut will take away material where as fitting looks at which end
                // of beam it is closest to figure out how to cut.
                BeamCutPlane.AxisX = new T3D.Vector(0, -500, 0);
                BeamLineCut.Plane  = BeamCutPlane;
                BeamLineCut.Insert();

                // SetWorkplane back to what user had before
                Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(CurrentPlane);

                // Show the plate in the model and the workplane change
                Model.CommitChanges();

                // Draw Positive Z axis.
                GraphicsDrawer Drawer = new GraphicsDrawer();
                var            red    = new Color(1, 0, 0);
                Drawer.DrawLineSegment(new T3D.Point(0, 0, 0), new T3D.Point(0, 0, 500), red);
            }
            Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane());
        }
        private void CuttingBeam(Part beam, Point inputPt, Vector axisX, Vector axisY)
        {
            Fitting cuttingBeam = new Fitting();

            cuttingBeam.Plane        = new Plane();
            cuttingBeam.Plane.Origin = inputPt;
            cuttingBeam.Plane.AxisX  = axisX;
            cuttingBeam.Plane.AxisY  = axisY;
            cuttingBeam.Father       = beam;
            cuttingBeam.Insert();
        }
示例#3
0
        private void btnApplyFitting_Click(object sender, EventArgs e)
        {
            // Current workplane. Remember how the user had the model before you changed things.
            TransformationPlane currentPlane = currentModel.GetWorkPlaneHandler().GetCurrentTransformationPlane();

            TSMUI.Picker myPicker    = new TSMUI.Picker();
            Beam         currentBeam = null;

            try
            {
                currentBeam = myPicker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART) as Beam;
            }
            catch
            {
                currentBeam = null;
            }

            if (currentBeam != null)
            {
                // Change the workplane to the coordinate system of the beam.
                currentModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane(currentBeam.GetCoordinateSystem()));

                // Apply fitting
                Fitting beamFitting = new Fitting();
                beamFitting.Father = currentBeam;
                Plane fittingPlane = new Plane();
                fittingPlane.Origin = new T3D.Point(500, 0, 0);
                fittingPlane.AxisX  = new T3D.Vector(0, 0, 500);
                fittingPlane.AxisY  = new T3D.Vector(0, 500, 0);
                beamFitting.Plane   = fittingPlane;
                beamFitting.Insert();

                // Apply cut line
                CutPlane beamLineCut = new CutPlane();
                beamLineCut.Father = currentBeam;
                Plane beamCutPlane = new Plane();
                beamCutPlane.Origin = new T3D.Point(2000, 0, 0);
                beamCutPlane.AxisX  = new T3D.Vector(0, 0, 500);
                // Changing positive vs. negative value here determines which direction
                // the line cut will take away material where as fittin glooks at which end
                // of the beam it is closest to to figure out how to cut
                beamCutPlane.AxisY = new T3D.Vector(0, -500, 0);
                beamLineCut.Plane  = beamCutPlane;
                beamLineCut.Insert();

                // Setworkplane back to what user had before
                currentModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentPlane);

                // Show the fitting in the model but the user will never see the workplane change
                currentModel.CommitChanges();
            }
        }
示例#4
0
        public void FittingBeamByFace()
        {
            Beam           beam      = PickBeam();
            GeometricPlane geomPlane = PickFace();

            Fitting fitting = new Fitting();

            fitting.Father = beam;
            CoordinateSystem beamCS = beam.GetCoordinateSystem();

            ReperShow(beamCS);
            Line lineAlongBeamAxisX = new Line(beamCS.Origin, beamCS.AxisX);

            //do u need Z asis
            //T3D.Vector axisZ = beamCS.
            T3D.Point intersectionPoint = Intersection.LineToPlane(lineAlongBeamAxisX, geomPlane);
            PointShow(intersectionPoint, "intersectionPoint");

            T3D.Point randomPoint = new T3D.Point(intersectionPoint + new T3D.Point(500, 500, 500));
            PointShow(randomPoint, "randomPoint");
            randomPoint = Projection.PointToPlane(randomPoint, geomPlane);
            PointShow(randomPoint, "Projected randomPoint");
            T3D.Vector       x        = new T3D.Vector(randomPoint - intersectionPoint);
            T3D.Vector       y        = geomPlane.Normal.Cross(x);
            CoordinateSystem itersect = new CoordinateSystem(intersectionPoint, x, y);

            ReperShow(itersect);

            Plane plane = new Plane();

            plane.Origin = intersectionPoint;
            plane.AxisX  = x;
            plane.AxisY  = y;
            x.Normalize(500);
            y.Normalize(500);
            fitting.Plane = plane;
            fitting.Insert();

            Model.CommitChanges();
        }
        private void TryApplyFits(Part beam, List <Tuple <Tuple <Point, Point, Point>, Plane> > fitPlanes)
        {
            if (null == fitPlanes)
            {
                return;
            }

            var centerLine = GetBeamCenterLineSegmentExpanded(beam, 10.0);

            if (null == centerLine)
            {
                return;
            }

            // check collision
            foreach (var fitPlaneDef in fitPlanes)
            {
                //var pps = fitPlaneDef.Item1;
                var plane = fitPlaneDef.Item2;
                //var geomPlane = new GeometricPlane(pps.Item1, new Vector(pps.Item3));
                var geomPlane    = new GeometricPlane(plane.Origin, plane.AxisX, plane.AxisY);
                var intersection = Intersection.LineSegmentToPlane(centerLine, geomPlane);
                if (null == intersection)
                {
                    Tracer._trace($"Does not intersect with {beam.Profile.ProfileString}");
                    continue;
                }
                var operativePart = fitPlaneDef.Item2;

                var fitPlane = new Fitting();
                fitPlane.Father = beam;
                fitPlane.Plane  = operativePart;
                if (!fitPlane.Insert())
                {
                    Tracer._trace("Insert failed!");
                }
                Tracer._trace($"Fit solid: {beam.Name}.");
            }
        }
        private static bool CreateFittings(Beam targetBeam, double customGap)
        {
            bool Result = false;

            Fitting fitBeam = new Fitting();
            fitBeam.Plane = new Plane();
            fitBeam.Plane.Origin = new Point(customGap, -160, -500);
            fitBeam.Plane.AxisX = new Vector(0.0, 500.0, 0.0);
            fitBeam.Plane.AxisY = new Vector(0.0, 0.0, 1200.0);
            fitBeam.Father = targetBeam;

            if (fitBeam.Insert())
                Result = true;

            return Result;
        }
示例#7
0
        public void Create()
        {
            Point  Point1              = StartPoint;
            Point  Point2              = EndPoint;
            Vector mainVector          = new Vector(Point2.X - Point1.X, Point2.Y - Point1.Y, Point2.Z - Point1.Z);
            Vector zaxis               = new Vector(0, 0, -1);
            double height              = Point1.Z - Point2.Z;
            Vector heightStair         = zaxis * height;
            Point  heightStairEndPt    = new Point(Point1.X + heightStair.X, Point1.Y + heightStair.Y, Point1.Z + heightStair.Z);
            Vector subMainVector       = new Vector(Point2.X - heightStairEndPt.X, Point2.Y - heightStairEndPt.Y, Point2.Z - heightStairEndPt.Z);
            double stairLength         = height / Math.Tan(Ang * Math.PI / 180);
            Vector normallengthStair   = subMainVector.GetNormal();
            Vector lengthStair         = normallengthStair * stairLength;
            Point  lengthStairEndPoint = new Point(heightStairEndPt.X + lengthStair.X, heightStairEndPt.Y + lengthStair.Y, heightStairEndPt.Z + lengthStair.Z);
            Vector mainStairVector     = new Vector(lengthStairEndPoint.X - Point1.X, lengthStairEndPoint.Y - Point1.Y, lengthStairEndPoint.Z - Point1.Z);

            Vector leftOffsetVector       = Vector.Cross(heightStair, mainVector);
            Vector normalOffsetBeamVector = leftOffsetVector.GetNormal();

            leftOffsetVector = normalOffsetBeamVector * (Width / 2);
            Vector horizontalVector       = normallengthStair * (-1);
            Vector horizontalVectorLength = horizontalVector * Offset;
            Point  leftBeamMidlePt        = new Point(Point1.X + leftOffsetVector.X, Point1.Y + leftOffsetVector.Y, Point1.Z + leftOffsetVector.Z);
            Point  leftBeamStartPt        = new Point(leftBeamMidlePt.X + horizontalVectorLength.X, leftBeamMidlePt.Y + horizontalVectorLength.Y, leftBeamMidlePt.Z + horizontalVectorLength.Z);
            Point  leftBeamEndPt          = new Point(lengthStairEndPoint.X + leftOffsetVector.X, lengthStairEndPoint.Y + leftOffsetVector.Y, lengthStairEndPoint.Z + leftOffsetVector.Z);

            Vector rightOffsetVector = leftOffsetVector * (-1);
            Point  rightBeamMidlePt  = new Point(Point1.X + rightOffsetVector.X, Point1.Y + rightOffsetVector.Y, Point1.Z + rightOffsetVector.Z);
            Point  rightBeamStartPt  = new Point(rightBeamMidlePt.X + horizontalVectorLength.X, rightBeamMidlePt.Y + horizontalVectorLength.Y, rightBeamMidlePt.Z + horizontalVectorLength.Z);
            Point  rightBeamEndPt    = new Point(lengthStairEndPoint.X + rightOffsetVector.X, lengthStairEndPoint.Y + rightOffsetVector.Y, lengthStairEndPoint.Z + rightOffsetVector.Z);

            // offset along length stair
            Vector offsetVect = normallengthStair * Offset;

            Point leftBeamMidlePtOffset = new Point(leftBeamMidlePt.X + offsetVect.X, leftBeamMidlePt.Y + offsetVect.Y, leftBeamMidlePt.Z + offsetVect.Z);
            Point leftBeamStartPtOffset = new Point(leftBeamStartPt.X + offsetVect.X, leftBeamStartPt.Y + offsetVect.Y, leftBeamStartPt.Z + offsetVect.Z);
            Point leftBeamEndPtOffset   = new Point(leftBeamEndPt.X + offsetVect.X, leftBeamEndPt.Y + offsetVect.Y, leftBeamEndPt.Z + offsetVect.Z);

            Point rightBeamMidlePtOffset = new Point(rightBeamMidlePt.X + offsetVect.X, rightBeamMidlePt.Y + offsetVect.Y, rightBeamMidlePt.Z + offsetVect.Z);
            Point rightBeamStartPtOffset = new Point(rightBeamStartPt.X + offsetVect.X, rightBeamStartPt.Y + offsetVect.Y, rightBeamStartPt.Z + offsetVect.Z);
            Point rightBeamEndPtOffset   = new Point(rightBeamEndPt.X + offsetVect.X, rightBeamEndPt.Y + offsetVect.Y, rightBeamEndPt.Z + offsetVect.Z);

            TSM.Beam     centerLineBeam = new TSM.Beam(Point1, lengthStairEndPoint);
            TSM.PolyBeam rightPolyBeam  = new TSM.PolyBeam(PolyBeam.PolyBeamTypeEnum.BEAM);
            TSM.PolyBeam leftPolyBeam   = new TSM.PolyBeam(PolyBeam.PolyBeamTypeEnum.BEAM);

            ContourPoint rightBeamPt1 = new ContourPoint(rightBeamStartPtOffset, null);
            ContourPoint rightBeamPt2 = new ContourPoint(rightBeamMidlePtOffset, null);
            ContourPoint rightBeamPt3 = new ContourPoint(rightBeamEndPtOffset, null);

            ContourPoint leftBeamPt1 = new ContourPoint(leftBeamStartPtOffset, null);
            ContourPoint leftBeamPt2 = new ContourPoint(leftBeamMidlePtOffset, null);
            ContourPoint leftBeamPt3 = new ContourPoint(leftBeamEndPtOffset, null);

            // build right kosour
            rightPolyBeam.Class = "11";
            rightPolyBeam.AddContourPoint(leftBeamPt1);
            rightPolyBeam.AddContourPoint(leftBeamPt2);
            rightPolyBeam.AddContourPoint(leftBeamPt3);
            rightPolyBeam.Position.Plane          = TSM.Position.PlaneEnum.RIGHT;
            rightPolyBeam.Position.Depth          = Position.DepthEnum.BEHIND;
            rightPolyBeam.Position.Rotation       = TSM.Position.RotationEnum.TOP;
            rightPolyBeam.Profile.ProfileString   = Profile;
            rightPolyBeam.Material.MaterialString = Material;
            rightPolyBeam.Finish = "PAINT";
            rightPolyBeam.Insert();

            MainStringer = rightPolyBeam;

            // build left kosour
            leftPolyBeam.Class = "11";
            leftPolyBeam.AddContourPoint(rightBeamPt1);
            leftPolyBeam.AddContourPoint(rightBeamPt2);
            leftPolyBeam.AddContourPoint(rightBeamPt3);
            leftPolyBeam.Position.Plane          = TSM.Position.PlaneEnum.LEFT;
            leftPolyBeam.Position.Depth          = Position.DepthEnum.BEHIND;
            leftPolyBeam.Position.Rotation       = TSM.Position.RotationEnum.BELOW;
            leftPolyBeam.Profile.ProfileString   = Profile;
            leftPolyBeam.Material.MaterialString = Material;
            leftPolyBeam.Finish = "PAINT";
            leftPolyBeam.Insert();

            SecondStringer = leftPolyBeam;

            // fitting kosours
            Vector  xaxis            = normallengthStair;
            Vector  yaxis            = normalOffsetBeamVector;
            Fitting cuttingRightBeam = new Fitting();

            cuttingRightBeam.Plane        = new Plane();
            cuttingRightBeam.Plane.Origin = lengthStairEndPoint;
            cuttingRightBeam.Plane.AxisX  = xaxis;
            cuttingRightBeam.Plane.AxisY  = yaxis;
            cuttingRightBeam.Father       = rightPolyBeam;
            cuttingRightBeam.Insert();

            Fitting cuttingLeftBeam = new Fitting();

            cuttingLeftBeam.Plane        = new Plane();
            cuttingLeftBeam.Plane.Origin = lengthStairEndPoint;
            cuttingLeftBeam.Plane.AxisX  = xaxis;
            cuttingLeftBeam.Plane.AxisY  = yaxis;
            cuttingLeftBeam.Father       = leftPolyBeam;
            cuttingLeftBeam.Insert();

            double hprofile = 0;

            rightPolyBeam.GetReportProperty("HEIGHT", ref hprofile);
            Vector hOrtVect = zaxis * hprofile;

            Point stepsOffsetZPt = new Point(Point1.X + hOrtVect.X, Point1.Y + hOrtVect.Y, Point1.Z + hOrtVect.Z);
            //   var offsetStep = lengthStartSegment - ( hprofile / Math.Tan( (90.0 - ang /2) * Math.PI / 180) );
            var    offsetStep      = Offset;
            Vector offsetStepsVect = normallengthStair * offsetStep;

            StartStepsPoint = new Point(Point1.X + offsetStepsVect.X, Point1.Y + offsetStepsVect.Y, Point1.Z + offsetStepsVect.Z);
            // Height = height - hprofile;
            StairVector = normallengthStair;
        }