Пример #1
0
        private void btn_Add_To_Click(object sender, EventArgs e)
        {
            TSMUI.Picker thisPicker       = new TSMUI.Picker();
            Part         firstPickedPart  = null;
            Part         secondPickedPart = null;

            try
            {
                firstPickedPart  = thisPicker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART) as Part;
                secondPickedPart = thisPicker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART) as Part;
            }
            catch
            {
                firstPickedPart  = null;
                secondPickedPart = null;
            }

            if (firstPickedPart != null && secondPickedPart != null)
            {
                Assembly mainAssembly = firstPickedPart.GetAssembly();
                mainAssembly.Add(secondPickedPart);
                mainAssembly.Modify();
                currentModel.CommitChanges();
            }
            else
            {
                Tekla.Structures.Model.Operations.Operation.DisplayPrompt("Could not add parts to assembly");
            }
        }
Пример #2
0
        public override List <InputDefinition> DefineInput()
        {
            List <InputDefinition> PartList = new List <InputDefinition>();

            TSMUI.Picker _picker = new TSMUI.Picker();

            Beam Purlin1 = (Beam)_picker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART);
            Beam Purlin2 = (Beam)_picker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART);

            Beam OFlange = (Beam)_picker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART);
            Beam Web     = (Beam)_picker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART);
            Beam IFlange = (Beam)_picker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART);

            InputDefinition Input1 = new InputDefinition(Purlin1.Identifier);
            InputDefinition Input2 = new InputDefinition(Purlin2.Identifier);
            InputDefinition Input3 = new InputDefinition(OFlange.Identifier);
            InputDefinition Input4 = new InputDefinition(Web.Identifier);
            InputDefinition Input5 = new InputDefinition(IFlange.Identifier);

            PartList.Add(Input1);
            PartList.Add(Input2);
            PartList.Add(Input3);
            PartList.Add(Input4);
            PartList.Add(Input5);

            return(PartList);
        }
        public override List <InputDefinition> DefineInput()
        {
            // create new instance of TSMUI.Picker and input definition list
            TSMUI.Picker           anglePicker = new TSMUI.Picker();
            List <InputDefinition> InputList   = new List <InputDefinition>();
            // create array list to hold plates for input
            ArrayList PlateList = new ArrayList();

            try
            {
                // Prompt user to pick 4 plates
                _plate1 = anglePicker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART) as TSM.ContourPlate;
                _plate2 = anglePicker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART) as TSM.ContourPlate;
                _plate3 = anglePicker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART) as TSM.ContourPlate;
                _plate4 = anglePicker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART) as TSM.ContourPlate;

                // Get coordinate system for first plate
                _classModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TSM.TransformationPlane(_plate1.GetCoordinateSystem()));

                // Prompt user to pick points
                _point1 = anglePicker.PickPoint() as T3D.Point;
                _point2 = anglePicker.PickPoint() as T3D.Point;
                _point3 = anglePicker.PickPoint() as T3D.Point;
                _point4 = anglePicker.PickPoint() as T3D.Point;

                // Add plates to array list
                PlateList.Add(_plate1.Identifier);
                PlateList.Add(_plate2.Identifier);
                PlateList.Add(_plate3.Identifier);
                PlateList.Add(_plate4.Identifier);

                // Create inputs to InputDefinition list.
                InputDefinition Input1 = new InputDefinition(_point1);
                InputDefinition Input2 = new InputDefinition(_point2);
                InputDefinition Input3 = new InputDefinition(_point3);
                InputDefinition Input4 = new InputDefinition(_point4);
                InputDefinition Input5 = new InputDefinition(PlateList);

                // Add inputs to InputDefinition list.
                InputList.Add(Input1);
                InputList.Add(Input2);
                InputList.Add(Input3);
                InputList.Add(Input4);
                InputList.Add(Input5);
            }
            catch (Exception ex)
            {
                throw;
            }

            return(InputList);
        }
