Exemplo n.º 1
0
        public override bool Run(List <InputDefinition> input)
        {
            try
            {
                Tekla.Structures.Identifier  id    = (Tekla.Structures.Identifier)(input[0]).GetInput();
                Tekla.Structures.Model.Model model = new TSM.Model();
                TSM.Beam beam = (TSM.Beam)model.SelectModelObject(id);

                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TSM.TransformationPlane());
                TSM.TransformationPlane currentTP       = model.GetWorkPlaneHandler().GetCurrentTransformationPlane();
                CoordinateSystem        coordenadasMuro = beam.GetCoordinateSystem();
                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TSM.TransformationPlane(coordenadasMuro));

                ParametrosPanel p = new ParametrosPanel(beam);
                p.dx                 = data.dx;
                p.dy                 = data.dy;
                p.diametroBarras     = data.diametroBarras;
                p.diametroDiagonal   = data.diametroDiagonales;
                p.adicionalDerecha   = data.largoDerecha;
                p.adicionalIzquierda = data.largoIzquierda;
                p.adicionalSuperior  = data.largoSuperior;
                p.adicionalInferior  = data.largoInferior;

                PanelMoldar panel = new PanelMoldar(p);
                panel.fabricar();

                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentTP);
            }
            catch (Exception ex)
            {
                ErrorDialog.Show("Exception", ex.Message, ErrorDialog.Severity.ERROR);
            }

            return(true);
        }
 public TemporaryWorkplane(TSM.TransformationPlane planeToWorkOn)
 {
     _model = new TSM.Model();
     // save current plan
     _oldPlan = _model.GetWorkPlaneHandler().GetCurrentTransformationPlane();
     // set workplan
     _model.GetWorkPlaneHandler().SetCurrentTransformationPlane(planeToWorkOn);
     Tracer._trace("Setting new plane to work at.");
 }
        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);
        }
Exemplo n.º 4
0
        private TSG.OBB CreateOrientedBoundingBox(TSM.Part part)
        {
            TSG.OBB obb = null;

            if (part != null)
            {
                WorkPlaneHandler    workPlaneHandler            = model.GetWorkPlaneHandler();
                TransformationPlane originalTransformationPlane = workPlaneHandler.GetCurrentTransformationPlane();

                Solid     solid = part.GetSolid();
                TSG.Point minPointInCurrentPlane = solid.MinimumPoint;
                TSG.Point maxPointInCurrentPlane = solid.MaximumPoint;

                TSG.Point centerPoint = CalculateCenterPoint(minPointInCurrentPlane, maxPointInCurrentPlane);

                TSG.CoordinateSystem coordSys = part.GetCoordinateSystem();
                TransformationPlane  localTransformationPlane = new TransformationPlane(coordSys);
                workPlaneHandler.SetCurrentTransformationPlane(localTransformationPlane);

                solid = part.GetSolid();
                TSG.Point minPoint = solid.MinimumPoint;
                TSG.Point maxPoint = solid.MaximumPoint;
                double    extent0  = (maxPoint.X - minPoint.X) / 2;
                double    extent1  = (maxPoint.Y - minPoint.Y) / 2;
                double    extent2  = (maxPoint.Z - minPoint.Z) / 2;

                workPlaneHandler.SetCurrentTransformationPlane(originalTransformationPlane);

                obb = new TSG.OBB(centerPoint, coordSys.AxisX, coordSys.AxisY,
                                  coordSys.AxisX.Cross(coordSys.AxisY), extent0, extent1, extent2);
            }
            return(obb);
        }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         // set back old one
         if (null != _oldPlan)
         {
             Tracer._trace("Setting work plane back.");
             _model?.GetWorkPlaneHandler().SetCurrentTransformationPlane(_oldPlan);
         }
         _model = null; _oldPlan = null;
     }
 }
        public static List <Point> GetColumnPoints(
            Tekla.Structures.Model.Model Model,
            Point ptStart,
            double firstLevel,
            double secondLevel)
        {
            TransformationPlane transformationPlane = Model.GetWorkPlaneHandler().GetCurrentTransformationPlane();
            Matrix transformationMatrixToLocal      = transformationPlane.TransformationMatrixToLocal;
            Point  point   = transformationPlane.TransformationMatrixToGlobal.Transform(ptStart);
            Vector vector1 = new Vector(0.0, 0.0, firstLevel);
            Vector vector2 = new Vector(0.0, 0.0, secondLevel);

            point.Z = 0.0;
            Point p1 = point + (Point)vector1;
            Point p2 = point + (Point)vector2;

            return(new List <Point>()
            {
                transformationMatrixToLocal.Transform(p1),
                transformationMatrixToLocal.Transform(p2)
            });
        }
