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();
                }
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        private void PasteToTarget(Assembly targetAssembly)
        {
            _targetCoordsys = targetAssembly.GetMainPart().GetCoordinateSystem();

            if (_sourceModelObject is Assembly)
            {
                if (!_childrenOnly)
                {
                    CopyAssembly(_sourceModelObject as Assembly, targetAssembly);
                }
                else
                {
                    ArrayList subAssemblies = (_sourceModelObject as Assembly).GetSubAssemblies();

                    foreach (Assembly subAssembly in subAssemblies)
                    {
                        CopyAssembly(subAssembly, targetAssembly);
                    }

                    CopyChildren(_sourceModelObject as Assembly, targetAssembly);
                }
            }
            else
            {
                ModelObject resultObject = CopyObject(_sourceModelObject);

                if (resultObject is IAssemblable)
                {
                    targetAssembly.Add(resultObject as IAssemblable);
                    targetAssembly.Modify();
                }
            }
        }
Esempio n. 4
0
 private static void GetCoordinateSystemAndNameOfSelectedObject(TSM.ModelObjectEnumerator SelectedModelObjects, out TSG.CoordinateSystem ModelObjectCoordSys, out string ModelObjectName)
 {
     if (SelectedModelObjects.Current is TSM.Part)
     {
         ModelObjectCoordSys = (SelectedModelObjects.Current as TSM.Part).GetCoordinateSystem();
         ModelObjectName     = (SelectedModelObjects.Current as TSM.Part).GetPartMark();
     }
     else if (SelectedModelObjects.Current is TSM.Assembly)
     {
         ModelObjectCoordSys = (SelectedModelObjects.Current as TSM.Assembly).GetCoordinateSystem();
         ModelObjectName     = (SelectedModelObjects.Current as TSM.Assembly).AssemblyNumber.Prefix + (SelectedModelObjects.Current as TSM.Assembly).AssemblyNumber.StartNumber;
     }
     else if (SelectedModelObjects.Current is TSM.BaseComponent)
     {
         ModelObjectCoordSys = (SelectedModelObjects.Current as TSM.BaseComponent).GetCoordinateSystem();
         ModelObjectName     = (SelectedModelObjects.Current as TSM.BaseComponent).Name;
     }
     else if (SelectedModelObjects.Current is TSM.Task)
     {
         ModelObjectCoordSys = new TSG.CoordinateSystem();
         ModelObjectName     = (SelectedModelObjects.Current as TSM.Task).Name;
     }
     else
     {
         ModelObjectCoordSys = new TSG.CoordinateSystem();
         ModelObjectName     = string.Empty;
     }
 }
        public void CK06_ByPickPart()
        {
            ModelObject PickedObject = null;
            Picker      Picker       = new Picker();

            try
            {
                PickedObject = Picker.PickObject(Picker.PickObjectEnum.PICK_ONE_OBJECT);
            }
            catch { PickedObject = null; }

            if (PickedObject != null)
            {
                T3D.CoordinateSystem ObjectSystem = PickedObject.GetCoordinateSystem();
                Model.GetWorkPlaneHandler()
                .SetCurrentTransformationPlane(new TransformationPlane(ObjectSystem));

                double StartX = 500;
                for (int i = 0; i < 7; i++)
                {
                    T3D.Point p1 = new T3D.Point(StartX, 0);
                    T3D.Point p2 = new T3D.Point(StartX, 0, 1000);
                    CreateBeam("test Beam", "I30B1_20_93", p1, p2);
                    StartX += 500;
                }
                ViewHandler.SetRepresentation("standard"); //PKh> should be add for Tekla-2018
                Model.CommitChanges();
            }
            mw.Msg("Изображение ПСК теперь на стартовой точке - на желтой ручке балки:"
                   + " Х по опорной линии, Y вверх. Перпендикулярно балке создано"
                   + " 7 дополнительных отрезков другого цвета.  [OK]");
            MessageBox.Show("вывел ПСК и 7 перпендикулярных дополнительных балок");
            mw.Msg();
        }
