Пример #1
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);
        }
Пример #2
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");
            }
        }
Пример #3
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));
            }
        }
Пример #4
0
        // button to create polybeam
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            ArrayList pickedPoints = null;                 // arraylist for user picked points

            TSMUI.Picker picker      = new TSMUI.Picker(); // new picker for user
            string       beamProfile = txtProfile.Text;    // profile for polybeam

            try
            {
                // prompt user to pick points in model
                pickedPoints = picker.PickPoints(Tekla.Structures.Model.UI.Picker.PickPointEnum.PICK_POLYGON);
            }
            catch
            {
                // set pickedpoints to null
                pickedPoints = null;

                // read error message to user
                MessageBox.Show("No points were picked");
            }

            if (pickedPoints != null)
            {
                // pass model to PolyBeamModelerChild class
                PolyBeamModelerChild myPolyBeamModeler = new PolyBeamModelerChild(currentModel);

                // Model beam using pickedPoints
                myPolyBeamModeler.ModelBeam(pickedPoints, beamProfile);
            }
        }
Пример #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();
                }
            }
        }
 static TeklaLibrary()
 {
     _currentModel = new Model();
     _currentPlane = GetWorkPlane();
     _picker       = new TSMUI.Picker();
     _progressBar  = new ProgressBar();
 }
Пример #7
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();
            }
        }
        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);
        }
Пример #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 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;
                }
            }
        }
Пример #11
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();
            }
        }
Пример #12
0
        public static Point PickAPoint(string prompt = "Pick a point")
        {
            Point myPoint = null;

            try
            {
                var picker = new UI.Picker();
                myPoint = picker.PickPoint(prompt);
            }
            catch (Exception ex)
            {
                if (ex.Message != "User interrupt")
                {
                    Console.WriteLine(ex.Message + ex.StackTrace);
                }
            }

            return(myPoint);
        }
Пример #13
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");
                }
            }
        }
Пример #14
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);
        }
Пример #15
0
        private void btnPickPoints_Click(object sender, EventArgs e)
        {
            T3D.Point firstPoint  = null;             // first point picked by user
            T3D.Point secondPoint = null;             // second point picked by user

            TSMUI.Picker picker = new TSMUI.Picker(); // picker for user to pick points

            try
            {
                // store picked points in an ArrayList
                ArrayList pickedPoints = picker.PickPoints(Tekla.Structures.Model.UI.Picker.PickPointEnum.PICK_TWO_POINTS);

                firstPoint  = pickedPoints[0] as T3D.Point; // first picked point
                secondPoint = pickedPoints[1] as T3D.Point; // second picked point
            }
            catch                                           // if user cancels without selecting points
            {
                // set both points to null
                firstPoint  = null;
                secondPoint = null;

                // inform user that first and second points weren't chosen
                MessageBox.Show("First and second points were not chosen.");
            }
            finally
            {
                // if first and second points aren't null
                if (firstPoint != null && secondPoint != null)
                {
                    // subtract distance between two points
                    T3D.Vector XVector = new T3D.Vector(secondPoint.X - firstPoint.X, secondPoint.Y - firstPoint.Y, secondPoint.Z - firstPoint.Z);
                    T3D.Vector YVector = new T3D.Vector(new T3D.Vector(0, 0, -1));

                    // use selected points to set work plane
                    Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane(firstPoint, XVector, YVector));

                    // commit changes to model
                    Model.CommitChanges();
                }
            }
        }
Пример #16
0
        public override List <InputDefinition> DefineInput()
        {
            // create new instance of TSMUI.Picker and input definition list
            TSMUI.Picker           columnPicker = new TSMUI.Picker();
            List <InputDefinition> InputList    = new List <InputDefinition>();


            try
            {
                // Get insertion point from user
                _insertionPoint = columnPicker.PickPoint() as T3D.Point;
                InputDefinition Input1 = new InputDefinition(_insertionPoint);
                InputList.Add(Input1);
            }
            catch (Exception ex)
            {
                throw;
            }

            return(InputList);
        }
Пример #17
0
        // button to create column
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            T3D.Point    firstPoint = null;               // insertion point for column
            TSMUI.Picker picker     = new TSMUI.Picker(); // new picker for user
            double       columnHeight;                    // height of column
            string       beamProfile = txtProfile.Text;   // profile for column / beam

            try
            {
                // try converting text in text box for column height to double
                columnHeight = Convert.ToDouble(txtColumnHeight.Text);
            }
            catch
            {
                // if column height conversion failed, set height to zero and display error message
                columnHeight = 0;
                MessageBox.Show("No column height was entered.");
            }

            try
            {
                // prompt user to pick points in model
                firstPoint = picker.PickPoint();

                // create new column modeler
                ColumnModeler myColumnModeler = new ColumnModeler(currentModel);

                // model column
                myColumnModeler.ModelColumn(firstPoint, columnHeight, beamProfile);
            }
            catch
            {
                // set pickedpoints to null
                firstPoint = null;

                // read error message to user
                MessageBox.Show("No insertion points were picked");
            }
        }