Exemplo n.º 7
0
        public static void Run(Tekla.Technology.Akit.IScript akit)
        {
            try
            {
                TSM.Model          model          = new TSM.Model();
                TSD.DrawingHandler drawingHandler = new TSD.DrawingHandler();
                TSG.Vector         UpDirection    = new TSG.Vector(0.0, 0.0, 1.0);
                TSD.Size           A3             = new TSD.Size(410, 287);

                TSM.TransformationPlane current = model.GetWorkPlaneHandler().GetCurrentTransformationPlane();
                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TSM.TransformationPlane());

                TSM.ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects();
                while (modelObjectEnum.MoveNext())
                {
                    if (modelObjectEnum.Current is Tekla.Structures.Model.Part)
                    {
                        TSM.Part selectedPart = (TSM.Part)modelObjectEnum.Current;

                        string USER_FIELD_3 = "", USER_FIELD_4 = "";
                        selectedPart.GetUserProperty("USER_FIELD_3", ref USER_FIELD_3);
                        selectedPart.GetUserProperty("USER_FIELD_4", ref USER_FIELD_4);
                        USER_FIELD_4 = USER_FIELD_4.Replace("(?)", "");
                        selectedPart.SetUserProperty("USER_FIELD_4", USER_FIELD_4);

                        if (USER_FIELD_3 == "M")
                        {
                            TSD.Drawing gaDrawing = new TSD.GADrawing("BRAD-Mod-Ass", A3);
                            gaDrawing.Name   = selectedPart.Name;
                            gaDrawing.Title1 = "SITEWORK";
                            gaDrawing.Title2 = USER_FIELD_3 + USER_FIELD_4;
                            gaDrawing.Title3 = "";
                            gaDrawing.Insert();
                            drawingHandler.SetActiveDrawing(gaDrawing, false);

                            model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new Tekla.Structures.Model.TransformationPlane(selectedPart.GetCoordinateSystem()));
                            TSM.Solid tsolid  = selectedPart.GetSolid();
                            TSG.Point tsMinPt = tsolid.MinimumPoint;
                            TSG.Point tsMaxPt = tsolid.MaximumPoint;
                            model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new Tekla.Structures.Model.TransformationPlane());

                            if (selectedPart.Name.Contains("BEAM"))
                            {
                                TSG.CoordinateSystem ModelObjectCoordSys = selectedPart.GetCoordinateSystem();
                                TSG.CoordinateSystem PlanViewCoordSys    = new TSG.CoordinateSystem();
                                PlanViewCoordSys.Origin = new TSG.Point(ModelObjectCoordSys.Origin);
                                PlanViewCoordSys.AxisX  = new TSG.Vector(ModelObjectCoordSys.AxisX) * -1.0;
                                PlanViewCoordSys.AxisY  = new TSG.Vector(ModelObjectCoordSys.AxisY);

                                TSG.Vector tempVector = (PlanViewCoordSys.AxisX.Cross(UpDirection));
                                if (tempVector == new TSG.Vector())
                                {
                                    tempVector = (ModelObjectCoordSys.AxisY.Cross(UpDirection));
                                }

                                PlanViewCoordSys.AxisX = tempVector.Cross(UpDirection);
                                PlanViewCoordSys.AxisY = tempVector;

                                TSM.Solid solid = selectedPart.GetSolid();

                                TSG.AABB aabbPlanView = new TSG.AABB();
                                aabbPlanView.MinPoint = new TSG.Point(-50, tsMinPt.Z - 50, tsMinPt.Y - 50);
                                aabbPlanView.MaxPoint = new TSG.Point(tsMaxPt.X + 50, tsMaxPt.Z + 50, tsMaxPt.Y + 50);

                                TSD.View PlanView = new TSD.View(gaDrawing.GetSheet(), PlanViewCoordSys, PlanViewCoordSys, aabbPlanView, "BRAD-Mod-Ass");
                                PlanView.Name  = "TOP";
                                PlanView.Scale = 10;
                                PlanView.Attributes.Shortening.CutParts      = true;
                                PlanView.Attributes.Shortening.MinimumLength = 1200;
                                PlanView.Attributes.Shortening.Offset        = 0.5;
                                PlanView.Insert();
                                PlanView.Attributes.FixedViewPlacing = true;
                                PlanView.Origin = new TSG.Point(100, 200);
                                PlanView.Modify();

                                TSG.CoordinateSystem FrontViewCoordSys = (TSG.CoordinateSystem)PlanViewCoordSys;
                                FrontViewCoordSys.AxisX = tempVector.Cross(UpDirection).GetNormal();
                                FrontViewCoordSys.AxisY = UpDirection.GetNormal();

                                TSG.AABB aabbFrontView = new TSG.AABB();
                                aabbFrontView.MinPoint = new TSG.Point(-50, tsMinPt.Y - 50, tsMinPt.Z - 50);
                                aabbFrontView.MaxPoint = new TSG.Point(tsMaxPt.X + 50, tsMaxPt.Y + 50, tsMaxPt.Z + 50);

                                TSD.View FrontView = new TSD.View(gaDrawing.GetSheet(), FrontViewCoordSys, FrontViewCoordSys, aabbFrontView, "BRAD-Mod-Ass");
                                FrontView.Name  = "FRONT";
                                FrontView.Scale = 10;
                                FrontView.Attributes.Shortening.CutParts      = true;
                                FrontView.Attributes.Shortening.MinimumLength = 1200;
                                FrontView.Attributes.Shortening.Offset        = 0.5;
                                FrontView.Insert();
                                FrontView.Attributes.FixedViewPlacing = true;
                                FrontView.Origin = new TSG.Point(100, (200 - FrontView.Height - 2));
                                FrontView.Modify();
                            }
                            if (selectedPart.Name.Contains("COLUMN"))
                            {
                                TSG.CoordinateSystem ModelObjectCoordSys = selectedPart.GetCoordinateSystem();
                                TSG.CoordinateSystem PlanViewCoordSys    = new TSG.CoordinateSystem();
                                PlanViewCoordSys.Origin = new TSG.Point(ModelObjectCoordSys.Origin);
                                PlanViewCoordSys.AxisX  = new TSG.Vector(ModelObjectCoordSys.AxisX);
                                PlanViewCoordSys.AxisY  = new TSG.Vector(ModelObjectCoordSys.AxisY);

                                TSG.Vector tempVector = (PlanViewCoordSys.AxisX.Cross(UpDirection));
                                if (tempVector == new TSG.Vector())
                                {
                                    tempVector = (ModelObjectCoordSys.AxisY.Cross(UpDirection));
                                }

                                TSG.AABB aabbPlanView = new TSG.AABB();
                                aabbPlanView.MinPoint = new TSG.Point(-50, tsMinPt.Y - 50, tsMinPt.Z - 50);
                                aabbPlanView.MaxPoint = new TSG.Point(tsMaxPt.X + 50, tsMaxPt.Y + 50, tsMaxPt.Z + 50);

                                TSD.View PlanView = new TSD.View(gaDrawing.GetSheet(), PlanViewCoordSys, PlanViewCoordSys, aabbPlanView, "BRAD-Mod-Ass");
                                PlanView.Name  = "TOP";
                                PlanView.Scale = 10;
                                PlanView.Attributes.Shortening.CutParts      = true;
                                PlanView.Attributes.Shortening.MinimumLength = 1200;
                                PlanView.Attributes.Shortening.Offset        = 0.5;
                                PlanView.Origin = new TSG.Point(100, 200);
                                PlanView.Insert();
                                PlanView.Attributes.FixedViewPlacing = true;
                                PlanView.Modify();

                                TSG.CoordinateSystem FrontViewCoordSys = (TSG.CoordinateSystem)PlanViewCoordSys;
                                FrontViewCoordSys.AxisY = new TSG.Vector(ModelObjectCoordSys.AxisY).Cross(UpDirection) * -1;

                                TSG.AABB aabbFrontView = new TSG.AABB();
                                aabbFrontView.MinPoint = new TSG.Point(-50, tsMinPt.Z - 50, tsMinPt.Y - 50);
                                aabbFrontView.MaxPoint = new TSG.Point(tsMaxPt.X + 50, tsMaxPt.Z + 50, tsMaxPt.Y + 50);

                                TSD.View FrontView = new TSD.View(gaDrawing.GetSheet(), FrontViewCoordSys, FrontViewCoordSys, aabbFrontView, "BRAD-Mod-Ass");
                                FrontView.Name  = "FRONT";
                                FrontView.Scale = 10;
                                FrontView.Attributes.Shortening.CutParts      = true;
                                FrontView.Attributes.Shortening.MinimumLength = 1200;
                                FrontView.Attributes.Shortening.Offset        = 0.5;
                                FrontView.Origin = new TSG.Point(100, (200 - FrontView.Height - 30));
                                FrontView.Insert();
                                FrontView.Attributes.FixedViewPlacing = true;
                                FrontView.Modify();
                            }
                            drawingHandler.CloseActiveDrawing(true);
                        }
                    }
                }
                MessageBox.Show("Drawings Created");
                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(current);
            }
            catch { }
        }