Пример #4
0
        private void btn_action_Click(object sender, EventArgs e)
        {
            // kết nối với model đang hiện hành.
            tsm.Model model = new tsm.Model();
            if (!model.GetConnectionStatus())
            {
                MessageBox.Show("Tekla is not connected!! @@");
                return;
            }
            // kiểm tra xem đã kết nối được với model chưa.
            //--------------------------------
            // Nhặt 2 đối tượng Rebar group
            tsm.RebarGroup rebargroup0 = null;
            tsm.RebarGroup rebargroup1 = null;
            // Khởi tạo picker
            mui.Picker picker = new mui.Picker();
            string     mess   = "";

            while (rebargroup0 == null & rebargroup1 == null)
            {
                try
                {
                    tsm.ModelObject obj0 = picker.PickObject(mui.Picker.PickObjectEnum.PICK_ONE_OBJECT, mess + "pick a group Rebar 0");
                    if (obj0 as tsm.RebarGroup != null)
                    {
                        rebargroup0 = obj0 as tsm.RebarGroup;
                        mess        = "";
                    }
                    else
                    {
                        mess = "Object is not a Rebar group. ";
                    }
                    tsm.ModelObject obj1 = picker.PickObject(mui.Picker.PickObjectEnum.PICK_ONE_OBJECT, mess + "pick a group Rebar 1");
                    if (obj1 as tsm.RebarGroup != null)
                    {
                        rebargroup1 = obj1 as tsm.RebarGroup;
                        mess        = "";
                    }
                    else
                    {
                        mess = "Object is not a Rebar group. ";
                    }
                }
                catch
                {
                    Operation.DisplayPrompt("not select");
                    return;
                }
            }
        }
Пример #5
0
        private void btnPickPart_Click(object sender, EventArgs e)
        {
            // declaration for object user will select
            ModelObject pickedObject = null;

            // New picker for user interface
            TSMUI.Picker picker = new TSMUI.Picker();

            try
            {
                // if user picks an object
                pickedObject = picker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_OBJECT);
            }
            catch
            {
                // if user interrupts
                pickedObject = null;
                MessageBox.Show("No object was selected.");
            }
            finally
            {
                if (pickedObject != null)
                {
                    // get coordinate system for object
                    T3D.CoordinateSystem objectSystem = pickedObject.GetCoordinateSystem();

                    // set transformation plane to picked object coordinate system
                    Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane(objectSystem));

                    Model.CommitChanges();
                }
            }
        }
Пример #6
0
        private void btn_Set_Workplane_Click(object sender, EventArgs e)
        {
            // Reset workplane back to global
            currentModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane());

            TSMUI.Picker currentPicker = new TSMUI.Picker();
            Part         pickedPart    = null;

            try
            {
                pickedPart = currentPicker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART) as Part;
            }
            catch
            {
                pickedPart = null;
            }

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

                // Show the plate in the model and the workplane change
                currentModel.CommitChanges();
            }
        }
Пример #7
0
        private void btnWorkPlane_Click(object sender, EventArgs e)
        {
            // Reset workplane back to global
            currentModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane());

            TSMUI.Picker currentPicker = new TSMUI.Picker();
            Part         pickedPart    = null;

            try
            {
                pickedPart = currentPicker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART) as Part;
            }
            catch
            {
                pickedPart = null;
            }

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

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

                // Draw Positive Z axis
                TSMUI.GraphicsDrawer myDrawer = new TSMUI.GraphicsDrawer();
                myDrawer.DrawLineSegment(new T3D.LineSegment(new T3D.Point(0, 0, 0), new T3D.Point(0, 0, 500)), new TSMUI.Color(1, 0, 0));
            }
        }
Пример #8
0
        private void btn_Weld_Click(object sender, EventArgs e)
        {
            TSMUI.Picker thisPicker       = new TSMUI.Picker();
            Part         firstPickedPart  = null;
            Part         secondPickedPart = null;

            try
            {
                firstPickedPart  = thisPicker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART) as Part;
                secondPickedPart = thisPicker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART) as Part;
            }
            catch
            {
                firstPickedPart  = null;
                secondPickedPart = null;
            }

            if (firstPickedPart != null && secondPickedPart != null)
            {
                Weld newWeld = new Weld();
                newWeld.MainObject      = firstPickedPart;
                newWeld.SecondaryObject = secondPickedPart;
                newWeld.SizeBelow       = 6.35;
                newWeld.TypeBelow       = BaseWeld.WeldTypeEnum.WELD_TYPE_FILLET;
                newWeld.SizeAbove       = 0.0;
                newWeld.TypeAbove       = BaseWeld.WeldTypeEnum.WELD_TYPE_NONE;
                newWeld.AroundWeld      = false;
                newWeld.ShopWeld        = true;
                newWeld.ReferenceText   = "Typ.";
                newWeld.Placement       = BaseWeld.WeldPlacementTypeEnum.PLACEMENT_AUTO;

                if (newWeld.Insert())
                {
                    // Show the weld in the model but the user will never see the workplane chage
                    currentModel.CommitChanges();
                }
                else
                {
                    Tekla.Structures.Model.Operations.Operation.DisplayPrompt("Weld  was not created");
                }
            }
        }
