Ejemplo n.º 1
0
        public Beam CutBeamByPart(Beam beam, Part part, bool startSideCut = true)
        {
            // вырезаем ThasBeam по MainBeam
            var         partClass = part.Class;
            BooleanPart Beam      = new BooleanPart();

            Beam.Father = beam;
            part.Class  = BooleanPart.BooleanOperativeClassName;
            Beam.SetOperativePart(part);
            Beam.Insert();
            part.Class = partClass;
            part.Modify();

            // создаем режущую плоскость, чтобы отбросить
            //..(левую) часть ThisBeam по плоскости MainBeam
            CutPlane BeamLineCut = new CutPlane();

            BeamLineCut.Father = beam;
            Plane BeamCutPlane = new Plane();
            var   cs           = part.GetCoordinateSystem();

            if (startSideCut)
            {
                cs.AxisX *= -1;
            }
            BeamCutPlane.AxisX  = cs.AxisX;
            BeamCutPlane.AxisY  = cs.AxisY;
            BeamCutPlane.Origin = cs.Origin;
            BeamLineCut.Plane   = BeamCutPlane;
            BeamLineCut.Insert();

            Model.CommitChanges();

            return(beam);
        }
        private void TryApplyCuts(Part part, List <Tuple <Tuple <Point, Point, Point>, Plane> > cutPlanes)
        {
            if (null == cutPlanes)
            {
                return;
            }

            var partBox = part.GetSolid();

            // check collision
            foreach (var cutPlaneDef in cutPlanes)
            {
                var operativePart = cutPlaneDef.Item2;
                var pps           = cutPlaneDef.Item1;
                var intersection  = partBox.IntersectAllFaces(pps.Item1, pps.Item2, pps.Item3);
                if (intersection.IsNullOrEmpty())
                {
                    continue;
                }

                var cutPlane = new CutPlane();
                cutPlane.Father = part;
                cutPlane.Plane  = operativePart;
                if (!cutPlane.Insert())
                {
                    Tracer._trace("Insert failed!");
                }
                //Tracer._trace($"Cut solid: {part.Name}.");
            }
        }
        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());
        }
        public void UT_CutBeamByLine()
        {
            // Пример 1: из TeklaAPI CutPlate Example
            //.. создает балку в [0,0 - 1000,0] и обрезает ее по CutPlate
            Point Point  = new Point(0, 0, 0);
            Point Point2 = new Point(1000, 0, 0);

            ThisBeam                       = new Beam();
            ThisBeam.StartPoint            = Point;
            ThisBeam.EndPoint              = Point2;
            ThisBeam.Profile.ProfileString = "HEA400";
            ThisBeam.Finish                = "PAINT";
            ThisBeam.Insert();
            Model.CommitChanges();

            CutPlane CutPlane = new CutPlane();

            CutPlane.Plane        = new Plane();
            CutPlane.Plane.Origin = new Point(400, 0, 0);
            CutPlane.Plane.AxisX  = new Vector(0, 500, 0);
            CutPlane.Plane.AxisY  = new Vector(0, 0, -1000);
            CutPlane.Father       = ThisBeam;
            CutPlane.Insert();
            Model.CommitChanges();
            // В результате на экране Tekla создается балка вдоль оси Х
            //..и стирается ее часть, ближняя к точке (0,0) на Х=400.
            //..Чтобы стирать другую часть балки, поменяйте

            // test 0: создаем балку вдоль оси Х, а потом ее стираем
            Point p1 = new Point(0, 2500, 0);
            Point p2 = new Point(2500, 0, 0);

            MainBeam = _TS.CreateBeam("MainBeam", "I50B1_20_93", p1, p2);

            // создаем режущую плоскость
            CutPlane BeamLineCut = new CutPlane();

            // Father - Объект модели над которым выполняется действие
            BeamLineCut.Father = this.MainBeam;
            Plane BeamCutPlane = new Plane();

            BeamCutPlane.Origin = new Point(1000, 0, 0);
            BeamCutPlane.AxisX  = new 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.AxisY = new Vector(0, -500, 0);
            BeamLineCut.Plane  = BeamCutPlane;
            BeamLineCut.Insert();

            Model.CommitChanges();
        }
Ejemplo n.º 5
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();
            }
        }
        //PKh 7/6/18
        public Beam CutBeamByLine(Beam beam, CutPlane cutPlane)
        {
            // Apply Line Cut
            CutPlane BeamLineCut = new CutPlane();

            BeamLineCut.Father = beam;
            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();
            return(beam);
        }