Exemplo n.º 8
0
        private void BtnCreate_Click(object sender, EventArgs e)
        {
            TSM.TransformationPlane current = model.GetWorkPlaneHandler().GetCurrentTransformationPlane();

            try
            {
                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TSM.TransformationPlane());
                TSM.ModelObjectEnumerator selectedModelObjects = new TSMUI.ModelObjectSelector().GetSelectedObjects();

                TSD.GADrawing MyDrawing = null;

                while (selectedModelObjects.MoveNext())
                {
                    TSG.CoordinateSystem ModelObjectCoordSys;

                    string ModelObjectName;
                    string DrawingName = "Part basic views" + (selectedModelObjects.Current as TSM.ModelObject).Identifier;

                    GetCoordinateSystemAndNameOfSelectedObject(selectedModelObjects, out ModelObjectCoordSys, out ModelObjectName);

                    MyDrawing = new TSD.GADrawing(DrawingName, "standard");
                    MyDrawing.Insert();

                    if (openDrawings.Checked)
                    {
                        drawingHandler.SetActiveDrawing(MyDrawing, true);
                    }
                    else
                    {
                        drawingHandler.SetActiveDrawing(MyDrawing, false);
                    }

                    ArrayList Parts = new ArrayList();

                    if (selectedModelObjects.Current is TSM.Part)
                    {
                        Parts.Add(selectedModelObjects.Current.Identifier);
                    }
                    else if (selectedModelObjects.Current is TSM.Assembly)
                    {
                        Parts = GetAssemblyParts(selectedModelObjects.Current as TSM.Assembly);
                    }
                    else if (selectedModelObjects.Current is TSM.BaseComponent)
                    {
                        Parts = GetComponentParts(selectedModelObjects.Current as TSM.BaseComponent);
                    }
                    else if (selectedModelObjects.Current is TSM.Task)
                    {
                        Parts = GetTaskParts(selectedModelObjects.Current as TSM.Task);
                    }

                    CreateViews(ModelObjectCoordSys, ModelObjectName, MyDrawing, Parts);

                    MyDrawing.PlaceViews();

                    drawingHandler.CloseActiveDrawing(true);
                }

                if (MyDrawing != null && openDrawings.Checked)
                {
                    drawingHandler.SetActiveDrawing(MyDrawing);
                }

                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(current);
            }
            catch (Exception Ex)
            {
                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(current);
                MessageBox.Show(Ex.Message);
            }
        }
        // The constructor argument defines the database class StructuresData and set the data to be used in the plug-in.
        public AngleBracingPlugin(StructuresData data)
        {
            Data        = data;
            _classModel = new TSM.Model();

            // pass fields from Structures Data into AngleBracingPlugin class
            _angleBracingType    = data.AngleBracingType;
            _anglePosition       = data.AnglePosition;
            _angleBracingProfile = data.AngleBracingProfile;

            // Convert string offset values to double
            if (!Double.TryParse(data.AngleOffset, out _angleOffset))
            {
                _angleOffset = 0.0; // Default offset to 0 if parse fails
            }

            if (!Double.TryParse(data.FirstOffset, out _firstOffset))
            {
                _firstOffset = 0.0; // Default offset to 0 if parse fails
            }

            if (!Double.TryParse(data.SecondOffset, out _secondOffset))
            {
                _secondOffset = 0.0; // Default offset to 0 if parse fails
            }

            if (!Double.TryParse(data.ThirdOffset, out _thirdOffset))
            {
                _thirdOffset = 0.0; // Default offset to 0 if parse fails
            }

            if (!Double.TryParse(data.FourthOffset, out _fourthOffset))
            {
                _fourthOffset = 0.0; // Default offset to 0 if parse fails
            }


            if (!Int32.TryParse(data.BoltQty, out _boltQty))
            {
                _boltQty = 1; // Default bolt quantity to 1 if parse fails
            }

            // Assign profile for angle
            try
            {
                _angleProfile = _angleType[_angleBracingProfile];
            }
            catch (IndexOutOfRangeException ex)
            {
                _angleProfile = _angleType[0];
            }
            catch (Exception ex)
            {
                _angleProfile = _angleType[0];
            }

            if (!Double.TryParse(_angleProfile.Substring(1, 1), out _angleWidth))
            {
                _angleWidth = 0.0;
            }
            else
            {
                _angleWidth *= 25.4;
            }

            _originalPlane = _classModel.GetWorkPlaneHandler().GetCurrentTransformationPlane();
        }
Exemplo n.º 10
0
        private void btn_multiBeams_Click(object sender, EventArgs e)
        {
            try
            {
                Picker    picker = new Picker();
                ArrayList points = picker.PickPoints(Picker.PickPointEnum.PICK_POLYGON);

                if (points.Count >= 3)
                {
                    TSG.Point  start     = new TSG.Point(0, 0, 0);
                    TSG.Point  middle    = new TSG.Point(0, 0, 0);
                    TSG.Point  end       = new TSG.Point(0, 0, 0);
                    TSG.Vector vectorFit = new TSG.Vector();
                    TSG.Vector vectorZ   = new TSG.Vector();
                    TSG.Vector vectorOne = new TSG.Vector();
                    TSG.Vector vectorTwo = new TSG.Vector();

                    ArrayList listBeams  = new ArrayList();
                    ArrayList listPlates = new ArrayList();

                    double angelDegree = 0.0;

                    for (int i = 0; i < points.Count - 1; i++)
                    {
                        TSM.Beam beam = BeamFirst(points[i] as TSG.Point, points[i + 1] as TSG.Point);
                        beam.Insert();
                        listBeams.Add(beam);
                        this.model.CommitChanges();
                    }

                    double primaryWidth  = 0.0;
                    double primaryHeight = 0.0;

                    for (int i = 0; i < points.Count - 1; i++)
                    {
                        try
                        {
                            start  = points[i] as TSG.Point;
                            middle = points[i + 1] as TSG.Point;
                            end    = points[i + 2] as TSG.Point;
                        }
                        catch
                        {
                        }

                        vectorOne = new TSG.Vector(middle.X - start.X, middle.Y - start.Y, middle.Z - start.Z);
                        vectorOne.Normalize();
                        vectorTwo = new TSG.Vector(middle.X - end.X, middle.Y - end.Y, middle.Z - end.Z);
                        vectorTwo.Normalize();
                        double angle = vectorOne.GetAngleBetween(vectorTwo);
                        angelDegree = angle * 180 / Math.PI;

                        //TSG.Vector vectorFit = new TSG.Vector(1 * Math.Cos(angle / 2), 1 * Math.Cos(angle / 2), 0);
                        vectorFit = new TSG.Vector(vectorOne.X + vectorTwo.X, vectorOne.Y + vectorTwo.Y, vectorOne.Z + vectorTwo.Z);
                        vectorZ   = vectorOne.Cross(vectorTwo);

                        TSG.CoordinateSystem coordinateSystem = new TSG.CoordinateSystem();

                        double thick;
                        if (tb_thcikPlates.Text != string.Empty)
                        {
                            double.TryParse(tb_thcikPlates.Text, out thick);
                        }
                        else
                        {
                            thick = 20.0;
                        }

                        double offset  = thick;
                        double angleFD = 90 - (angelDegree / 2);
                        double angleFR = Math.PI * angleFD / 180;

                        double width  = 0.0;
                        double heigth = 0.0;

                        double x = Math.Round(vectorFit.X, 2, MidpointRounding.ToEven);
                        double y = Math.Round(vectorFit.Y, 2, MidpointRounding.ToEven);
                        double z = Math.Round(vectorFit.Z, 2, MidpointRounding.ToEven);


                        TSM.Beam beam1 = listBeams[i] as TSM.Beam;
                        TSM.Beam beam2 = listBeams[i + 1] as TSM.Beam;
                        beam1.GetReportProperty("WIDTH", ref primaryWidth);
                        beam1.GetReportProperty("HEIGHT", ref primaryHeight);

                        if (x == 0.0 && y == 0.0 && z == 0.0)
                        {
                            TSG.Vector bAxisX = beam1.GetCoordinateSystem().AxisX;
                            TSG.Vector bAxisY = beam1.GetCoordinateSystem().AxisY;
                            TSG.Vector bAxisZ = bAxisY.Cross(bAxisX);

                            coordinateSystem = new TSG.CoordinateSystem(middle, bAxisZ, bAxisY);
                        }
                        else
                        {
                            coordinateSystem = new TSG.CoordinateSystem(
                                middle, vectorFit, vectorZ);
                        }

                        TSM.WorkPlaneHandler planeHandler = model.GetWorkPlaneHandler();

                        TSM.TransformationPlane original  = planeHandler.GetCurrentTransformationPlane();
                        TSM.TransformationPlane beamPlane = new TSM.TransformationPlane(coordinateSystem);
                        planeHandler.SetCurrentTransformationPlane(beamPlane);

                        FitBeam(beam1, -offset);
                        FitBeam(beam2, offset);

                        if (z != 0)
                        {
                            vectorZ = vectorTwo.Cross(vectorOne);

                            planeHandler.SetCurrentTransformationPlane(original);
                            TSG.CoordinateSystem coordinatePlate = new TSG.CoordinateSystem(
                                middle, vectorZ, vectorFit);

                            TSM.TransformationPlane beamPlate = new TSM.TransformationPlane(coordinatePlate);
                            planeHandler.SetCurrentTransformationPlane(beamPlate);

                            width  = primaryWidth;
                            heigth = 50 + primaryHeight / (Math.Cos(angleFR));
                        }
                        else
                        {
                            width  = 50 + primaryWidth / (Math.Cos(angleFR));
                            heigth = primaryHeight;
                        }


                        bool positionPlate = true;

                        for (int k = 0; k < 2; k++)
                        {
                            TSM.ContourPlate plate = PlateFirst(width, heigth, offset);
                            if (positionPlate)
                            {
                                plate.Position.Depth = TSM.Position.DepthEnum.BEHIND;
                                positionPlate        = false;
                            }
                            else
                            {
                                plate.Position.Depth = TSM.Position.DepthEnum.FRONT;
                            }
                            plate.Insert();
                            listPlates.Add(plate);
                        }

                        TSM.ContourPlate plate1 = listPlates[0] as TSM.ContourPlate;
                        TSM.ContourPlate plate2 = listPlates[1] as TSM.ContourPlate;

                        BoltPlatetoPlate(plate1, plate2, heigth, width);

                        WeldBeamToPlate(beam1, plate1);
                        WeldBeamToPlate(beam2, plate2);

                        planeHandler.SetCurrentTransformationPlane(original);

                        this.model.CommitChanges();
                        listPlates.Clear();
                    }

                    this.model.CommitChanges();

                    listBeams.Clear();
                }
                else
                {
                    MessageBox.Show(Tekla.Structures.Dialog.UIControls.LocalizeForm.Localization.GetText("albl_Invalid_input_parts"));//translation of text in message box
                }
            }
            catch
            {
            }
        }