Пример #9
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();
            }
        }
Пример #10
0
        private void Button_ModifyByClick_Click(object sender, RoutedEventArgs e)
        {
            TSMUI.Picker Picker   = new TSMUI.Picker();
            Beam         ThisBeam = Picker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART) as Beam;

            if (ThisBeam != null)
            {
                ThisBeam.Profile.ProfileString = "I20_8239_89";
                ThisBeam.Class      = "6";
                ThisBeam.StartPoint = new T3D.Point(0, 1000, 0);
                ThisBeam.EndPoint   = new T3D.Point(4000, 1000, 0);
                ThisBeam.Modify();

                Model.CommitChanges();
            }
        }
Пример #11
0
        public PickedObjects(string channelProfile, string channelClass, Model Model)
        {
            Model ThisModel = Model;

            this.ChannelProfile = channelProfile;
            this.ChannelClass   = channelClass;

            // User interface for the model, new picker for the user
            TSMUI.Picker Picker = new TSMUI.Picker();

            do
            {
                try
                {
                    // User picks one single object for input
                    Beam ThisBeam = Picker.PickObject(Tekla.Structures.Model.UI.Picker.PickObjectEnum.PICK_ONE_PART) as Beam; // Cast to beam

                    // If beam is not null
                    if (ThisBeam != null)
                    {
                        // Change channel profile to value passed in constructor
                        ThisBeam.Profile.ProfileString = this.ChannelProfile;
                        // Set class to value passed in constructor
                        ThisBeam.Class = this.ChannelClass;
                        // Move beam from origin, start point at 1000mm on x-axis
                        ThisBeam.StartPoint = new T3D.Point(0, 1000, 0);
                        // Move beam from origin, end point at 4000mm on x-axis and 1000mm on y-axis
                        ThisBeam.EndPoint = new T3D.Point(4000, 1000, 0);
                        // Method to modify beam and apply changes
                        ThisBeam.Modify();

                        // drawing changes and setting the undo
                        // Since user is selecting beam, we want change to be made right away
                        ThisModel.CommitChanges();
                    }
                }
                catch
                {
                    MessageBox.Show("Nothing was selected");
                }
            } while (Picker == null);
        }
Пример #12
0
    /// <summary>
    /// Pick one object of given type
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="message"></param>
    /// <returns></returns>
    public static T PickOneObject <T>(string message = null)
    {
        object obj    = null;
        var    prompt = message ?? "Pick one " + typeof(T).Name.ToLower();

        var warning = string.Empty;

        do
        {
            var modelObject = _picker.PickObject(TSMUI.Picker.PickObjectEnum
                                                 .PICK_ONE_OBJECT, warning + prompt);

            if (modelObject.GetType() != (typeof(T)))
            {
                warning = "Object not found: "; continue;
            }

            obj = Convert.ChangeType(modelObject, typeof(T));
        } while (obj is null);

        return((T)obj);
    }