Ejemplo n.º 7
0
        public static void Main(string[] args)
        {
            var model          = new Model();
            var graphicsDrawer = new GraphicsDrawer();
            var picker         = new Picker();
            var red            = new Color(1, 0, 0);
            var white          = new Color(1, 1, 1);
            var blue           = new Color(0, 0, 1);
            var green          = new Color(0, 1, 0);
            var black          = new Color(0, 0, 0);

            try
            {
                var savedPlane = model.GetWorkPlaneHandler().GetCurrentTransformationPlane();
                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane());

                var part1 = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_PART, "Pick Part") as Part;
                var solid = part1.GetSolid();

                var maximumPoint = solid.MaximumPoint;
                var minimumPoint = solid.MinimumPoint;

                graphicsDrawer.DrawText(maximumPoint, maximumPoint.ToString(), white);
                graphicsDrawer.DrawText(minimumPoint, maximumPoint.ToString(), white);

                var part2 = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_PART, "Pick Part") as Part;

                var part2CoordinateSystem = part2.GetCoordinateSystem();
                var origin     = part2CoordinateSystem.Origin;
                var xDirection = origin + part2CoordinateSystem.AxisX;
                var yDirection = origin + part2CoordinateSystem.AxisY;

                var xAxis = new LineSegment(origin, xDirection);
                var yAxis = new LineSegment(origin, yDirection);

                graphicsDrawer.DrawLineSegment(xAxis, blue);
                graphicsDrawer.DrawLineSegment(yAxis, red);

                graphicsDrawer.DrawText(origin, "ORIGIN", white);
                graphicsDrawer.DrawText(xDirection, "XAXIS", blue);
                graphicsDrawer.DrawText(yDirection, "YAXIS", red);


                var intersectionPoints = solid.GetAllIntersectionPoints(part2CoordinateSystem.Origin, part2CoordinateSystem.AxisX, part2CoordinateSystem.AxisY);

                while (intersectionPoints.MoveNext())
                {
                    var point = intersectionPoints.Current as Point;
                    graphicsDrawer.DrawText(point, point.ToString(), green);
                }

                var plane = new Plane()
                {
                    Origin = origin,
                    AxisX  = part2CoordinateSystem.AxisX,
                    AxisY  = part2CoordinateSystem.AxisY,
                };

                var cut = new CutPlane()
                {
                    Father     = part1,
                    Identifier = new Identifier(new Guid()),
                    Plane      = plane,
                };

                cut.Insert();
                model.CommitChanges();

                var part2Centerline = part2.GetCenterLine(false);
                var intersect       = solid.Intersect(new LineSegment(part2Centerline[0] as Point, part2Centerline[1] as Point));

                var point1 = intersect[0] as Point;
                var point2 = intersect[1] as Point;

                graphicsDrawer.DrawText(point1, "POINT1", red);
                graphicsDrawer.DrawText(point2, "POINT2", blue);

                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(savedPlane);

                var currentViews = ViewHandler.GetAllViews();
                while (currentViews.MoveNext())
                {
                    var currentView = currentViews.Current;
                    currentView.Select();
                    currentView.VisibilitySettings.WeldsVisible                = false;
                    currentView.VisibilitySettings.WeldsVisibleInComponents    = false;
                    currentView.VisibilitySettings.ComponentsVisible           = false;
                    currentView.VisibilitySettings.FittingsVisible             = false;
                    currentView.VisibilitySettings.FittingsVisibleInComponents = false;
                    currentView.Modify();
                }

                var faces    = picker.PickFace("Pick Face");
                var vertices = faces.OfType <InputItem>().ToList()[1].GetData() as ArrayList;
                foreach (Point vertex in vertices)
                {
                    graphicsDrawer.DrawText(vertex, vertex.ToString(), black);
                }

                plane = new Plane
                {
                    Origin = vertices[0] as Point,
                    AxisX  = new Vector((vertices[1] as Point) - (vertices[0] as Point)),
                    AxisY  = new Vector((vertices[2] as Point) - (vertices[0] as Point)),
                };

                cut = new CutPlane
                {
                    Father     = part1,
                    Identifier = new Identifier(new Guid()),
                    Plane      = plane,
                };

                cut.Insert();
                model.CommitChanges();
            }
            catch (Exception ex)
            {
                // ignored
            }
        }