Exemplo n.º 11
0
        public override bool Run(List <InputDefinition> Input)
        {
            try
            {
                // 오버라이드 된 DefineInput에서 List를 가져옴
                // purlin = 중도리 지붕을 지탱하는 골조
                // flange = 플랜지 파이프를 연결하기 위한 배관?
                Beam Purlin1 = (Beam)_model.SelectModelObject((Identifier)Input[0].GetInput());
                Beam Purlin2 = (Beam)_model.SelectModelObject((Identifier)Input[1].GetInput());
                Beam OFlange = (Beam)_model.SelectModelObject((Identifier)Input[2].GetInput());
                Beam Web     = (Beam)_model.SelectModelObject((Identifier)Input[3].GetInput());
                Beam IFlange = (Beam)_model.SelectModelObject((Identifier)Input[4].GetInput());

                // 초기값 체크
                GetValuesFromDialog();

                double WebThick     = 0.0;
                double IFlangeWidth = 0.0;
                double IFlangeThick = 0.0;
                double OFlangeThick = 0.0;
                Web.GetReportProperty("WIDTH", ref WebThick);
                OFlange.GetReportProperty("WIDTH", ref OFlangeThick);
                IFlange.GetReportProperty("WIDTH", ref IFlangeThick);
                IFlange.GetReportProperty("HEIGHT", ref IFlangeWidth);

                if (IsDefaultValue(_PlateWidth) || _PlateWidth == 0)
                {
                    _PlateWidth = (IFlangeWidth - WebThick) * 0.5;
                }
                if (IsDefaultValue(_PlateLength) || _PlateLength == 0)
                {
                    _PlateLength = (IFlangeWidth - WebThick) * 0.5;
                }

                CoordinateSystem WebSys = Web.GetCoordinateSystem();

                // 평면(Web)과 선(purlin1의 시작과 끝점)이 만나는 교차점
                T3D.Point TopCenter = T3D.Intersection.LineToPlane(new Line(Purlin1.StartPoint, Purlin1.EndPoint), new GeometricPlane(WebSys.Origin, WebSys.AxisX, WebSys.AxisY));

                // 실제 좌표점(x,y,z)
                CoordinateSystem WorkSystem = new CoordinateSystem(TopCenter, WebSys.AxisX.Cross(WebSys.AxisY), WebSys.AxisY);

                // CoordinateSystem의 실좌표를 Plane 변경
                _model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane(WorkSystem));

                Purlin1.Select();
                Purlin2.Select();
                Web.Select();
                OFlange.Select();
                IFlange.Select();

                CoordinateSystem PurSys        = Purlin1.GetCoordinateSystem();
                T3D.Point        TopClipCenter = T3D.Intersection.LineToPlane(new Line(OFlange.StartPoint, OFlange.EndPoint), new GeometricPlane(PurSys.Origin, PurSys.AxisX, PurSys.AxisY));
                T3D.Point        BottCenter    = T3D.Intersection.LineToPlane(new Line(IFlange.StartPoint, IFlange.EndPoint), new GeometricPlane(PurSys.Origin, PurSys.AxisX, PurSys.AxisY));

                T3D.Point LeftAngleFirstPoint   = new T3D.Point(-_UpperHorizontalDistance, _UpperVerticalDistance, 0);
                T3D.Point LeftAngleSecondPoint  = new T3D.Point(-_LowerHorizontalDistance, BottCenter.Y - IFlangeThick + _LowerVerticalDistance, 0);
                T3D.Point RightAngleFirstPoint  = new T3D.Point(_UpperHorizontalDistance, _UpperVerticalDistance, 0);
                T3D.Point RightAngleSecondPoint = new T3D.Point(_LowerHorizontalDistance, BottCenter.Y - IFlangeThick + _LowerVerticalDistance, 0);

                Beam         LeftAngle  = new Beam();
                Beam         RightAngle = new Beam();
                Beam         TopClip    = new Beam();
                ContourPlate LeftPlate  = new ContourPlate();
                ContourPlate RightPlate = new ContourPlate();

                TopClip.StartPoint = new T3D.Point(-_TopClipLength * 0.5, TopClipCenter.Y + OFlangeThick, 0);
                TopClip.EndPoint   = new T3D.Point(_TopClipLength * 0.5, TopClipCenter.Y + OFlangeThick, 0);

                if (PurSys.AxisX.GetNormal() == new Vector(1, 0, 0) && PurSys.AxisY.GetNormal() == new Vector(0, 1, 0))
                {
                    LeftAngle.StartPoint         = LeftAngleSecondPoint;
                    LeftAngle.EndPoint           = LeftAngleFirstPoint;
                    RightAngle.StartPoint        = RightAngleFirstPoint;
                    RightAngle.EndPoint          = RightAngleSecondPoint;
                    LeftAngle.Position.Plane     = Position.PlaneEnum.LEFT;
                    LeftAngle.Position.Rotation  = Position.RotationEnum.BELOW;
                    LeftAngle.Position.Depth     = Position.DepthEnum.BEHIND;
                    RightAngle.Position.Plane    = Position.PlaneEnum.LEFT;
                    RightAngle.Position.Rotation = Position.RotationEnum.BELOW;
                    RightAngle.Position.Depth    = Position.DepthEnum.BEHIND;
                    TopClip.Position.Plane       = Position.PlaneEnum.LEFT;
                    TopClip.Position.Rotation    = Position.RotationEnum.FRONT;
                    TopClip.Position.Depth       = Position.DepthEnum.BEHIND;
                    LeftPlate.Position.Depth     = Position.DepthEnum.FRONT;
                    RightPlate.Position.Depth    = Position.DepthEnum.FRONT;
                }
                else
                {
                    LeftAngle.StartPoint         = LeftAngleFirstPoint;
                    LeftAngle.EndPoint           = LeftAngleSecondPoint;
                    RightAngle.StartPoint        = RightAngleFirstPoint;
                    RightAngle.EndPoint          = RightAngleSecondPoint;
                    LeftAngle.Position.Plane     = Position.PlaneEnum.RIGHT;
                    LeftAngle.Position.Rotation  = Position.RotationEnum.TOP;
                    LeftAngle.Position.Depth     = Position.DepthEnum.FRONT;
                    RightAngle.Position.Plane    = Position.PlaneEnum.RIGHT;
                    RightAngle.Position.Rotation = Position.RotationEnum.FRONT;
                    RightAngle.Position.Depth    = Position.DepthEnum.FRONT;
                    TopClip.Position.Plane       = Position.PlaneEnum.LEFT;
                    TopClip.Position.Rotation    = Position.RotationEnum.FRONT;
                    TopClip.Position.Depth       = Position.DepthEnum.FRONT;
                    LeftPlate.Position.Depth     = Position.DepthEnum.BEHIND;
                    RightPlate.Position.Depth    = Position.DepthEnum.BEHIND;
                }

                LeftAngle.Profile.ProfileString   = _FlangeProfile;
                LeftAngle.Material.MaterialString = _FlangeMaterial;
                LeftAngle.Class = _FlangeClass;
                LeftAngle.Name  = _FlangeName;
                LeftAngle.Insert();

                RightAngle.Profile.ProfileString   = _FlangeProfile;
                RightAngle.Material.MaterialString = _FlangeMaterial;
                RightAngle.Class = _FlangeClass;
                RightAngle.Name  = _FlangeName;
                RightAngle.Insert();

                double BraceWidth     = 0.0;
                double BraceThickness = 0.0;
                RightAngle.GetReportProperty("WIDTH", ref BraceWidth);
                RightAngle.GetReportProperty("PROFILE.FLANGE_THICKNESS_1", ref BraceThickness);

                double BoltGauge = (BraceWidth + BraceThickness) * 0.5;
                LeftAngle.Position.PlaneOffset = -BoltGauge;
                LeftAngle.StartPointOffset.Dx  = _UpperBoltHorizontalDistance;
                LeftAngle.EndPointOffset.Dx    = _LowerBoltHorizontalDistance;
                LeftAngle.Modify();
                RightAngle.Position.PlaneOffset = -BoltGauge;
                RightAngle.StartPointOffset.Dx  = -_LowerBoltHorizontalDistance;
                RightAngle.EndPointOffset.Dx    = _UpperBoltHorizontalDistance;
                RightAngle.Modify();

                TopClip.Profile.ProfileString   = "PL" + _TopClipThickness + "*" + _TopClipWidth;
                TopClip.Material.MaterialString = _TopClipMaterial;
                TopClip.Name = _TopClipName;
                TopClip.Insert();

                Point        LeftPlatePoint1        = new Point(BottCenter.X - WebThick * 0.5, BottCenter.Y, 0);
                Point        LeftPlatePoint2        = new Point(BottCenter.X - WebThick * 0.5, BottCenter.Y + _PlateLength, 0);
                Point        LeftPlatePoint3        = new Point(BottCenter.X - WebThick * 0.5 - _PlateWidth, BottCenter.Y + _PlateLength, 0);
                Point        LeftPlatePoint4        = new Point(BottCenter.X - WebThick * 0.5 - _PlateWidth, BottCenter.Y, 0);
                ContourPoint LeftPlateContourPoint1 = new ContourPoint(LeftPlatePoint1, new Chamfer(30, 30, Chamfer.ChamferTypeEnum.CHAMFER_LINE));
                ContourPoint LeftPlateContourPoint2 = new ContourPoint(LeftPlatePoint2, new Chamfer());
                ContourPoint LeftPlateContourPoint3 = new ContourPoint(LeftPlatePoint3, new Chamfer());
                ContourPoint LeftPlateContourPoint4 = new ContourPoint(LeftPlatePoint4, new Chamfer());
                LeftPlate.AddContourPoint(LeftPlateContourPoint1);
                LeftPlate.AddContourPoint(LeftPlateContourPoint2);
                LeftPlate.AddContourPoint(LeftPlateContourPoint3);
                LeftPlate.AddContourPoint(LeftPlateContourPoint4);
                LeftPlate.Material.MaterialString = _PlateMaterial;
                LeftPlate.Profile.ProfileString   = "PL" + _PlateThickness.ToString();
                LeftPlate.Name = _PlateName;
                LeftPlate.Insert();

                Point        RightPlatePoint1        = new Point(BottCenter.X + WebThick * 0.5, BottCenter.Y, 0);
                Point        RightPlatePoint2        = new Point(RightPlatePoint1.X + _PlateWidth, RightPlatePoint1.Y, 0);
                Point        RightPlatePoint3        = new Point(RightPlatePoint2.X, RightPlatePoint2.Y + _PlateLength, 0);
                Point        RightPlatePoint4        = new Point(RightPlatePoint3.X - _PlateWidth, RightPlatePoint3.Y, 0);
                ContourPoint RightPlateContourPoint1 = new ContourPoint(RightPlatePoint1, new Chamfer(30, 30, Chamfer.ChamferTypeEnum.CHAMFER_LINE));
                ContourPoint RightPlateContourPoint2 = new ContourPoint(RightPlatePoint2, new Chamfer());
                ContourPoint RightPlateContourPoint3 = new ContourPoint(RightPlatePoint3, new Chamfer());
                ContourPoint RightPlateContourPoint4 = new ContourPoint(RightPlatePoint4, new Chamfer());
                RightPlate.AddContourPoint(RightPlateContourPoint1);
                RightPlate.AddContourPoint(RightPlateContourPoint2);
                RightPlate.AddContourPoint(RightPlateContourPoint3);
                RightPlate.AddContourPoint(RightPlateContourPoint4);
                RightPlate.Material.MaterialString = _PlateMaterial;
                RightPlate.Profile.ProfileString   = "PL" + _PlateThickness.ToString();
                RightPlate.Name = _PlateName;
                RightPlate.Insert();

                Beam LeftPurlin  = Purlin1;
                Beam RightPurlin = Purlin2;
                if ((Purlin1.StartPoint.X - Purlin2.StartPoint.X) > 1 || (Purlin1.StartPoint.Y - Purlin2.StartPoint.Y) > 1)
                {
                    RightPurlin = Purlin1;
                    LeftPurlin  = Purlin2;
                }

                Weld LeftPlateToIFlange = new Weld();
                LeftPlateToIFlange.MainObject      = IFlange;
                LeftPlateToIFlange.SecondaryObject = LeftPlate;
                LeftPlateToIFlange.ShopWeld        = true;
                LeftPlateToIFlange.Insert();
                Weld LeftPlateToWeb = new Weld();
                LeftPlateToWeb.MainObject      = Web;
                LeftPlateToWeb.SecondaryObject = LeftPlate;
                LeftPlateToWeb.ShopWeld        = true;
                LeftPlateToWeb.Insert();
                Weld RightPlateToIFlange = new Weld();
                RightPlateToIFlange.MainObject      = IFlange;
                RightPlateToIFlange.SecondaryObject = RightPlate;
                RightPlateToIFlange.ShopWeld        = true;
                RightPlateToIFlange.Insert();
                Weld RightPlateToWeb = new Weld();
                RightPlateToWeb.MainObject      = Web;
                RightPlateToWeb.SecondaryObject = RightPlate;
                RightPlateToWeb.ShopWeld        = true;
                RightPlateToWeb.Insert();

                PolygonWeld ClipToFlange = new PolygonWeld();
                ClipToFlange.TypeAbove       = BaseWeld.WeldTypeEnum.WELD_TYPE_FILLET;
                ClipToFlange.TypeBelow       = BaseWeld.WeldTypeEnum.WELD_TYPE_FILLET;
                ClipToFlange.SizeAbove       = _ClipWeldSize;
                ClipToFlange.SizeBelow       = _ClipWeldSize;
                ClipToFlange.MainObject      = OFlange;
                ClipToFlange.SecondaryObject = TopClip;
                ClipToFlange.ShopWeld        = true;
                ClipToFlange.Polygon.Points.Add(TopClip.StartPoint);
                ClipToFlange.Polygon.Points.Add(TopClip.EndPoint);
                ClipToFlange.Insert();

                // Bolting Brace with Plate or Purlin
                BoltArray UpperLeftBolt = new BoltArray();
                UpperLeftBolt.PartToBoltTo   = LeftPurlin;
                UpperLeftBolt.PartToBeBolted = LeftAngle;
                UpperLeftBolt.FirstPosition  = LeftAngle.StartPoint;
                UpperLeftBolt.SecondPosition = LeftAngle.EndPoint;
                UpperLeftBolt.AddBoltDistX(0.0);
                UpperLeftBolt.AddBoltDistY(0.0);
                UpperLeftBolt.BoltSize          = _BraceBoltSize;
                UpperLeftBolt.Tolerance         = 0.0625 * 25.4;
                UpperLeftBolt.BoltStandard      = _BraceBoltStandard;
                UpperLeftBolt.BoltType          = BoltGroup.BoltTypeEnum.BOLT_TYPE_SITE;
                UpperLeftBolt.CutLength         = 76.2;
                UpperLeftBolt.Bolt              = true;
                UpperLeftBolt.Position.Rotation = Position.RotationEnum.FRONT;
                BoltArray LowerLeftBolt = new BoltArray();
                LowerLeftBolt.PartToBoltTo   = LeftPlate;
                LowerLeftBolt.PartToBeBolted = LeftAngle;
                LowerLeftBolt.FirstPosition  = LeftAngle.EndPoint;
                LowerLeftBolt.SecondPosition = LeftAngle.StartPoint;
                LowerLeftBolt.AddBoltDistX(0.0);
                LowerLeftBolt.AddBoltDistY(0.0);
                LowerLeftBolt.BoltSize          = _BraceBoltSize;
                LowerLeftBolt.BoltStandard      = _BraceBoltStandard;
                LowerLeftBolt.Tolerance         = 0.0625 * 25.4;
                LowerLeftBolt.BoltType          = BoltGroup.BoltTypeEnum.BOLT_TYPE_SITE;
                LowerLeftBolt.CutLength         = 76.2;
                LowerLeftBolt.Bolt              = true;
                LowerLeftBolt.Position.Rotation = Position.RotationEnum.FRONT;
                BoltArray UpperRightBolt = new BoltArray();
                UpperRightBolt.PartToBoltTo   = RightPurlin;
                UpperRightBolt.PartToBeBolted = RightAngle;
                UpperRightBolt.FirstPosition  = RightAngle.EndPoint;
                UpperRightBolt.SecondPosition = RightAngle.StartPoint;
                UpperRightBolt.AddBoltDistX(0.0);
                UpperRightBolt.AddBoltDistY(0.0);
                UpperRightBolt.BoltSize          = _BraceBoltSize;
                UpperRightBolt.Tolerance         = 0.0625 * 25.4;
                UpperRightBolt.BoltStandard      = _BraceBoltStandard;
                UpperRightBolt.BoltType          = BoltGroup.BoltTypeEnum.BOLT_TYPE_SITE;
                UpperRightBolt.CutLength         = 76.2;
                UpperRightBolt.Bolt              = true;
                UpperRightBolt.Position.Rotation = Position.RotationEnum.FRONT;
                BoltArray LowerRightBolt = new BoltArray();
                LowerRightBolt.PartToBoltTo   = RightPlate;
                LowerRightBolt.PartToBeBolted = RightAngle;
                LowerRightBolt.FirstPosition  = RightAngle.StartPoint;
                LowerRightBolt.SecondPosition = RightAngle.EndPoint;
                LowerRightBolt.AddBoltDistX(0.0);
                LowerRightBolt.AddBoltDistY(0.0);
                LowerRightBolt.BoltSize          = _BraceBoltSize;
                LowerRightBolt.Tolerance         = 0.0625 * 25.4;
                LowerRightBolt.BoltStandard      = _BraceBoltStandard;
                LowerRightBolt.BoltType          = BoltGroup.BoltTypeEnum.BOLT_TYPE_SITE;
                LowerRightBolt.CutLength         = 76.2;
                LowerRightBolt.Bolt              = true;
                LowerRightBolt.Position.Rotation = Position.RotationEnum.FRONT;

                // Bolting ClipPlate with purlin
                BoltArray ClipBolts1 = new BoltArray();
                ClipBolts1.PartToBoltTo        = LeftPurlin;
                ClipBolts1.PartToBeBolted      = TopClip;
                ClipBolts1.FirstPosition       = TopClip.StartPoint;
                ClipBolts1.SecondPosition      = TopClip.EndPoint;
                ClipBolts1.StartPointOffset.Dx = 31.75;
                ClipBolts1.AddBoltDistX(0);
                ClipBolts1.AddBoltDistY(76.2);
                ClipBolts1.StartPointOffset.Dy = 76.2;
                ClipBolts1.EndPointOffset.Dy   = 76.2;
                ClipBolts1.BoltSize            = _ClipBoltSize;
                ClipBolts1.Tolerance           = 0.0625 * 25.4;
                ClipBolts1.BoltStandard        = _CliptBoltStandard;
                ClipBolts1.BoltType            = BoltGroup.BoltTypeEnum.BOLT_TYPE_SITE;
                ClipBolts1.CutLength           = 76.2;
                ClipBolts1.Bolt = true;
                ClipBolts1.Position.Rotation = Position.RotationEnum.FRONT;

                BoltArray ClipBolts2 = new BoltArray();
                ClipBolts2.PartToBoltTo        = RightPurlin;
                ClipBolts2.PartToBeBolted      = TopClip;
                ClipBolts2.FirstPosition       = TopClip.StartPoint;
                ClipBolts2.SecondPosition      = TopClip.EndPoint;
                ClipBolts2.StartPointOffset.Dx = _TopClipLength - 31.75;
                ClipBolts2.AddBoltDistX(0);
                ClipBolts2.AddBoltDistY(76.2);
                ClipBolts2.StartPointOffset.Dy = 76.2;
                ClipBolts2.EndPointOffset.Dy   = 76.2;
                ClipBolts2.BoltSize            = _ClipBoltSize;
                ClipBolts2.Tolerance           = 0.0625 * 25.4;
                ClipBolts2.BoltStandard        = _CliptBoltStandard;
                ClipBolts2.BoltType            = BoltGroup.BoltTypeEnum.BOLT_TYPE_SITE;
                ClipBolts2.CutLength           = 76.2;
                ClipBolts2.Bolt = true;
                ClipBolts2.Position.Rotation = Position.RotationEnum.FRONT;

                if (PurSys.AxisX.GetNormal() == new Vector(1, 0, 0) && PurSys.AxisX.GetNormal() == new Vector(0, 1, 0))
                {
                    UpperLeftBolt.FirstPosition      = LeftAngle.EndPoint;
                    UpperLeftBolt.SecondPosition     = LeftAngle.StartPoint;
                    UpperLeftBolt.Position.Rotation  = Position.RotationEnum.BACK;
                    LowerLeftBolt.FirstPosition      = LeftAngle.StartPoint;
                    LowerLeftBolt.SecondPosition     = LeftAngle.EndPoint;
                    LowerLeftBolt.Position.Rotation  = Position.RotationEnum.BACK;
                    UpperRightBolt.FirstPosition     = RightAngle.StartPoint;
                    UpperRightBolt.SecondPosition    = RightAngle.EndPoint;
                    UpperRightBolt.Position.Rotation = Position.RotationEnum.BACK;
                    LowerRightBolt.FirstPosition     = RightAngle.StartPoint;
                    LowerRightBolt.SecondPosition    = RightAngle.EndPoint;
                    LowerRightBolt.Position.Rotation = Position.RotationEnum.BACK;
                    ClipBolts1.Position.Rotation     = Position.RotationEnum.BACK;
                    ClipBolts2.Position.Rotation     = Position.RotationEnum.BACK;
                }
                UpperLeftBolt.Insert();
                LowerLeftBolt.Insert();
                UpperRightBolt.Insert();
                LowerRightBolt.Insert();
                ClipBolts1.Insert();
                ClipBolts2.Insert();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }

            return(true);
        }