Esempio n. 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!validarMuroSeleccionado())
            {
                return;
            }

            model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane());
            TransformationPlane currentTP = model.GetWorkPlaneHandler().GetCurrentTransformationPlane();

            T3D.CoordinateSystem coordenadasMuro = muro.GetCoordinateSystem();
            model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane(coordenadasMuro));

            ParametrosPanel p = new ParametrosPanel(muro);

            p.dx = Double.Parse(this.txtDx.Text);
            p.dy = Double.Parse(this.txtDz.Text);
            p.adicionalDerecha   = Double.Parse(this.txtAddDer.Text);
            p.adicionalIzquierda = Double.Parse(this.txtAdIzq.Text);
            p.adicionalSuperior  = Double.Parse(this.txtAdicionalSup.Text);
            p.adicionalInferior  = Double.Parse(this.txtAdicionalInf.Text);
            p.diametroBarras     = 7.0;
            p.diametroDiagonal   = 4.0;

            PanelMoldar panel = new PanelMoldar(p);

            panel.fabricar();

            model.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentTP);
            model.CommitChanges();
        }
Esempio n. 7
0
        private void AddView(string Name, TSD.Drawing MyDrawing, ArrayList Parts, TSG.CoordinateSystem coordinateSystem)
        {
            TSD.View MyView = new TSD.View(MyDrawing.GetSheet(), coordinateSystem, coordinateSystem, Parts);

            MyView.Name = Name;
            MyView.Insert();
        }
Esempio n. 8
0
        private static bool isView2D(TSD.View currentView)
        {
            T3D.CoordinateSystem disp  = currentView.DisplayCoordinateSystem as T3D.CoordinateSystem;
            T3D.CoordinateSystem viewp = currentView.ViewCoordinateSystem as T3D.CoordinateSystem;

            if (disp.AxisX.Z != viewp.AxisX.Z || disp.AxisY.Z != viewp.AxisY.Z)
            {
                return(false);
            }

            return(true);
        }
        public void CK07_Column()
        {
            // Create Column after Pick a Point of this column
            T3D.Point FirstPoint = null;
            Picker    Picker     = new Picker();

            try
            {
                ArrayList PickedPoints = Picker.PickPoints(Picker.PickPointEnum.PICK_ONE_POINT);
                FirstPoint = PickedPoints[0] as T3D.Point;
            }
            catch { FirstPoint = null; }
            if (FirstPoint != null)
            {
                T3D.Point SecondPoint = new T3D.Point(FirstPoint.X, FirstPoint.Y, FirstPoint.Z + 8000);
                Beam      ThisBeam    = CreateBeam("MyColumn", mw.prfStr, FirstPoint, SecondPoint);
                ThisBeam.Finish = "D";
                ThisBeam.Class  = "7";
                ThisBeam.AssemblyNumber.Prefix      = "C";
                ThisBeam.AssemblyNumber.StartNumber = 1;
                ThisBeam.Position.Depth             = Position.DepthEnum.MIDDLE;
                ThisBeam.Position.Plane             = Position.PlaneEnum.MIDDLE;
                ThisBeam.Position.Rotation          = Position.RotationEnum.TOP;
                ThisBeam.Modify();
                //ThisBeam.SetUserProperty("USER_FIELD_1", "PEOPLE");
                //string UserField = "";
                //ThisBeam.GetUserProperty("USER_FIELD_1", ref UserField);
                //Solid BeamSolid = ThisBeam.GetSolid();
                T3D.CoordinateSystem  BeamCoordinateSystem = ThisBeam.GetCoordinateSystem();
                Assembly              BeamAssembly         = ThisBeam.GetAssembly();
                ModelObjectEnumerator BeamsBolt            = ThisBeam.GetBolts();
                ReperShow(BeamCoordinateSystem);
                Model.CommitChanges();

                Matrix         FromColumnSystem = MatrixFactory.FromCoordinateSystem(ThisBeam.GetCoordinateSystem());
                T3D.Point      FrontFacePoint   = FromColumnSystem.Transform(new T3D.Point(50, 50, 500));
                GraphicsDrawer Drawer           = new GraphicsDrawer();
                // Label for Front Face
                var label = new Color(0, 0, 0);
                Drawer.DrawLineSegment(new LineSegment(FirstPoint, FrontFacePoint), label);
                Drawer.DrawText(FrontFacePoint, "THIS IS FRONT FACE", label);

                mw.Msg("В выбранной точке создается колонна с осью Х ПСК, направленой вверх."
                       + " Профиль колонны как в поле TextBox выше. Черная надпись показывает"
                       + "  переднюю грань.      [ОК]");
                MessageBox.Show("Создал колонну и вывел репер, указал переднюю грань");
                mw.Msg();
            }
        }