Пример #13
0
        private void btn_Bolt_Click(object sender, EventArgs e)
        {
            // Current Workplane. Remember how the user had the model before you made changes
            TransformationPlane originalPlane = currentModel.GetWorkPlaneHandler().GetCurrentTransformationPlane();

            TSMUI.Picker thisPicker       = new TSMUI.Picker();
            Part         firstPickedPart  = null;
            Part         secondPickedPart = null;

            try
            {
                firstPickedPart  = thisPicker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART) as Part;
                secondPickedPart = thisPicker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART) as Part;
            }
            catch
            {
                firstPickedPart  = null;
                secondPickedPart = null;
            }

            if (firstPickedPart != null && secondPickedPart != null)
            {
                // Change the workplane to the coordinate system of hte part
                currentModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane(firstPickedPart.GetCoordinateSystem()));

                // BOltGroupCode
                BoltArray newBoltArray = new BoltArray();
                newBoltArray.BoltSize     = 25.4;
                newBoltArray.BoltType     = BoltGroup.BoltTypeEnum.BOLT_TYPE_WORKSHOP;
                newBoltArray.BoltStandard = "A325N";
                newBoltArray.CutLength    = 150;
                // Adds to spacings of bolts in X direction
                newBoltArray.AddBoltDistX(76.2);
                newBoltArray.AddBoltDistX(76.2);
                // Only one row of bolts
                newBoltArray.AddBoltDistY(0);
                // Edge distance from first pooint picked to first bolt in x direction
                newBoltArray.StartPointOffset.Dx = 38.1;
                // Front lines up nicely with x / y position in current workplane.
                newBoltArray.Position.Rotation = Position.RotationEnum.FRONT;
                newBoltArray.PartToBoltTo      = firstPickedPart;
                newBoltArray.PartToBeBolted    = secondPickedPart;
                newBoltArray.FirstPosition     = new T3D.Point(0, 100, 0);
                newBoltArray.SecondPosition    = new T3D.Point(1000, 250, 0);

                if (newBoltArray.Insert())
                {
                    // Draw X Axis of bolt group
                    TSMUI.GraphicsDrawer thisDrawer = new TSMUI.GraphicsDrawer();
                    thisDrawer.DrawLineSegment(new T3D.LineSegment(newBoltArray.FirstPosition, newBoltArray.SecondPosition), new TSMUI.Color(1, 0, 0));

                    // Set workplane back to what user had before
                    currentModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(originalPlane);

                    // Show the bolt group in the model but the user will never see the workplane change.
                    currentModel.CommitChanges();
                }
                else
                {
                }
            }
        }
Пример #14
0
        private void btn_Get_Assembly_Click(object sender, EventArgs e)
        {
            TSMUI.Picker thisPicker = new TSMUI.Picker();
            Part         pickedPart = null;

            try
            {
                pickedPart = thisPicker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART) as Part;
            }
            catch
            {
                pickedPart = null;
            }

            if (pickedPart != null)
            {
                Assembly    thisAssembly = pickedPart.GetAssembly();
                ModelObject mainObject   = thisAssembly.GetMainPart();
                Part        mainPart     = mainObject as Part;

                if (mainPart != null)
                {
                    mainPart.Class = "2";
                    mainPart.Modify();
                    // Don't grab from assembly because it doesn't have one...
                    mainPart.GetCoordinateSystem();

                    // Set the mainPart of the assembly.
                    // thisAssembly.setMainPart(pickedPart);
                }
                else
                {
                    Assembly mainAssembly = mainObject as Assembly;
                    if (mainAssembly != null)
                    {
                        // You got an assembly...
                    }
                }

                // This doesn't do anything, don't use it
                ModelObjectEnumerator partsOnAssembly = thisAssembly.GetChildren();
                int childrenObjects = partsOnAssembly.GetSize();

                // Gets Parts
                ArrayList partsList = thisAssembly.GetSecondaries();

                foreach (Part thisPart in partsList)
                {
                    thisPart.Class = "6";
                    thisPart.Modify();
                }

                // Neat way to highlight / select objects in the model.
                TSMUI.ModelObjectSelector selector = new TSMUI.ModelObjectSelector();
                selector.Select(partsList);

                // Gets Sub Assemblies
                int subAssemblies = thisAssembly.GetSubAssemblies().Count;
                Tekla.Structures.Model.Operations.Operation.DisplayPrompt(childrenObjects + " Children Objects");

                currentModel.CommitChanges();
            }
        }