Exemplo n.º 12
0
        private void btnConvert_Click(object sender, EventArgs e)
        {
            ModelObjectSelector mos = new ModelObjectSelector();

            TSM.ModelObjectEnumerator moe = mos.GetSelectedObjects();

            moe.SelectInstances = false;

            while (moe.MoveNext())
            {
                if (moe.Current is TSM.Part)
                {
                    TSM.Part part = moe.Current as TSM.Part;

                    // this method needs to be called to properly fill all the properties of the part
                    part.Select();

                    double partLength = 0.0;
                    double partHeight = 0.0;
                    double partWidth  = 0.0;
                    part.GetReportProperty("LENGTH", ref partLength);
                    part.GetReportProperty("HEIGHT", ref partHeight);
                    part.GetReportProperty("WIDTH", ref partWidth);

                    TSM.ModelObjectEnumerator MyAllBooleans = part.GetBooleans();
                    TSM.ModelObjectEnumerator MyAllBolts    = part.GetBolts();
                    TSM.ModelObject           MyFather      = part.GetFatherComponent();


                    TSG.CoordinateSystem coordinateSystem = part.GetCoordinateSystem();
                    TSM.WorkPlaneHandler planeHandler     = model.GetWorkPlaneHandler();

                    // before we create a new plane we need to store the old one
                    TSM.TransformationPlane original  = planeHandler.GetCurrentTransformationPlane();
                    TSM.TransformationPlane partPlane = new TSM.TransformationPlane(coordinateSystem);
                    planeHandler.SetCurrentTransformationPlane(partPlane);

                    //this.DrawCoordinateSystem();

                    TSG.Point p1 = new TSG.Point(0, partHeight / 2, 0);
                    TSG.Point p2 = new TSG.Point(partLength, partHeight / 2, 0);
                    TSG.Point p3 = new TSG.Point(partLength, -partHeight / 2, 0);
                    TSG.Point p4 = new TSG.Point(0, -partHeight / 2, 0);

                    TSM.ContourPlate CP            = new TSM.ContourPlate();
                    TSM.ContourPoint conturePoint1 = new TSM.ContourPoint(p1, null);
                    TSM.ContourPoint conturePoint2 = new TSM.ContourPoint(p2, null);
                    TSM.ContourPoint conturePoint3 = new TSM.ContourPoint(p3, null);
                    TSM.ContourPoint conturePoint4 = new TSM.ContourPoint(p4, null);

                    CP.AddContourPoint(conturePoint1);
                    CP.AddContourPoint(conturePoint2);
                    CP.AddContourPoint(conturePoint3);
                    CP.AddContourPoint(conturePoint4);
                    CP.Name   = "NEM";
                    CP.Finish = "xxx";
                    CP.Profile.ProfileString   = "PL" + partWidth;
                    CP.Material.MaterialString = "S235";
                    CP.Class = "1";

                    CP.Insert();

                    while (MyAllBooleans.MoveNext())
                    {
                        try
                        {
                            TSM.BooleanPart partBooleans = MyAllBooleans.Current as TSM.BooleanPart;

                            TSM.Part partBool = partBooleans.OperativePart as TSM.Part;
                            partBool.Class = TSM.BooleanPart.BooleanOperativeClassName;
                            partBool.Insert();

                            TSM.BooleanPart myboolpart = new TSM.BooleanPart();
                            myboolpart.Father = CP;
                            myboolpart.SetOperativePart(partBool);
                            myboolpart.Insert();
                            partBool.Delete();
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                    }


                    while (MyAllBolts.MoveNext())
                    {
                        try
                        {
                            if (MyAllBolts.Current is TSM.BoltGroup)
                            {
                                TSM.BoltGroup b = MyAllBolts.Current as TSM.BoltGroup;

                                TSM.Part toBolted = b.PartToBeBolted as TSM.Part;
                                TSM.Part toBolt   = b.PartToBoltTo as TSM.Part;
                                if (toBolted.Identifier.ID == toBolt.Identifier.ID)
                                {
                                    b.PartToBeBolted = CP;
                                    b.PartToBoltTo   = CP;
                                }
                                else if (toBolted.Identifier.ID == part.Identifier.ID)
                                {
                                    b.PartToBoltTo.GetBolts();
                                    b.PartToBeBolted = CP;
                                }
                                else
                                {
                                    b.PartToBoltTo = CP;
                                    b.PartToBeBolted.GetBolts();
                                }
                                b.Insert();
                            }
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                    }

                    if (MyFather != null)
                    {
                        TSM.ModelObjectEnumerator elementOfComponenet = MyFather.GetChildren();
                        while (elementOfComponenet.MoveNext())
                        {
                            TSM.Part element = elementOfComponenet.Current as TSM.Part;
                            try
                            {
                                if (element is TSM.Part)
                                {
                                    if (element.Identifier.ID == part.Identifier.ID)
                                    {
                                        element = CP;

                                        element.Modify();
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                }
                                else
                                {
                                    continue;
                                }
                            }
                            catch (Exception)
                            {
                                throw;
                            }
                        }
                    }



                    part.Delete();
                    planeHandler.SetCurrentTransformationPlane(original);
                }
            }

            this.model.CommitChanges();
        }
Exemplo n.º 13
0
        private void button1_Click(object sender, EventArgs e)
        {
            //1. 기본 가정
            // 1) 슬라브를 배치할 두 빔은 평행
            // 2) 슬라브는 비스듬하게 배치되지 않음.(두빔에 항상 수직방향으로 배치됨)
            // 3) 슬라브는 z평면과 수평하게 배치됨

            ContourPlate contourPlate = new ContourPlate();

            contourPlate.Position.Depth = Position.DepthEnum.FRONT;

            //2. 현재 모델의 좌표계(글로벌좌표계) 및 Z 벡터 저장
            TSM.Model           currentModel     = new TSM.Model();
            WorkPlaneHandler    workPlaneHandler = currentModel.GetWorkPlaneHandler();
            TransformationPlane originPlane      = workPlaneHandler.GetCurrentTransformationPlane();

            //3. 슬라브 생성할 두 부재 선택
            Picker picker = new Picker();

            TSM.ModelObject mainpart  = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_PART, "슬라브를 삽입할 첫번째 부재를 선택하세요.");
            TSM.Beam        startBeam = mainpart as TSM.Beam;
            mainpart = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_PART, "슬라브를 삽입할 두번째 부재를 선택하세요.");
            TSM.Beam endBeam = mainpart as TSM.Beam;

            //4. 새 좌표계 생성(startBeam과 EndBeam과의 관계 내포)
            TSG.Vector          coordinateVector2    = new TSG.Vector(startBeam.EndPoint - startBeam.StartPoint);
            TSG.Vector          coordinateVector1    = new TSG.Vector(endBeam.EndPoint - startBeam.StartPoint);
            TransformationPlane slabCoordinateSystem = new TransformationPlane(startBeam.StartPoint, coordinateVector2, coordinateVector1);

            workPlaneHandler.SetCurrentTransformationPlane(slabCoordinateSystem);

            //5. 슬라브 Point시작점 위치 잡기
            //1) 슬라브 벡터 설정
            TSG.Vector slabVector = new TSG.Vector(0, 1, 0);

            //3) offset길이만큼 beam1 e.p 방향으로 이동(추후 작성)
            //4) 걸침 높이만큼 z축 방향으로 이동(여기서는 slab Height로 가야함)(추후 작성)

            //6. 슬라브 치수요소 입력 ( 현재는 상수 )
            double slabWidthLeft   = 300;
            double slabWidthCenter = 300;
            double slabWidthRight  = 300;
            double slabHeight      = 300;
            double ribDistUpper    = 50;
            double ribDistLower    = 30;
            double slabThickness   = 100;

            //7. 슬라브 시작점 설정
            TSG.Point slabStartPoint = new TSG.Point(0, 0, (Methods.GetGirderHeight(startBeam) * 0.5 + slabHeight) * -1);

            //Y방향 설정
            double startOffset = 100;

            slabStartPoint += slabVector * Methods.GetGirderWidth(startBeam) * 0.5;
            slabStartPoint += slabVector * startOffset * -1;

            //8. 슬라브 포인트 입력 (수정)
            TSG.Point point1  = new TSG.Point(slabStartPoint.X, slabStartPoint.Y, slabStartPoint.Z);
            TSG.Point point2  = new TSG.Point(slabStartPoint.X, slabStartPoint.Y, slabStartPoint.Z + (slabThickness));
            TSG.Point point3  = new TSG.Point(slabStartPoint.X + slabWidthLeft - ribDistUpper / 2, slabStartPoint.Y, slabStartPoint.Z + (slabThickness));
            TSG.Point point4  = new TSG.Point(slabStartPoint.X + slabWidthLeft - ribDistLower / 2, slabStartPoint.Y, slabStartPoint.Z + (slabHeight));
            TSG.Point point5  = new TSG.Point(slabStartPoint.X + slabWidthLeft + ribDistLower / 2, slabStartPoint.Y, slabStartPoint.Z + (slabHeight));
            TSG.Point point6  = new TSG.Point(slabStartPoint.X + slabWidthLeft + ribDistUpper / 2, slabStartPoint.Y, slabStartPoint.Z + (slabThickness));
            TSG.Point point7  = new TSG.Point(slabStartPoint.X + slabWidthLeft + slabWidthCenter - ribDistUpper / 2, slabStartPoint.Y, slabStartPoint.Z + (slabThickness));
            TSG.Point point8  = new TSG.Point(slabStartPoint.X + slabWidthLeft + slabWidthCenter - ribDistLower / 2, slabStartPoint.Y, slabStartPoint.Z + (slabHeight));
            TSG.Point point9  = new TSG.Point(slabStartPoint.X + slabWidthLeft + slabWidthCenter + ribDistLower / 2, slabStartPoint.Y, slabStartPoint.Z + (slabHeight));
            TSG.Point point10 = new TSG.Point(slabStartPoint.X + slabWidthLeft + slabWidthCenter + ribDistUpper / 2, slabStartPoint.Y, slabStartPoint.Z + (slabThickness));
            TSG.Point point11 = new TSG.Point(slabStartPoint.X + slabWidthLeft + slabWidthCenter + slabWidthRight, slabStartPoint.Y, slabStartPoint.Z + (slabThickness));
            TSG.Point point12 = new TSG.Point(slabStartPoint.X + slabWidthLeft + slabWidthCenter + slabWidthRight, slabStartPoint.Y, slabStartPoint.Z);

            //TSG.Point point1 = new TSG.Point(slabStartPoint.X, slabStartPoint.Y, slabStartPoint.Z);
            //TSG.Point point2 = new TSG.Point(slabStartPoint.X, slabStartPoint.Y, slabStartPoint.Z + (slabThickness) * -1);
            //TSG.Point point3 = new TSG.Point(slabStartPoint.X + slabWidthLeft - ribDistUpper / 2, slabStartPoint.Y, slabStartPoint.Z + (slabThickness) * -1);
            //TSG.Point point4 = new TSG.Point(slabStartPoint.X + slabWidthLeft - ribDistLower / 2, slabStartPoint.Y, slabStartPoint.Z + (slabHeight) * -1);
            //TSG.Point point5 = new TSG.Point(slabStartPoint.X + slabWidthLeft + ribDistLower / 2, slabStartPoint.Y, slabStartPoint.Z + (slabHeight) * -1);
            //TSG.Point point6 = new TSG.Point(slabStartPoint.X + slabWidthLeft + ribDistUpper / 2, slabStartPoint.Y, slabStartPoint.Z + (slabThickness) * -1);
            //TSG.Point point7 = new TSG.Point(slabStartPoint.X + slabWidthLeft + slabWidthCenter - ribDistUpper / 2, slabStartPoint.Y, slabStartPoint.Z + (slabThickness) * -1);
            //TSG.Point point8 = new TSG.Point(slabStartPoint.X + slabWidthLeft + slabWidthCenter - ribDistLower / 2, slabStartPoint.Y, slabStartPoint.Z + (slabHeight) * -1);
            //TSG.Point point9 = new TSG.Point(slabStartPoint.X + slabWidthLeft + slabWidthCenter + ribDistLower / 2, slabStartPoint.Y, slabStartPoint.Z + (slabHeight) * -1);
            //TSG.Point point10 = new TSG.Point(slabStartPoint.X + slabWidthLeft + slabWidthCenter + ribDistUpper / 2, slabStartPoint.Y, slabStartPoint.Z + (slabThickness) * -1);
            //TSG.Point point11 = new TSG.Point(slabStartPoint.X + slabWidthLeft + slabWidthCenter + slabWidthRight, slabStartPoint.Y, slabStartPoint.Z + (slabThickness) * -1);
            //TSG.Point point12 = new TSG.Point(slabStartPoint.X + slabWidthLeft + slabWidthCenter + slabWidthRight, slabStartPoint.Y, slabStartPoint.Z);


            contourPlate.AddContourPoint(new ContourPoint(point1, null));
            contourPlate.AddContourPoint(new ContourPoint(point2, null));
            contourPlate.AddContourPoint(new ContourPoint(point3, null));
            contourPlate.AddContourPoint(new ContourPoint(point4, null));
            contourPlate.AddContourPoint(new ContourPoint(point5, null));
            contourPlate.AddContourPoint(new ContourPoint(point6, null));
            contourPlate.AddContourPoint(new ContourPoint(point7, null));
            contourPlate.AddContourPoint(new ContourPoint(point8, null));
            contourPlate.AddContourPoint(new ContourPoint(point9, null));
            contourPlate.AddContourPoint(new ContourPoint(point10, null));
            contourPlate.AddContourPoint(new ContourPoint(point11, null));
            contourPlate.AddContourPoint(new ContourPoint(point12, null));

            contourPlate.Profile.ProfileString   = "2000";
            contourPlate.Material.MaterialString = "C24";

            bool result = false;

            result = contourPlate.Insert();
            currentModel.CommitChanges();

            //모델의 좌표계를 재로드
            workPlaneHandler.SetCurrentTransformationPlane(originPlane);
        }