Esempio n. 10
0
        private void AddRotatedView(string Name, TSD.Drawing MyDraiwng, ArrayList Parts, TSG.CoordinateSystem coordinateSystem)
        {
            TSG.CoordinateSystem displayCoordinateSystem = new TSG.CoordinateSystem();

            TSG.Matrix RotationAroundX = TSG.MatrixFactory.Rotate(20.0 * Math.PI * 2.0 / 360.0, coordinateSystem.AxisX);
            TSG.Matrix RotationAroundZ = TSG.MatrixFactory.Rotate(30.0 * Math.PI * 2.0 / 360.0, coordinateSystem.AxisY);

            TSG.Matrix Rotation = RotationAroundX * RotationAroundZ;

            displayCoordinateSystem.AxisX = new TSG.Vector(Rotation.Transform(new TSG.Point(coordinateSystem.AxisX)));
            displayCoordinateSystem.AxisY = new TSG.Vector(Rotation.Transform(new TSG.Point(coordinateSystem.AxisY)));

            TSD.View FrontView = new TSD.View(MyDraiwng.GetSheet(), coordinateSystem, displayCoordinateSystem, Parts);

            FrontView.Name = Name;
            FrontView.Insert();
        }
Esempio n. 11
0
 private void CreateViews(TSG.CoordinateSystem ModelObjectCoordSys, string ModelObjectName, TSD.GADrawing MyDrawing, ArrayList Parts)
 {
     if (createFrontView.Checked)
     {
         AddView("Front view of " + ModelObjectName, MyDrawing, Parts, GetBasicViewsCoordinateSystemForFrontView(ModelObjectCoordSys));
     }
     if (createTopView.Checked)
     {
         AddView("Top view of " + ModelObjectName, MyDrawing, Parts, GetBasicViewsCoordinateSystemForTopView(ModelObjectCoordSys));
     }
     if (createEndView.Checked)
     {
         AddView("End view of " + ModelObjectName, MyDrawing, Parts, GetBasicViewsCoordinateSystemForEndView(ModelObjectCoordSys));
     }
     if (create3dView.Checked)
     {
         AddRotatedView("3d view of " + ModelObjectName, MyDrawing, Parts, GetBasicViewsCoordinateSystemForFrontView(ModelObjectCoordSys));
     }
 }
Esempio n. 12
0
        private TSG.CoordinateSystem GetBasicViewsCoordinateSystemForTopView(TSG.CoordinateSystem objectCoordinateSystem)
        {
            TSG.CoordinateSystem result = new TSG.CoordinateSystem()
            {
                Origin = new TSG.Point(objectCoordinateSystem.Origin),
                AxisX  = new TSG.Vector(objectCoordinateSystem.AxisX) * -1.0,
                AxisY  = new TSG.Vector(objectCoordinateSystem.AxisY)
            };

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

            result.AxisX = tempVector.Cross(UpDirection).GetNormal();
            result.AxisY = UpDirection.GetNormal();

            return(result);
        }
Esempio n. 13
0
        public void AddObjectToClipBoard(Identifier selectedID)
        {
            _sourceModelObject = _tsModel.SelectModelObject(selectedID);
            Assembly fatherAssembly = null;

            if (_sourceModelObject is IAssemblable)
            {
                fatherAssembly  = (_sourceModelObject as IAssemblable).GetAssembly();
                _sourceCoordsys = fatherAssembly.GetMainPart().GetCoordinateSystem();
            }
            else if (_sourceModelObject is Assembly)
            {
                fatherAssembly  = _sourceModelObject as Assembly;
                _sourceCoordsys = fatherAssembly.GetAssembly().GetMainPart().GetCoordinateSystem();
            }
            else if (_sourceModelObject is Reinforcement)
            {
                fatherAssembly  = ((_sourceModelObject as Reinforcement).Father as Part).GetAssembly();
                _sourceCoordsys = fatherAssembly.GetMainPart().GetCoordinateSystem();
            }

            _sourceRootAssembly = GetRootAssembly(fatherAssembly);
        }