Пример #18
0
        // button to create beam
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ArrayList pickedPoints = null;                 // arraylist for user picked points

            T3D.Point    firstPoint  = null;               // first point picked by user
            T3D.Point    secondPoint = null;               // second point picked by user
            TSMUI.Picker picker      = new TSMUI.Picker(); // new picker for user
            string       beamProfile = txtProfile.Text;    // profile for beam

            try
            {
                // prompt user to pick points in model
                pickedPoints = picker.PickPoints(Tekla.Structures.Model.UI.Picker.PickPointEnum.PICK_TWO_POINTS);


                // assign first and second points from arraylist
                firstPoint  = pickedPoints[0] as T3D.Point;
                secondPoint = pickedPoints[1] as T3D.Point;
            }
            catch
            {
                // set pickedpoints to null
                pickedPoints = null;

                // read error message to user
                MessageBox.Show("No points were picked");
            }

            // if points aren't null
            if (firstPoint != null && secondPoint != null)
            {
                // create new beam modeler
                StandardBeamModeler myBeamModeler = new StandardBeamModeler(currentModel);

                // model beam
                myBeamModeler.ModelBeam(pickedPoints, beamProfile);
            }
        }
Пример #19
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();
                    }
                }
            }
        }
Пример #20
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();
                }
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // Reset workplane to global
            currentModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane());

            ArrayList PickedPoints = null;

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

            try
            {
                PickedPoints = myPicker.PickPoints(Tekla.Structures.Model.UI.Picker.PickPointEnum.PICK_POLYGON);
            }
            catch
            {
                PickedPoints = null;
            }

            if (PickedPoints != null)
            {
                ContourPlate myPlate = new ContourPlate();
                myPlate.AssemblyNumber.Prefix      = "P";
                myPlate.AssemblyNumber.StartNumber = 1;
                myPlate.PartNumber.Prefix          = "p";
                myPlate.PartNumber.StartNumber     = 1;
                myPlate.Name = "Plate";
                myPlate.Profile.ProfileString   = "PL25.4";
                myPlate.Material.MaterialString = "A36";
                myPlate.Finish         = "GP";
                myPlate.Class          = "9";
                myPlate.Position.Depth = Position.DepthEnum.FRONT;

                foreach (T3D.Point ThisPoint in PickedPoints)
                {
                    myPlate.AddContourPoint(new ContourPoint(ThisPoint, new Chamfer(12.7, 12.7, Chamfer.ChamferTypeEnum.CHAMFER_LINE)));
                }

                if (!myPlate.Insert())
                {
                    Tekla.Structures.Model.Operations.Operation.DisplayPrompt("No plate was created.");
                }
                else
                {
                    // Change the workplane to match coordinate system of plate
                    currentModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane(myPlate.GetCoordinateSystem()));

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

                    // This gets the plates coordinates and information in the current workplane.
                    myPlate.Select();

                    // Draw the coordinate of the plate in the model in hte local coordinate system.
                    TSMUI.GraphicsDrawer myDrawer = new TSMUI.GraphicsDrawer();

                    foreach (ContourPoint ContourPoint in myPlate.Contour.ContourPoints)
                    {
                        T3D.Point CornerPoint = new T3D.Point(ContourPoint.X, ContourPoint.Y, ContourPoint.Z);

                        const double IMPERIALUNIT = 25.4;
                        double       XValue       = Math.Round(CornerPoint.X / IMPERIALUNIT, 4);
                        double       YValue       = Math.Round(CornerPoint.Y / IMPERIALUNIT, 4);
                        double       ZValue       = Math.Round(CornerPoint.Z / IMPERIALUNIT, 4);

                        myDrawer.DrawText(CornerPoint, "(" + XValue + "," + YValue + "," + ZValue + ")", new TSMUI.Color(1, 0, 0));
                        myDrawer.DrawLineSegment(new T3D.LineSegment(new T3D.Point(0, 0, 0), new T3D.Point(0, 0, 500)), new TSMUI.Color(1, 0, 0));
                    }
                }
            }
        }
Пример #22
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
                {
                }
            }
        }
Пример #23
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();
            }
        }