コード例 #1
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));
            }
        }
コード例 #2
0
        private void DrawCoordinateSystem()
        {
            TSM.UI.GraphicsDrawer drawer = new TSM.UI.GraphicsDrawer();

            TSG.Point    origin = new TSG.Point();
            TSG.Point    pointX = new TSG.Point(3000, 0, 0);
            TSG.Point    pointY = new TSG.Point(0, 3000, 0);
            TSG.Point    pointZ = new TSG.Point(0, 0, 3000);
            TSM.UI.Color blue   = new TSM.UI.Color(0, 0, 1);
            TSM.UI.Color red    = new TSM.UI.Color(1, 0, 0);

            drawer.DrawText(pointX, "X", blue);
            drawer.DrawText(pointY, "Y", blue);
            drawer.DrawText(pointZ, "Z", blue);

            drawer.DrawLineSegment(origin, pointX, red);
            drawer.DrawLineSegment(origin, pointY, red);
            drawer.DrawLineSegment(origin, pointZ, red);
        }
コード例 #3
0
        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));
                    }
                }
            }
        }
コード例 #4
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
                {
                }
            }
        }