Пример #15
0
        private void btnPolygonCut_Click(object sender, EventArgs e)
        {
            // Current Workplane. Remember how the user had model before you made changes
            TransformationPlane currentPlane = currentModel.GetWorkPlaneHandler().GetCurrentTransformationPlane();

            TSMUI.Picker myPicker   = new TSMUI.Picker();
            Part         pickedPart = null;

            try
            {
                pickedPart = myPicker.PickObject(Tekla.Structures.Model.UI.Picker.PickObjectEnum.PICK_ONE_PART) as Part;
            }
            catch
            {
                pickedPart = null;
            }

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

                // Apply polygon cut
                ContourPlate contourPlateObject = new ContourPlate();
                contourPlateObject.AssemblyNumber.Prefix      = "XX";
                contourPlateObject.AssemblyNumber.StartNumber = 1;
                contourPlateObject.PartNumber.Prefix          = "xx";
                contourPlateObject.PartNumber.StartNumber     = 1;
                contourPlateObject.Name = "CUT";
                contourPlateObject.Profile.ProfileString   = "200";
                contourPlateObject.Material.MaterialString = "ANTIMATERIAL";
                contourPlateObject.Finish = "";
                // THIS IS THE IMPORTANT PART!!!
                contourPlateObject.Class          = BooleanPart.BooleanOperativeClassName;
                contourPlateObject.Position.Depth = Position.DepthEnum.MIDDLE;
                // When doing a polygon cut make sure you don't do it right along edge
                // or sometimes you might et a solid error and your part will disappear.
                contourPlateObject.AddContourPoint(new ContourPoint(new T3D.Point(-10, -10, 0), null));
                contourPlateObject.AddContourPoint(new ContourPoint(new T3D.Point(100, -10, 0), null));
                contourPlateObject.AddContourPoint(new ContourPoint(new T3D.Point(100, 100, 0), null));
                contourPlateObject.AddContourPoint(new ContourPoint(new T3D.Point(-10, 100, 0), null));

                if (!contourPlateObject.Insert())
                {
                    Tekla.Structures.Model.Operations.Operation.DisplayPrompt("Plate was ot created");
                    // Set workplane to what user had before
                    currentModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentPlane);
                }
                else
                {
                    // We don't need the physical part in the model anymore.
                    contourPlateObject.Delete();

                    // Set workplane to what user had before
                    currentModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentPlane);

                    // Show the fitting in the model, the user will never see the workplane change.
                    currentModel.CommitChanges();
                }
            }
        }
Пример #16
0
        private void btnPartCut_Click(object sender, EventArgs e)
        {
            // Current Workplane. Remember how the user had the model before you made changes
            TransformationPlane currentPlane = currentModel.GetWorkPlaneHandler().GetCurrentTransformationPlane();

            TSMUI.Picker myPicker   = new TSMUI.Picker();
            Part         pickedPart = null;

            try
            {
                pickedPart = myPicker.PickObject(Tekla.Structures.Model.UI.Picker.PickObjectEnum.PICK_ONE_PART) as Part;
            }
            catch
            {
                pickedPart = null;
            }

            if (pickedPart != null)
            {
                // Change the workplaen to the coordinate system of the part
                currentModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane(pickedPart.GetCoordinateSystem()));

                Beam beamPartObject = new Beam();
                beamPartObject.StartPoint              = new T3D.Point(400, 0, -200);
                beamPartObject.EndPoint                = new T3D.Point(400, 0, 200);
                beamPartObject.Profile.ProfileString   = "D200";
                beamPartObject.Material.MaterialString = "ANTIMATERIAL";
                beamPartObject.Class             = BooleanPart.BooleanOperativeClassName;
                beamPartObject.Name              = "CUT";;
                beamPartObject.Position.Depth    = Position.DepthEnum.MIDDLE;
                beamPartObject.Position.Rotation = Position.RotationEnum.FRONT;
                beamPartObject.Position.Plane    = Position.PlaneEnum.MIDDLE;

                if (!beamPartObject.Insert())
                {
                    Tekla.Structures.Model.Operations.Operation.DisplayPrompt("Cut was not created.");
                    // Setworkplane back to what user had vefore changes
                    currentModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentPlane);
                }
                else
                {
                    BooleanPart partCut = new BooleanPart();
                    partCut.Father        = pickedPart;
                    partCut.OperativePart = beamPartObject;
                    partCut.Type          = BooleanPart.BooleanTypeEnum.BOOLEAN_CUT;

                    if (!partCut.Insert())
                    {
                        // Setworkplane back to what user had before
                        currentModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentPlane);
                    }
                    else
                    {
                        // We don't need the physical part in the model anymore
                        beamPartObject.Delete();

                        // 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();
                    }
                }
            }
        }