Esempio n. 14
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 { }
        }
Esempio n. 15
0
 public void AddChildrenToClipBoard(Identifier selectedID)
 {
     _sourceModelObject = _tsModel.SelectModelObject(selectedID);
     _sourceCoordsys    = _sourceModelObject.GetCoordinateSystem();
     _childrenOnly      = true;
 }
Esempio n. 16
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();
        }
Esempio n. 17
0
 public static void pcor(T3D.CoordinateSystem pc, string txt)
 {
     pvector(pc.AxisX, txt + " Axis X");
     pvector(pc.AxisY, txt + " Axis Y");
     ppoint(pc.Origin, txt + " Origin");
 }
        public void CK07_Beam()
        {
            string prf = mw.prfStr;

            // Create Beam after Pick 2 Points - StartPoint and EndPoint of Beam
            T3D.Point FirstPoint = null, SecondPoint = null;
            Picker    Picker = new Picker();

            try
            {
                ArrayList PickedPoints = Picker.PickPoints(Picker.PickPointEnum.PICK_TWO_POINTS);
                FirstPoint  = PickedPoints[0] as T3D.Point;
                SecondPoint = PickedPoints[1] as T3D.Point;
            }
            catch { FirstPoint = SecondPoint = null; }
            if (FirstPoint != null && SecondPoint != null)
            {
                Beam ThisBeam = CreateBeam("MyBeam", prf, FirstPoint, SecondPoint);
                ThisBeam.Finish = "GALVANIZED";
                ThisBeam.Class  = "4";
                ThisBeam.AssemblyNumber.Prefix      = "B";
                ThisBeam.AssemblyNumber.StartNumber = 1;
                ThisBeam.Position.Depth             = Position.DepthEnum.BEHIND;
                ThisBeam.Position.Plane             = Position.PlaneEnum.MIDDLE;
                ThisBeam.Position.Rotation          = Position.RotationEnum.TOP;
                ThisBeam.Modify();
                ThisBeam.SetUserProperty("USER_FIELD_1", "PEOPLE");
                string UserField = "";
                ThisBeam.GetUserProperty("USER_FIELD_1", ref UserField);
                Solid BeamSolid = ThisBeam.GetSolid();
                T3D.CoordinateSystem  BeamCoordinateSystem = ThisBeam.GetCoordinateSystem();
                Assembly              BeamAssembly         = ThisBeam.GetAssembly();
                ModelObjectEnumerator BeamsBolt            = ThisBeam.GetBolts();
                ReperShow(BeamCoordinateSystem);
                Model.CommitChanges();
                mw.Msg("Балка и репер выводится в точке 1 с осью Х по направлению к фиолетовой точке"
                       + " (ручке конца балки) - точке 2. Профиль как в поле TextBox выше.      [ОК]");
                MessageBox.Show("Создал балку по 2 точкам и вывел репер");
                mw.Msg();

                string ReportProfile = "—200*20";
                ThisBeam.Class = "2";
                ThisBeam.Profile.ProfileString = ReportProfile;
                ThisBeam.Modify();
                double Height = 0;
                ThisBeam.GetReportProperty("HEIGHT", ref Height);

                ThisBeam.GetReportProperty("PROFILE", ref ReportProfile);
                Model.CommitChanges();
                mw.Msg("Профиль балки изменяется на красную пластину -200x20  [OK]");
                MessageBox.Show("Beam Modified - PL");

                ThisBeam.Delete();
                Model.CommitChanges();
                mw.Msg("После всех предыдущих манипуляций, балка стерта.  [ОК]");
                MessageBox.Show("Beam DELETED");
                mw.Msg();
            }
            Model.GetWorkPlaneHandler()
            .SetCurrentTransformationPlane(new TransformationPlane());
            ViewHandler.SetRepresentation("standard"); //PKh> should be add for Tekla-2018
            Model.CommitChanges();
        }
Esempio n. 19
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
            {
            }
        }