Ejemplo n.º 8
0
        private void SetUpRafters(Point StartPoint, Point EndPoint, Point DirectionPoint)
        {
            Phase phase = new Phase();

            phase.PhaseNumber = 3;

            Rafters        = new Beam[5];
            TopBeam        = new Beam();
            BottomBeam     = new Beam();
            SheatingPanels = new Beam[2];

            for (int i = 0; i < Rafters.Length; i++)
            {
                Rafters[i] = new Beam(Beam.BeamTypeEnum.BEAM);
                Rafters[i].Profile.ProfileString = _BeamProfile;
                Rafters[i].Name = _BeamName;
                Rafters[i].Material.MaterialString = _BeamMaterial;
                Rafters[i].PartNumber.Prefix       = "Sp";
                Rafters[i].AssemblyNumber.Prefix   = "Sp";
                Rafters[i].Finish = _BeamFinish;
                Rafters[i].Class  = _BeamClass;
            }

            TopBeam = new Beam(Beam.BeamTypeEnum.BEAM);
            TopBeam.Profile.ProfileString = _BeamProfile;
            TopBeam.Name = _BeamName;
            TopBeam.Material.MaterialString = _BeamMaterial;
            TopBeam.PartNumber.Prefix       = "Sp";
            TopBeam.AssemblyNumber.Prefix   = "Sp";
            TopBeam.Finish = _BeamFinish;
            TopBeam.Class  = _BeamClass;

            BottomBeam = new Beam(Beam.BeamTypeEnum.BEAM);
            BottomBeam.Profile.ProfileString = _BeamProfile;
            BottomBeam.Name = _BeamName;
            BottomBeam.Material.MaterialString = _BeamMaterial;
            BottomBeam.PartNumber.Prefix       = "Sp";
            BottomBeam.AssemblyNumber.Prefix   = "Sp";
            BottomBeam.Finish = _BeamFinish;
            BottomBeam.Class  = _BeamClass;

            Drukregel = new Beam(Beam.BeamTypeEnum.BEAM);
            Drukregel.Profile.ProfileString = _DrukregelProfile;
            Drukregel.Name = _DrukregelName;
            Drukregel.Material.MaterialString = _DrukregelMaterial;
            Drukregel.PartNumber.Prefix       = "Dr";
            Drukregel.AssemblyNumber.Prefix   = "Dr";
            Drukregel.Finish = _DrukregelFinish;
            Drukregel.Class  = _DrukregelClass;

            if (DirectionPoint.Y > StartPoint.Y)
            {
                Rafters.First().Position.Plane = Position.PlaneEnum.LEFT;
                Rafters.First().Position.Rotation = Position.RotationEnum.TOP;
                Rafters.First().Position.Depth = Position.DepthEnum.BEHIND;
                Rafters.First().StartPoint = new Point(StartPoint);
                Rafters.First().EndPoint   = new Point(EndPoint);
                Rafters.First().Insert();
                Rafters.First().SetPhase(phase);

                //TransformationPlane tp = new TransformationPlane(Rafters.First().GetCoordinateSystem());
                //Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(tp);

                double MinimumX = Rafters.First().GetSolid().MinimumPoint.X;
                double MinimumY = Rafters.First().GetSolid().MinimumPoint.Y;
                double MinimumZ = Rafters.First().GetSolid().MinimumPoint.Z;
                double MaximumX = Rafters.First().GetSolid().MaximumPoint.X;
                double MaximumY = Rafters.First().GetSolid().MaximumPoint.Y;
                double MaximumZ = Rafters.First().GetSolid().MaximumPoint.Z;

                Rafters.Last().Position.Plane = Position.PlaneEnum.LEFT;
                Rafters.Last().Position.Rotation = Position.RotationEnum.TOP;
                Rafters.Last().Position.Depth = Position.DepthEnum.FRONT;
                Rafters.Last().StartPoint = new Point(MinimumX + _Length, MinimumY, MinimumZ);
                Rafters.Last().EndPoint   = new Point(MinimumX + _Length, MinimumY, MaximumZ);
                Rafters.Last().Insert();
                Rafters.Last().SetPhase(phase);

                TopBeam.Position.Plane    = Position.PlaneEnum.LEFT;
                TopBeam.Position.Rotation = Position.RotationEnum.BELOW;
                TopBeam.Position.Depth    = Position.DepthEnum.FRONT;
                TopBeam.StartPoint        = new Point(MinimumX, MinimumY, MaximumZ);
                TopBeam.EndPoint          = new Point(MinimumX + _Length, MinimumY, MaximumZ);

                if (!TopBeam.Insert())
                {
                    MessageBox.Show("Failed to insert topbeam");
                }

                TopBeam.SetPhase(phase);

                BottomBeam.Position.Plane    = Position.PlaneEnum.LEFT;
                BottomBeam.Position.Rotation = Position.RotationEnum.BELOW;
                BottomBeam.Position.Depth    = Position.DepthEnum.BEHIND;
                BottomBeam.StartPoint        = new Point(MinimumX, MinimumY, MinimumZ);
                BottomBeam.EndPoint          = new Point(MinimumX + _Length, MinimumY, MinimumZ);

                if (!BottomBeam.Insert())
                {
                    MessageBox.Show("Failed to insert bottombeam");
                }

                BottomBeam.SetPhase(phase);

                //INTERMEDIATE
                for (int j = 1; j < Rafters.Length - 1; j++)
                {
                    Rafters[j].Position.Plane    = Position.PlaneEnum.LEFT;
                    Rafters[j].Position.Rotation = Position.RotationEnum.TOP;
                    Rafters[j].Position.Depth    = Position.DepthEnum.MIDDLE;
                    //Rafters[j].StartPoint = tp.TransformationMatrixToLocal.Transform(StartPoint) - new Point(0, j * _Spacing, 0);
                    //Rafters[j].EndPoint = tp.TransformationMatrixToLocal.Transform(EndPoint) - new Point(0, j * _Spacing, 0);

                    Rafters[j].StartPoint = new Point(MinimumX + j * _Spacing, MinimumY, MinimumZ);
                    Rafters[j].EndPoint   = new Point(MinimumX + j * _Spacing, MinimumY, MaximumZ);
                    Rafters[j].Insert();
                    Rafters[j].SetPhase(phase);
                }

                TopBeam.SetUserProperty("USER_FIELD_1", "x");
                BottomBeam.SetUserProperty("USER_FIELD_1", "x");
                Rafters.First().SetUserProperty("USER_FIELD_1", "x");
                Rafters.Last().SetUserProperty("USER_FIELD_1", "x");

                MinimumX = BottomBeam.GetSolid().MinimumPoint.X;
                MinimumY = BottomBeam.GetSolid().MinimumPoint.Y;
                MinimumZ = BottomBeam.GetSolid().MinimumPoint.Z;
                MaximumX = BottomBeam.GetSolid().MaximumPoint.X;
                MaximumY = BottomBeam.GetSolid().MaximumPoint.Y;
                MaximumZ = TopBeam.GetSolid().MaximumPoint.Z;

                for (int i = 0; i < SheatingPanels.Length; i++)
                {
                    SheatingPanels[i] = new Beam(Beam.BeamTypeEnum.BEAM);
                    SheatingPanels[i].Position.Plane          = Position.PlaneEnum.LEFT;
                    SheatingPanels[i].Position.Rotation       = Position.RotationEnum.TOP;
                    SheatingPanels[i].Position.Depth          = Position.DepthEnum.BEHIND;
                    SheatingPanels[i].Profile.ProfileString   = _SheatingProfile;
                    SheatingPanels[i].Material.MaterialString = _SheatingMaterial;
                    SheatingPanels[i].PartNumber.Prefix       = "PL";
                    SheatingPanels[i].AssemblyNumber.Prefix   = "R";
                    SheatingPanels[i].Finish = _SheatingFinish;
                    SheatingPanels[i].Name   = _SheatingName;
                    SheatingPanels[i].Class  = _SheatingClass;

                    if (_SheatingType == 0)
                    {
                        SheatingPanels[i].Name  = "SPAANPLAAT";
                        SheatingPanels[i].Class = "4";
                    }

                    if (_SheatingType == 1)
                    {
                        SheatingPanels[i].Name  = "SPAANPLAAT     (wit)";
                        SheatingPanels[i].Class = "5";
                    }
                }

                SheatingPanels.First().StartPoint = new Point(BottomBeam.GetSolid().MinimumPoint.X, BottomBeam.GetSolid().MaximumPoint.Y, BottomBeam.GetSolid().MinimumPoint.Z);
                SheatingPanels.First().EndPoint   = new Point(BottomBeam.GetSolid().MinimumPoint.X, BottomBeam.GetSolid().MaximumPoint.Y, TopBeam.GetSolid().MaximumPoint.Z + _SheatingOverhang);
                SheatingPanels.First().Insert();
                SheatingPanels.First().SetPhase(phase);

                SheatingPanels.Last().StartPoint = new Point(BottomBeam.GetSolid().MinimumPoint.X + 1222, BottomBeam.GetSolid().MaximumPoint.Y, BottomBeam.GetSolid().MinimumPoint.Z);
                SheatingPanels.Last().EndPoint   = new Point(BottomBeam.GetSolid().MinimumPoint.X + 1222, BottomBeam.GetSolid().MaximumPoint.Y, TopBeam.GetSolid().MaximumPoint.Z + _SheatingOverhang);
                SheatingPanels.Last().Insert();
                SheatingPanels.Last().SetPhase(phase);

                Drukregel.Position.Plane    = Position.PlaneEnum.LEFT;
                Drukregel.Position.Rotation = Position.RotationEnum.BACK;
                Drukregel.Position.Depth    = Position.DepthEnum.FRONT;

                Drukregel.Position.RotationOffset = -90 + _DrukregelAngle;

                Drukregel.StartPoint = new Point(MinimumX, MinimumY - _DrukregelMovement * Math.Cos((90 - _DrukregelAngle) * Math.PI / 180), MaximumZ + _DrukregelMovement * Math.Sin((90 - _DrukregelAngle) * Math.PI / 180));
                Drukregel.EndPoint   = new Point(MinimumX + _Length, MinimumY - _DrukregelMovement * Math.Cos((90 - _DrukregelAngle) * Math.PI / 180), MaximumZ + _DrukregelMovement * Math.Sin((90 - _DrukregelAngle) * Math.PI / 180));

                if (!Drukregel.Insert())
                {
                    MessageBox.Show("Failed to insert drukregel");
                }

                String drukregelComment = Math.Abs(Math.Round(_DrukregelAngle)).ToString();

                Drukregel.SetUserProperty("comment", drukregelComment);
                Drukregel.SetPhase(phase);

                if (_SheatingType == 0)
                {
                    SheatingPanels.First().SetUserProperty("comment", "Naturel");
                    SheatingPanels.Last().SetUserProperty("comment", "Naturel");
                }
                if (_SheatingType == 1)
                {
                    SheatingPanels.First().SetUserProperty("comment", "Wit spanolak");
                    SheatingPanels.Last().SetUserProperty("comment", "Wit spanolak");
                }

                for (int i = 0; i < Rafters.Length; i++)
                {
                    Rafters[i].SetUserProperty("comment", "");
                }

                CutPlane DrukregelCut1 = new CutPlane();
                DrukregelCut1.Plane        = new Plane();
                DrukregelCut1.Plane.Origin = new Point(MinimumX, MaximumY, MaximumZ);
                DrukregelCut1.Plane.AxisX  = new Vector(0, 0, 1);
                DrukregelCut1.Plane.AxisY  = new Vector(1, 0, 0);
                DrukregelCut1.Father       = Drukregel;
                DrukregelCut1.Insert();

                CutPlane DrukregelCut3 = new CutPlane();
                DrukregelCut3.Plane        = new Plane();
                DrukregelCut3.Plane.Origin = new Point(MinimumX, MinimumY, MaximumZ);
                DrukregelCut3.Plane.AxisX  = new Vector(0, 1, 0);
                DrukregelCut3.Plane.AxisY  = new Vector(1, 0, 0);
                DrukregelCut3.Father       = Drukregel;
                DrukregelCut3.Insert();
            }

            else if (DirectionPoint.Y < StartPoint.Y)
            {
                Rafters.First().Position.Plane = Position.PlaneEnum.RIGHT;
                Rafters.First().Position.Rotation = Position.RotationEnum.BELOW;
                Rafters.First().Position.Depth = Position.DepthEnum.FRONT;
                Rafters.First().StartPoint = new Point(StartPoint);
                Rafters.First().EndPoint   = new Point(EndPoint);
                Rafters.First().Insert();
                Rafters.First().SetPhase(phase);

                //TransformationPlane tp = new TransformationPlane(Rafters.First().GetCoordinateSystem());
                //Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(tp);

                double MinimumX = Rafters.First().GetSolid().MinimumPoint.X;
                double MinimumY = Rafters.First().GetSolid().MinimumPoint.Y;
                double MinimumZ = Rafters.First().GetSolid().MinimumPoint.Z;
                double MaximumX = Rafters.First().GetSolid().MaximumPoint.X;
                double MaximumY = Rafters.First().GetSolid().MaximumPoint.Y;
                double MaximumZ = Rafters.First().GetSolid().MaximumPoint.Z;

                Rafters.Last().Position.Plane = Position.PlaneEnum.LEFT;
                Rafters.Last().Position.Rotation = Position.RotationEnum.BELOW;
                Rafters.Last().Position.Depth = Position.DepthEnum.BEHIND;
                Rafters.Last().StartPoint = new Point(MaximumX - _Length, MinimumY, MinimumZ);
                Rafters.Last().EndPoint   = new Point(MaximumX - _Length, MinimumY, MaximumZ);
                Rafters.Last().Insert();
                Rafters.Last().SetPhase(phase);

                TopBeam.Position.Plane    = Position.PlaneEnum.RIGHT;
                TopBeam.Position.Rotation = Position.RotationEnum.BELOW;
                TopBeam.Position.Depth    = Position.DepthEnum.FRONT;
                TopBeam.StartPoint        = new Point(MaximumX, MinimumY, MaximumZ);
                TopBeam.EndPoint          = new Point(MaximumX - _Length, MinimumY, MaximumZ);

                if (!TopBeam.Insert())
                {
                    MessageBox.Show("Failed to insert topbeam");
                }

                TopBeam.SetPhase(phase);

                BottomBeam.Position.Plane    = Position.PlaneEnum.LEFT;
                BottomBeam.Position.Rotation = Position.RotationEnum.BELOW;
                BottomBeam.Position.Depth    = Position.DepthEnum.BEHIND;
                BottomBeam.StartPoint        = new Point(MaximumX, MaximumY, MinimumZ);
                BottomBeam.EndPoint          = new Point(MaximumX - _Length, MaximumY, MinimumZ);

                if (!BottomBeam.Insert())
                {
                    MessageBox.Show("Failed to insert bottombeam");
                }

                BottomBeam.SetPhase(phase);

                //INTERMEDIATE
                for (int j = 1; j < Rafters.Length - 1; j++)
                {
                    Rafters[j].Position.Plane    = Position.PlaneEnum.LEFT;
                    Rafters[j].Position.Rotation = Position.RotationEnum.TOP;
                    Rafters[j].Position.Depth    = Position.DepthEnum.MIDDLE;
                    //Rafters[j].StartPoint = tp.TransformationMatrixToLocal.Transform(StartPoint) - new Point(0, j * _Spacing, 0);
                    //Rafters[j].EndPoint = tp.TransformationMatrixToLocal.Transform(EndPoint) - new Point(0, j * _Spacing, 0);

                    Rafters[j].StartPoint = new Point(MaximumX - j * _Spacing, MinimumY, MinimumZ);
                    Rafters[j].EndPoint   = new Point(MaximumX - j * _Spacing, MinimumY, MaximumZ);
                    Rafters[j].Insert();
                    Rafters[j].SetPhase(phase);
                }

                TopBeam.SetUserProperty("USER_FIELD_1", "x");
                BottomBeam.SetUserProperty("USER_FIELD_1", "x");
                Rafters.First().SetUserProperty("USER_FIELD_1", "x");
                Rafters.Last().SetUserProperty("USER_FIELD_1", "x");

                MinimumX = BottomBeam.GetSolid().MinimumPoint.X;
                MinimumY = BottomBeam.GetSolid().MinimumPoint.Y;
                MinimumZ = BottomBeam.GetSolid().MinimumPoint.Z;
                MaximumX = BottomBeam.GetSolid().MaximumPoint.X;
                MaximumY = BottomBeam.GetSolid().MaximumPoint.Y;
                MaximumZ = TopBeam.GetSolid().MaximumPoint.Z;

                for (int i = 0; i < SheatingPanels.Length; i++)
                {
                    SheatingPanels[i] = new Beam(Beam.BeamTypeEnum.BEAM);
                    SheatingPanels[i].Position.Plane          = Position.PlaneEnum.RIGHT;
                    SheatingPanels[i].Position.Rotation       = Position.RotationEnum.BELOW;
                    SheatingPanels[i].Position.Depth          = Position.DepthEnum.FRONT;
                    SheatingPanels[i].Profile.ProfileString   = _SheatingProfile;
                    SheatingPanels[i].Material.MaterialString = _SheatingMaterial;
                    SheatingPanels[i].PartNumber.Prefix       = "PL";
                    SheatingPanels[i].AssemblyNumber.Prefix   = "R";
                    SheatingPanels[i].Finish = _SheatingFinish;
                    SheatingPanels[i].Name   = _SheatingName;
                    SheatingPanels[i].Class  = _SheatingClass;

                    if (_SheatingType == 0)
                    {
                        SheatingPanels[i].Name  = "SPAANPLAAT";
                        SheatingPanels[i].Class = "4";
                    }

                    if (_SheatingType == 1)
                    {
                        SheatingPanels[i].Name  = "SPAANPLAAT     (wit)";
                        SheatingPanels[i].Class = "5";
                    }
                }

                SheatingPanels.First().StartPoint = new Point(BottomBeam.GetSolid().MaximumPoint.X, BottomBeam.GetSolid().MinimumPoint.Y, BottomBeam.GetSolid().MinimumPoint.Z);
                SheatingPanels.First().EndPoint   = new Point(BottomBeam.GetSolid().MaximumPoint.X, BottomBeam.GetSolid().MinimumPoint.Y, TopBeam.GetSolid().MaximumPoint.Z + _SheatingOverhang);
                SheatingPanels.First().Insert();
                SheatingPanels.First().SetPhase(phase);

                SheatingPanels.Last().StartPoint = new Point(BottomBeam.GetSolid().MaximumPoint.X - 1222, BottomBeam.GetSolid().MinimumPoint.Y, BottomBeam.GetSolid().MinimumPoint.Z);
                SheatingPanels.Last().EndPoint   = new Point(BottomBeam.GetSolid().MaximumPoint.X - 1222, BottomBeam.GetSolid().MinimumPoint.Y, TopBeam.GetSolid().MaximumPoint.Z + _SheatingOverhang);
                SheatingPanels.Last().Insert();
                SheatingPanels.Last().SetPhase(phase);

                Drukregel.Position.Plane    = Position.PlaneEnum.LEFT;
                Drukregel.Position.Rotation = Position.RotationEnum.BACK;
                Drukregel.Position.Depth    = Position.DepthEnum.FRONT;

                Drukregel.Position.RotationOffset = -90 + _DrukregelAngle;

                Drukregel.StartPoint = new Point(MaximumX, MaximumY + _DrukregelMovement * Math.Cos((90 - _DrukregelAngle) * Math.PI / 180), MaximumZ + _DrukregelMovement * Math.Sin((90 - _DrukregelAngle) * Math.PI / 180));
                Drukregel.EndPoint   = new Point(MaximumX - _Length, MaximumY + _DrukregelMovement * Math.Cos((90 - _DrukregelAngle) * Math.PI / 180), MaximumZ + _DrukregelMovement * Math.Sin((90 - _DrukregelAngle) * Math.PI / 180));

                if (!Drukregel.Insert())
                {
                    MessageBox.Show("Failed to insert drukregel");
                }

                String drukregelComment = Math.Abs(Math.Round(_DrukregelAngle)).ToString();

                Drukregel.SetUserProperty("comment", drukregelComment);
                Drukregel.SetPhase(phase);

                if (_SheatingType == 0)
                {
                    SheatingPanels.First().SetUserProperty("comment", "Naturel");
                    SheatingPanels.Last().SetUserProperty("comment", "Naturel");
                }
                if (_SheatingType == 1)
                {
                    SheatingPanels.First().SetUserProperty("comment", "Wit spanolak");
                    SheatingPanels.Last().SetUserProperty("comment", "Wit spanolak");
                }

                for (int i = 0; i < Rafters.Length; i++)
                {
                    Rafters[i].SetUserProperty("comment", "");
                }

                CutPlane DrukregelCut1 = new CutPlane();
                DrukregelCut1.Plane        = new Plane();
                DrukregelCut1.Plane.Origin = new Point(MinimumX, MinimumY, MaximumZ);
                DrukregelCut1.Plane.AxisX  = new Vector(1, 0, 0);
                DrukregelCut1.Plane.AxisY  = new Vector(0, 0, 1);
                DrukregelCut1.Father       = Drukregel;
                DrukregelCut1.Insert();

                CutPlane DrukregelCut3 = new CutPlane();
                DrukregelCut3.Plane        = new Plane();
                DrukregelCut3.Plane.Origin = new Point(MinimumX, MinimumY, MaximumZ);
                DrukregelCut3.Plane.AxisX  = new Vector(0, 1, 0);
                DrukregelCut3.Plane.AxisY  = new Vector(1, 0, 0);
                DrukregelCut3.Father       = Drukregel;
                DrukregelCut3.Insert();
            }

            else if (DirectionPoint.X > StartPoint.X)
            {
                Rafters.First().Position.Plane = Position.PlaneEnum.RIGHT;
                Rafters.First().Position.Rotation = Position.RotationEnum.FRONT;
                Rafters.First().Position.Depth = Position.DepthEnum.BEHIND;
                Rafters.First().StartPoint = new Point(StartPoint);
                Rafters.First().EndPoint   = new Point(EndPoint);
                Rafters.First().Insert();
                Rafters.First().SetPhase(phase);

                //TransformationPlane tp = new TransformationPlane(Rafters.First().GetCoordinateSystem());
                //Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(tp);

                double MinimumX = Rafters.First().GetSolid().MinimumPoint.X;
                double MinimumY = Rafters.First().GetSolid().MinimumPoint.Y;
                double MinimumZ = Rafters.First().GetSolid().MinimumPoint.Z;
                double MaximumX = Rafters.First().GetSolid().MaximumPoint.X;
                double MaximumY = Rafters.First().GetSolid().MaximumPoint.Y;
                double MaximumZ = Rafters.First().GetSolid().MaximumPoint.Z;

                Rafters.Last().Position.Plane = Position.PlaneEnum.LEFT;
                Rafters.Last().Position.Rotation = Position.RotationEnum.FRONT;
                Rafters.Last().Position.Depth = Position.DepthEnum.BEHIND;
                Rafters.Last().StartPoint = new Point(MinimumX, MaximumY - _Length, MinimumZ);
                Rafters.Last().EndPoint   = new Point(MinimumX, MaximumY - _Length, MaximumZ);
                Rafters.Last().Insert();
                Rafters.Last().SetPhase(phase);

                TopBeam.Position.Plane    = Position.PlaneEnum.LEFT;
                TopBeam.Position.Rotation = Position.RotationEnum.BELOW;
                TopBeam.Position.Depth    = Position.DepthEnum.FRONT;
                TopBeam.StartPoint        = new Point(MinimumX, MaximumY, MaximumZ);
                TopBeam.EndPoint          = new Point(MinimumX, MaximumY - _Length, MaximumZ);

                if (!TopBeam.Insert())
                {
                    MessageBox.Show("Failed to insert topbeam");
                }

                TopBeam.SetPhase(phase);

                BottomBeam.Position.Plane    = Position.PlaneEnum.LEFT;
                BottomBeam.Position.Rotation = Position.RotationEnum.BELOW;
                BottomBeam.Position.Depth    = Position.DepthEnum.BEHIND;
                BottomBeam.StartPoint        = new Point(MinimumX, MaximumY, MinimumZ);
                BottomBeam.EndPoint          = new Point(MinimumX, MaximumY - _Length, MinimumZ);

                if (!BottomBeam.Insert())
                {
                    MessageBox.Show("Failed to insert bottombeam");
                }

                BottomBeam.SetPhase(phase);

                //INTERMEDIATE
                for (int j = 1; j < Rafters.Length - 1; j++)
                {
                    Rafters[j].Position.Plane    = Position.PlaneEnum.MIDDLE;
                    Rafters[j].Position.Rotation = Position.RotationEnum.FRONT;
                    Rafters[j].Position.Depth    = Position.DepthEnum.BEHIND;
                    //Rafters[j].StartPoint = tp.TransformationMatrixToLocal.Transform(StartPoint) - new Point(0, j * _Spacing, 0);
                    //Rafters[j].EndPoint = tp.TransformationMatrixToLocal.Transform(EndPoint) - new Point(0, j * _Spacing, 0);

                    Rafters[j].StartPoint = new Point(MinimumX, MaximumY - j * _Spacing, MinimumZ);
                    Rafters[j].EndPoint   = new Point(MinimumX, MaximumY - j * _Spacing, MaximumZ);
                    Rafters[j].Insert();
                    Rafters[j].SetPhase(phase);
                }

                TopBeam.SetUserProperty("USER_FIELD_1", "x");
                BottomBeam.SetUserProperty("USER_FIELD_1", "x");
                Rafters.First().SetUserProperty("USER_FIELD_1", "x");
                Rafters.Last().SetUserProperty("USER_FIELD_1", "x");

                MinimumX = BottomBeam.GetSolid().MinimumPoint.X;
                MinimumY = BottomBeam.GetSolid().MinimumPoint.Y;
                MinimumZ = BottomBeam.GetSolid().MinimumPoint.Z;
                MaximumX = BottomBeam.GetSolid().MaximumPoint.X;
                MaximumY = BottomBeam.GetSolid().MaximumPoint.Y;
                MaximumZ = TopBeam.GetSolid().MaximumPoint.Z;

                for (int i = 0; i < SheatingPanels.Length; i++)
                {
                    SheatingPanels[i] = new Beam(Beam.BeamTypeEnum.BEAM);
                    SheatingPanels[i].Position.Plane          = Position.PlaneEnum.RIGHT;
                    SheatingPanels[i].Position.Rotation       = Position.RotationEnum.FRONT;
                    SheatingPanels[i].Position.Depth          = Position.DepthEnum.BEHIND;
                    SheatingPanels[i].Profile.ProfileString   = _SheatingProfile;
                    SheatingPanels[i].Material.MaterialString = _SheatingMaterial;
                    SheatingPanels[i].PartNumber.Prefix       = "PL";
                    SheatingPanels[i].AssemblyNumber.Prefix   = "R";
                    SheatingPanels[i].Finish = _SheatingFinish;
                    SheatingPanels[i].Name   = _SheatingName;
                    SheatingPanels[i].Class  = _SheatingClass;

                    if (_SheatingType == 0)
                    {
                        SheatingPanels[i].Name  = "SPAANPLAAT";
                        SheatingPanels[i].Class = "4";
                    }

                    if (_SheatingType == 1)
                    {
                        SheatingPanels[i].Name  = "SPAANPLAAT     (wit)";
                        SheatingPanels[i].Class = "5";
                    }
                }

                SheatingPanels.First().StartPoint = new Point(BottomBeam.GetSolid().MaximumPoint.X, BottomBeam.GetSolid().MaximumPoint.Y, BottomBeam.GetSolid().MinimumPoint.Z);
                SheatingPanels.First().EndPoint   = new Point(BottomBeam.GetSolid().MaximumPoint.X, BottomBeam.GetSolid().MaximumPoint.Y, TopBeam.GetSolid().MaximumPoint.Z + _SheatingOverhang);
                SheatingPanels.First().Insert();
                SheatingPanels.First().SetPhase(phase);

                SheatingPanels.Last().StartPoint = new Point(BottomBeam.GetSolid().MaximumPoint.X, BottomBeam.GetSolid().MaximumPoint.Y - 1222, BottomBeam.GetSolid().MinimumPoint.Z);
                SheatingPanels.Last().EndPoint   = new Point(BottomBeam.GetSolid().MaximumPoint.X, BottomBeam.GetSolid().MaximumPoint.Y - 1222, TopBeam.GetSolid().MaximumPoint.Z + _SheatingOverhang);
                SheatingPanels.Last().Insert();
                SheatingPanels.Last().SetPhase(phase);

                Drukregel.Position.Plane    = Position.PlaneEnum.LEFT;
                Drukregel.Position.Rotation = Position.RotationEnum.BACK;
                Drukregel.Position.Depth    = Position.DepthEnum.FRONT;

                Drukregel.Position.RotationOffset = -90 + _DrukregelAngle;

                Drukregel.StartPoint = new Point(MinimumX - _DrukregelMovement * Math.Cos((90 - _DrukregelAngle) * Math.PI / 180), MaximumY, MaximumZ + _DrukregelMovement * Math.Sin((90 - _DrukregelAngle) * Math.PI / 180));
                Drukregel.EndPoint   = new Point(MinimumX - _DrukregelMovement * Math.Cos((90 - _DrukregelAngle) * Math.PI / 180), MaximumY - _Length, MaximumZ + _DrukregelMovement * Math.Sin((90 - _DrukregelAngle) * Math.PI / 180));

                if (!Drukregel.Insert())
                {
                    MessageBox.Show("Failed to insert drukregel");
                }

                String drukregelComment = Math.Abs(Math.Round(_DrukregelAngle)).ToString();

                Drukregel.SetUserProperty("comment", drukregelComment);
                Drukregel.SetPhase(phase);

                if (_SheatingType == 0)
                {
                    SheatingPanels.First().SetUserProperty("comment", "Naturel");
                    SheatingPanels.Last().SetUserProperty("comment", "Naturel");
                }
                if (_SheatingType == 1)
                {
                    SheatingPanels.First().SetUserProperty("comment", "Wit spanolak");
                    SheatingPanels.Last().SetUserProperty("comment", "Wit spanolak");
                }

                for (int i = 0; i < Rafters.Length; i++)
                {
                    Rafters[i].SetUserProperty("comment", "");
                }

                CutPlane DrukregelCut1 = new CutPlane();
                DrukregelCut1.Plane        = new Plane();
                DrukregelCut1.Plane.Origin = new Point(MaximumX, MaximumY, MaximumZ);
                DrukregelCut1.Plane.AxisX  = new Vector(0, 1, 0);
                DrukregelCut1.Plane.AxisY  = new Vector(0, 0, 1);
                DrukregelCut1.Father       = Drukregel;
                DrukregelCut1.Insert();

                CutPlane DrukregelCut3 = new CutPlane();
                DrukregelCut3.Plane        = new Plane();
                DrukregelCut3.Plane.Origin = new Point(MinimumX, MinimumY, MaximumZ);
                DrukregelCut3.Plane.AxisX  = new Vector(0, 1, 0);
                DrukregelCut3.Plane.AxisY  = new Vector(1, 0, 0);
                DrukregelCut3.Father       = Drukregel;
                DrukregelCut3.Insert();
            }

            else if (DirectionPoint.X < StartPoint.X)
            {
                Rafters.First().Position.Plane = Position.PlaneEnum.LEFT;
                Rafters.First().Position.Rotation = Position.RotationEnum.BACK;
                Rafters.First().Position.Depth = Position.DepthEnum.FRONT;
                Rafters.First().StartPoint = new Point(StartPoint);
                Rafters.First().EndPoint   = new Point(EndPoint);
                Rafters.First().Insert();
                Rafters.First().SetPhase(phase);

                //TransformationPlane tp = new TransformationPlane(Rafters.First().GetCoordinateSystem());
                //Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(tp);

                double MinimumX = Rafters.First().GetSolid().MinimumPoint.X;
                double MinimumY = Rafters.First().GetSolid().MinimumPoint.Y;
                double MinimumZ = Rafters.First().GetSolid().MinimumPoint.Z;
                double MaximumX = Rafters.First().GetSolid().MaximumPoint.X;
                double MaximumY = Rafters.First().GetSolid().MaximumPoint.Y;
                double MaximumZ = Rafters.First().GetSolid().MaximumPoint.Z;

                Rafters.Last().Position.Plane = Position.PlaneEnum.RIGHT;
                Rafters.Last().Position.Rotation = Position.RotationEnum.BACK;
                Rafters.Last().Position.Depth = Position.DepthEnum.BEHIND;
                Rafters.Last().StartPoint = new Point(MinimumX, MinimumY + _Length, MinimumZ);
                Rafters.Last().EndPoint   = new Point(MinimumX, MinimumY + _Length, MaximumZ);
                Rafters.Last().Insert();
                Rafters.Last().SetPhase(phase);

                TopBeam.Position.Plane    = Position.PlaneEnum.RIGHT;
                TopBeam.Position.Rotation = Position.RotationEnum.BELOW;
                TopBeam.Position.Depth    = Position.DepthEnum.FRONT;
                TopBeam.StartPoint        = new Point(MinimumX, MinimumY, MaximumZ);
                TopBeam.EndPoint          = new Point(MinimumX, MinimumY + _Length, MaximumZ);

                if (!TopBeam.Insert())
                {
                    MessageBox.Show("Failed to insert topbeam");
                }

                TopBeam.SetPhase(phase);

                BottomBeam.Position.Plane    = Position.PlaneEnum.RIGHT;
                BottomBeam.Position.Rotation = Position.RotationEnum.BELOW;
                BottomBeam.Position.Depth    = Position.DepthEnum.BEHIND;
                BottomBeam.StartPoint        = new Point(MinimumX, MinimumY, MinimumZ);
                BottomBeam.EndPoint          = new Point(MinimumX, MinimumY + _Length, MinimumZ);

                if (!BottomBeam.Insert())
                {
                    MessageBox.Show("Failed to insert bottombeam");
                }

                BottomBeam.SetPhase(phase);

                //INTERMEDIATE
                for (int j = 1; j < Rafters.Length - 1; j++)
                {
                    Rafters[j].Position.Plane    = Position.PlaneEnum.MIDDLE;
                    Rafters[j].Position.Rotation = Position.RotationEnum.BACK;
                    Rafters[j].Position.Depth    = Position.DepthEnum.BEHIND;
                    //Rafters[j].StartPoint = tp.TransformationMatrixToLocal.Transform(StartPoint) - new Point(0, j * _Spacing, 0);
                    //Rafters[j].EndPoint = tp.TransformationMatrixToLocal.Transform(EndPoint) - new Point(0, j * _Spacing, 0);

                    Rafters[j].StartPoint = new Point(MinimumX, MinimumY + j * _Spacing, MinimumZ);
                    Rafters[j].EndPoint   = new Point(MinimumX, MinimumY + j * _Spacing, MaximumZ);
                    Rafters[j].Insert();
                    Rafters[j].SetPhase(phase);
                }

                TopBeam.SetUserProperty("USER_FIELD_1", "x");
                BottomBeam.SetUserProperty("USER_FIELD_1", "x");
                Rafters.First().SetUserProperty("USER_FIELD_1", "x");
                Rafters.Last().SetUserProperty("USER_FIELD_1", "x");

                MinimumX = BottomBeam.GetSolid().MinimumPoint.X;
                MinimumY = BottomBeam.GetSolid().MinimumPoint.Y;
                MinimumZ = BottomBeam.GetSolid().MinimumPoint.Z;
                MaximumX = BottomBeam.GetSolid().MaximumPoint.X;
                MaximumY = BottomBeam.GetSolid().MaximumPoint.Y;
                MaximumZ = TopBeam.GetSolid().MaximumPoint.Z;

                for (int i = 0; i < SheatingPanels.Length; i++)
                {
                    SheatingPanels[i] = new Beam(Beam.BeamTypeEnum.BEAM);
                    SheatingPanels[i].Position.Plane          = Position.PlaneEnum.LEFT;
                    SheatingPanels[i].Position.Rotation       = Position.RotationEnum.BACK;
                    SheatingPanels[i].Position.Depth          = Position.DepthEnum.FRONT;
                    SheatingPanels[i].Profile.ProfileString   = _SheatingProfile;
                    SheatingPanels[i].Material.MaterialString = _SheatingMaterial;
                    SheatingPanels[i].PartNumber.Prefix       = "PL";
                    SheatingPanels[i].AssemblyNumber.Prefix   = "R";
                    SheatingPanels[i].Finish = _SheatingFinish;
                    SheatingPanels[i].Name   = _SheatingName;
                    SheatingPanels[i].Class  = _SheatingClass;

                    if (_SheatingType == 0)
                    {
                        SheatingPanels[i].Name  = "SPAANPLAAT";
                        SheatingPanels[i].Class = "4";
                    }

                    if (_SheatingType == 1)
                    {
                        SheatingPanels[i].Name  = "SPAANPLAAT     (wit)";
                        SheatingPanels[i].Class = "5";
                    }
                }

                SheatingPanels.First().StartPoint = new Point(BottomBeam.GetSolid().MinimumPoint.X, BottomBeam.GetSolid().MinimumPoint.Y, BottomBeam.GetSolid().MinimumPoint.Z);
                SheatingPanels.First().EndPoint   = new Point(BottomBeam.GetSolid().MinimumPoint.X, BottomBeam.GetSolid().MinimumPoint.Y, TopBeam.GetSolid().MaximumPoint.Z + _SheatingOverhang);
                SheatingPanels.First().Insert();
                SheatingPanels.First().SetPhase(phase);

                SheatingPanels.Last().StartPoint = new Point(BottomBeam.GetSolid().MinimumPoint.X, BottomBeam.GetSolid().MinimumPoint.Y + 1222, BottomBeam.GetSolid().MinimumPoint.Z);
                SheatingPanels.Last().EndPoint   = new Point(BottomBeam.GetSolid().MinimumPoint.X, BottomBeam.GetSolid().MinimumPoint.Y + 1222, TopBeam.GetSolid().MaximumPoint.Z + _SheatingOverhang);
                SheatingPanels.Last().Insert();
                SheatingPanels.Last().SetPhase(phase);

                Drukregel.Position.Plane    = Position.PlaneEnum.LEFT;
                Drukregel.Position.Rotation = Position.RotationEnum.BACK;
                Drukregel.Position.Depth    = Position.DepthEnum.FRONT;

                Drukregel.Position.RotationOffset = -90 + _DrukregelAngle;

                Drukregel.StartPoint = new Point(MaximumX + _DrukregelMovement * Math.Cos((90 - _DrukregelAngle) * Math.PI / 180), MinimumY, MaximumZ + _DrukregelMovement * Math.Sin((90 - _DrukregelAngle) * Math.PI / 180));
                Drukregel.EndPoint   = new Point(MaximumX + _DrukregelMovement * Math.Cos((90 - _DrukregelAngle) * Math.PI / 180), MinimumY + _Length, MaximumZ + _DrukregelMovement * Math.Sin((90 - _DrukregelAngle) * Math.PI / 180));

                if (!Drukregel.Insert())
                {
                    MessageBox.Show("Failed to insert drukregel");
                }

                String drukregelComment = Math.Abs(Math.Round(_DrukregelAngle)).ToString();

                Drukregel.SetUserProperty("comment", drukregelComment);
                Drukregel.SetPhase(phase);

                if (_SheatingType == 0)
                {
                    SheatingPanels.First().SetUserProperty("comment", "Naturel");
                    SheatingPanels.Last().SetUserProperty("comment", "Naturel");
                }
                if (_SheatingType == 1)
                {
                    SheatingPanels.First().SetUserProperty("comment", "Wit spanolak");
                    SheatingPanels.Last().SetUserProperty("comment", "Wit spanolak");
                }

                for (int i = 0; i < Rafters.Length; i++)
                {
                    Rafters[i].SetUserProperty("comment", "");
                }

                CutPlane DrukregelCut1 = new CutPlane();
                DrukregelCut1.Plane        = new Plane();
                DrukregelCut1.Plane.Origin = new Point(MinimumX, MaximumY, MaximumZ);
                DrukregelCut1.Plane.AxisX  = new Vector(0, 0, 1);
                DrukregelCut1.Plane.AxisY  = new Vector(0, 1, 0);
                DrukregelCut1.Father       = Drukregel;
                DrukregelCut1.Insert();

                CutPlane DrukregelCut3 = new CutPlane();
                DrukregelCut3.Plane        = new Plane();
                DrukregelCut3.Plane.Origin = new Point(MinimumX, MinimumY, MaximumZ);
                DrukregelCut3.Plane.AxisX  = new Vector(0, 1, 0);
                DrukregelCut3.Plane.AxisY  = new Vector(1, 0, 0);
                DrukregelCut3.Father       = Drukregel;
                DrukregelCut3.Insert();
            }

            else
            {
                MessageBox.Show("Invalid points");
            }

            Assembly assembly = BottomBeam.GetAssembly();

            assembly.Add(TopBeam);
            assembly.Add(Drukregel);

            foreach (Beam rafter in Rafters)
            {
                assembly.Add(rafter);
            }
            foreach (Beam sheating in SheatingPanels)
            {
                assembly.Add(sheating);
            }

            if (!assembly.Modify())
            {
                MessageBox.Show("Assembly Modify Failed!");
            }

            Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane());
        }