/// <summary>
        ///
        /// </summary>
        public override void Insert()
        {
            component.Number = -100000;
            component.Name   = this.name;
            component.LoadAttributesFromFile(this.attributeFile);

            ComponentInput I = new ComponentInput();

            I.AddOneInputPosition(startPoint);
            I.AddOneInputPosition(endPoint);

            component.SetComponentInput(I);

            component.Insert();
            this.ID = component.Identifier.ID;
        }
            private static bool exportIFC(string outputFileName)
            {
                ComponentInput ComponentInput = new ComponentInput();
                ComponentInput.AddOneInputPosition(new Point(0, 0, 0));
                Component Comp = new Component(ComponentInput);
                Comp.Name = "ExportIFC";
                Comp.Number = BaseComponent.PLUGIN_OBJECT_NUMBER;

                // Parameters
                Comp.SetAttribute("OutputFile", outputFileName);
                Comp.SetAttribute("Format", 0);
                Comp.SetAttribute("ExportType", 1);
                Comp.SetAttribute("AdditionalPSets", "BMcDIFCConfig");
                Comp.SetAttribute("CreateAll", 0);  // 0 to export only selected objects

                // Advanced
                Comp.SetAttribute("Assemblies", 1);
                Comp.SetAttribute("Bolts", 1);
                Comp.SetAttribute("Welds", 0);
                Comp.SetAttribute("SurfaceTreatments", 1);

                Comp.SetAttribute("BaseQuantities", 1);
                Comp.SetAttribute("GridExport", 1);
                Comp.SetAttribute("ReinforcingBars", 1);
                Comp.SetAttribute("PourObjects", 1);

                Comp.SetAttribute("LayersNameAsPart", 1);
                Comp.SetAttribute("PLprofileToPlate", 0);
                Comp.SetAttribute("ExcludeSnglPrtAsmb", 0);

                //Comp.SetAttribute("LocsFromOrganizer", 0); // dafuq

                return Comp.Insert();
            }
Esempio n. 3
0
        /// <summary>
        /// Modifies the input.
        /// </summary>
        /// <param name="points">The points.</param>
        private void ModifyInput(List <Point> points)
        {
            this.Graphics.Clear();
            var originalInput = this.Component.GetComponentInput();

            if (originalInput == null)
            {
                return;
            }

            var input = new ComponentInput();
            var index = 0;

            foreach (var inputItem in originalInput)
            {
                if (!(inputItem is InputItem item))
                {
                    continue;
                }

                switch (item.GetInputType())
                {
                case InputItem.InputTypeEnum.INPUT_1_OBJECT:
                    input.AddInputObject(item.GetData() as ModelObject);
                    break;

                case InputItem.InputTypeEnum.INPUT_N_OBJECTS:
                    input.AddInputObjects(item.GetData() as ArrayList);
                    break;

                case InputItem.InputTypeEnum.INPUT_1_POINT:
                    input.AddOneInputPosition(points[index]);
                    index++;
                    break;

                case InputItem.InputTypeEnum.INPUT_2_POINTS:
                    input.AddTwoInputPositions(points[index], points[index + 1]);
                    index += 2;
                    break;

                case InputItem.InputTypeEnum.INPUT_POLYGON:
                    var polygon = new Polygon();
                    foreach (var point in points)
                    {
                        polygon.Points.Add(new Point(point));
                    }

                    input.AddInputPolygon(polygon);
                    break;

                default:
                    break;
                }
            }

            this.ModifyComponentInput(input);
        }
Esempio n. 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            // Model mod = new Model();
            string[] Phases = new string[] { "IFC_10", "IFC_20", "IFC_30", "IFC_31", "IFC_32", "IFC_40", "IFC_41", "IFC_50", "IFC_60", "IFC_70", "IFC_80", "IFC_90" };


            foreach (string phase in Phases)
            {
                ComponentInput ComponentInput = new ComponentInput();
                ComponentInput.AddOneInputPosition(new Point(0, 0, 0));
                var exportPlugin = new Tekla.Structures.Model.Component(ComponentInput)
                {
                    Name   = "ExportIFC",
                    Number = BaseComponent.PLUGIN_OBJECT_NUMBER
                };
                exportPlugin.LoadAttributesFromFile("standard");
                exportPlugin.SetAttribute("OutputFile", phase);
                exportPlugin.Insert();
            }
        }
            private static bool exportIFC(string outputFileName)
            {
                ComponentInput ComponentInput = new ComponentInput();

                ComponentInput.AddOneInputPosition(new Point(0, 0, 0));
                Component Comp = new Component(ComponentInput);

                Comp.Name   = "ExportIFC";
                Comp.Number = BaseComponent.PLUGIN_OBJECT_NUMBER;

                // Parameters
                Comp.SetAttribute("OutputFile", outputFileName);
                Comp.SetAttribute("Format", 0);
                Comp.SetAttribute("ExportType", 1);
                Comp.SetAttribute("AdditionalPSets", "BMcDIFCConfig");
                Comp.SetAttribute("CreateAll", 0);  // 0 to export only selected objects

                // Advanced
                Comp.SetAttribute("Assemblies", 1);
                Comp.SetAttribute("Bolts", 1);
                Comp.SetAttribute("Welds", 0);
                Comp.SetAttribute("SurfaceTreatments", 1);

                Comp.SetAttribute("BaseQuantities", 1);
                Comp.SetAttribute("GridExport", 1);
                Comp.SetAttribute("ReinforcingBars", 1);
                Comp.SetAttribute("PourObjects", 1);

                Comp.SetAttribute("LayersNameAsPart", 1);
                Comp.SetAttribute("PLprofileToPlate", 0);
                Comp.SetAttribute("ExcludeSnglPrtAsmb", 0);

                //Comp.SetAttribute("LocsFromOrganizer", 0); // dafuq


                return(Comp.Insert());
            }
Esempio n. 6
0
        public static void ExportIFC(string outputFileName)
        {
            var componentInput = new ComponentInput();

            componentInput.AddOneInputPosition(new Point(0, 0, 0));
            var comp = new Component(componentInput)
            {
                Name   = "ExportIFC",
                Number = BaseComponent.PLUGIN_OBJECT_NUMBER
            };

            // Parameters
            comp.SetAttribute("OutputFile", outputFileName);
            comp.SetAttribute("Format", 0);
            comp.SetAttribute("ExportType", 1);
            //comp.SetAttribute("AdditionalPSets", "");
            comp.SetAttribute("CreateAll", 0);  // 0 to export only selected objects

            // Advanced
            comp.SetAttribute("Assemblies", 1);
            comp.SetAttribute("Bolts", 1);
            comp.SetAttribute("Welds", 0);
            comp.SetAttribute("SurfaceTreatments", 1);

            comp.SetAttribute("BaseQuantities", 1);
            comp.SetAttribute("GridExport", 1);
            comp.SetAttribute("ReinforcingBars", 1);
            comp.SetAttribute("PourObjects", 1);

            comp.SetAttribute("LayersNameAsPart", 1);
            comp.SetAttribute("PLprofileToPlate", 0);
            comp.SetAttribute("ExcludeSnglPrtAsmb", 0);

            comp.SetAttribute("LocsFromOrganizer", 0);

            comp.Insert();
        }
Esempio n. 7
0
        private void InsertComponents(ModelObject mObj, List <TSM.Component> components)
        {
            TransformationPlane originalTransformationplane = null;
            WorkPlaneHandler    wHandler = null;

            try {
                wHandler = model.GetWorkPlaneHandler();
                originalTransformationplane = wHandler.GetCurrentTransformationPlane();
                ComponentInput compInput  = new ComponentInput();
                Part           fatherpart = mObj as Part;
                Assembly       assembly   = fatherpart.GetAssembly();

                // Get the transformationplane from objects coordinate systems vectors and because objects coordinate system is not the same XY plane as of models,
                // so cross product needs to be made for the Y-axis
                TransformationPlane fatherpartsTransformationPlane = new TransformationPlane(fatherpart.GetCoordinateSystem().Origin, fatherpart.GetCoordinateSystem().AxisX, Vector.Cross(fatherpart.GetCoordinateSystem().AxisY, fatherpart.GetCoordinateSystem().AxisX));
                lock (wHandler) {
                    wHandler.SetCurrentTransformationPlane(fatherpartsTransformationPlane);
                }
                double minX            = fatherpart.GetSolid().MinimumPoint.X;
                double minY            = fatherpart.GetSolid().MinimumPoint.Y;
                double minZ            = fatherpart.GetSolid().MinimumPoint.Z;
                double maxX            = fatherpart.GetSolid().MaximumPoint.X;
                double maxY            = fatherpart.GetSolid().MaximumPoint.Y;
                double maxZ            = fatherpart.GetSolid().MaximumPoint.Z;
                bool   changeDirection = false;

                if (data.Direction == "y-")
                {
                    double temp = maxY;
                    maxY            = minY;
                    minY            = temp;
                    changeDirection = true;
                }

                Solid          s     = fatherpart.GetSolid();
                FaceEnumerator fEnum = s.GetFaceEnumerator();
                StringBuilder  sb    = new StringBuilder();
                while (fEnum.MoveNext())
                {
                }
                Point        p1            = null;
                Point        p2            = null;
                List <Point> cutPartPoints = new List <Point>()
                {
                    new Point(),
                    new Point(),
                    new Point(),
                    new Point()
                };
                ContourPlate cutpart = null;

                for (int i = 0; i < components.Count; i++)
                {
                    cutpart                         = new ContourPlate();
                    cutpart.Name                    = "Leikkaus";
                    cutpart.Position.Depth          = Position.DepthEnum.MIDDLE;
                    cutpart.Position.Plane          = Position.PlaneEnum.MIDDLE;
                    cutpart.Class                   = BooleanPart.BooleanOperativeClassName;
                    cutpart.Material.MaterialString = "Reikä";
                    cutpart.Profile.ProfileString   = "PL135";
                    BooleanPart bPart = new BooleanPart();
                    compInput = new ComponentInput();
                    double[] variables;
                    switch (i)
                    {
                    case 0:
                        p1        = new Point(maxX - data.LeftShoeDist, 0, minZ);
                        p2        = new Point(maxX - data.LeftShoeDist, maxY, minZ);
                        variables = WallShoeUtils.GetComponentVariables(components[i]);
                        if (variables[0] != 0)
                        {
                            AddWallShoeCut(variables, p1, minY, maxY, changeDirection, fatherpart);
                        }
                        break;

                    case 1:
                        p1        = new Point(minX + data.RightShoeDist, 0, minZ);
                        p2        = new Point(minX + data.RightShoeDist, maxY, minZ);
                        variables = WallShoeUtils.GetComponentVariables(components[i]);
                        if (variables[0] != 0)
                        {
                            AddWallShoeCut(variables, p1, minY, maxY, changeDirection, fatherpart);
                        }
                        break;

                    case 2:
                        p1 = new Point(maxX - data.LeftBoltDist, 0, maxZ + data.LeftBoltOffset);
                        p2 = new Point(maxX - data.LeftBoltDist, maxY, maxZ + data.LeftBoltOffset);
                        break;

                    case 3:
                        p1 = new Point(minX + data.RightBoltDist, 0, maxZ + data.RightBoltOffset);
                        sb.AppendLine(data.RightBoltDist + " " + data.RightBoltOffset);
                        p2 = new Point(minX + data.RightBoltDist, maxY, maxZ + data.RightBoltOffset);
                        break;
                    }
                    compInput.AddOneInputPosition(p1);
                    compInput.AddOneInputPosition(p2);
                    components[i].SetComponentInput(compInput);
                    if (!components[i].Insert())
                    {
                        TSM.Operations.Operation.DisplayPrompt("Komponentin " + i + " asettaminen epäonnistui!");
                        WriteLog("Komponentin " + i + " asettaminen epäonnistui!");
                    }
                }
                foreach (TSM.Component c in components)
                {
                    assembly.Add(c);
                    assembly.Modify();
                }
            } catch (Exception ex) {
                WriteLog(ex.Message + "\n" + ex.StackTrace);
            } finally {
                lock (wHandler) {
                    wHandler.SetCurrentTransformationPlane(originalTransformationplane);
                }
            }
        }
Esempio n. 8
0
        private void InsertComponents(ModelObject mObj, List <TSM.Component> components)
        {
            TransformationPlane originalTransformationplane = null;

            try {
                lock (wHandler) {
                    originalTransformationplane = wHandler.GetCurrentTransformationPlane();
                }
                ComponentInput compInput  = new ComponentInput();
                Part           fatherpart = mObj as Part;
                Assembly       assembly   = fatherpart.GetAssembly();

                // Get the transformationplane from objects coordinate systems vectors and because objects coordinate system is not the same XY plane as of models,
                // so cross product needs to be made for the Y-axis
                TransformationPlane fatherpartsTransformationPlane = new TransformationPlane(fatherpart.GetCoordinateSystem().Origin, fatherpart.GetCoordinateSystem().AxisX, Vector.Cross(fatherpart.GetCoordinateSystem().AxisY, fatherpart.GetCoordinateSystem().AxisX));
                lock (wHandler) {
                    wHandler.SetCurrentTransformationPlane(fatherpartsTransformationPlane);
                }
                double         minX  = fatherpart.GetSolid().MinimumPoint.X;
                double         minY  = fatherpart.GetSolid().MinimumPoint.Y;
                double         minZ  = fatherpart.GetSolid().MinimumPoint.Z;
                double         maxX  = fatherpart.GetSolid().MaximumPoint.X;
                double         maxY  = fatherpart.GetSolid().MaximumPoint.Y;
                double         maxZ  = fatherpart.GetSolid().MaximumPoint.Z;
                Solid          s     = fatherpart.GetSolid();
                FaceEnumerator fEnum = s.GetFaceEnumerator();
                StringBuilder  sb    = new StringBuilder();
                while (fEnum.MoveNext())
                {
                    sb.AppendLine(fEnum.Current.Normal.ToString());
                }
                Point        p1            = null;
                Point        p2            = null;
                List <Point> cutPartPoints = new List <Point>()
                {
                    new Point(),
                    new Point(),
                    new Point(),
                    new Point()
                };
                ContourPlate cutpart = null;

                for (int i = 0; i < components.Count; i++)
                {
                    cutpart                         = new ContourPlate();
                    cutpart.Name                    = "Leikkaus";
                    cutpart.Position.Depth          = Position.DepthEnum.MIDDLE;
                    cutpart.Position.Plane          = Position.PlaneEnum.MIDDLE;
                    cutpart.Class                   = BooleanPart.BooleanOperativeClassName;
                    cutpart.Material.MaterialString = "Reikä";
                    cutpart.Profile.ProfileString   = "PL135";
                    BooleanPart bPart = new BooleanPart();
                    compInput = new ComponentInput();
                    switch (i)
                    {
                    case 0:
                        p1 = new Point(minX + 300, 0, minZ);
                        p2 = new Point(minX + 300, maxY, minZ);
                        cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, p1.Y - 52, p1.Z + 40), null));
                        cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, p1.Y - 52, p1.Z + 161.68), null));
                        cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, maxY, p1.Z + 161.68 + (Math.Tan(9.88 * Math.PI / 180) * ((maxY - minY) / 2 + 52))), null));
                        cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, maxY, p1.Z + 40), null));
                        cutpart.Insert();
                        bPart.Father = fatherpart;
                        bPart.SetOperativePart(cutpart);
                        if (!bPart.Insert())
                        {
                            SetInfoText("Leikkauksen (1) tekeminen epäonnistui!");
                        }
                        cutpart.Delete();
                        break;

                    case 1:
                        p1 = new Point(maxX - 300, 0, minZ);
                        p2 = new Point(maxX - 300, maxY, minZ);
                        cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, p1.Y - 52, p1.Z + 40), null));
                        cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, p1.Y - 52, p1.Z + 161.68), null));
                        cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, maxY, p1.Z + 161.68 + (Math.Tan(9.88 * Math.PI / 180) * ((maxY - minY) / 2 + 52))), null));
                        cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, maxY, p1.Z + 40), null));
                        cutpart.Insert();
                        bPart.Father = fatherpart;
                        bPart.SetOperativePart(cutpart);
                        if (!bPart.Insert())
                        {
                            SetInfoText("Leikkauksen (2) tekeminen epäonnistui!");
                        }
                        cutpart.Delete();
                        break;

                    case 2:
                        p1 = new Point(minX + 300, 0, maxZ + 135);
                        p2 = new Point(minX + 300, maxY, maxZ + 135);
                        break;

                    case 3:
                        p1 = new Point(maxX - 300, 0, maxZ + 135);
                        p2 = new Point(maxX - 300, maxY, maxZ + 135);
                        break;
                    }
                    compInput.AddOneInputPosition(p1);
                    compInput.AddOneInputPosition(p2);
                    components[i].SetComponentInput(compInput);
                    if (!components[i].Insert())
                    {
                        SetInfoText("Komponentin laittaminen epäonnistui!");
                    }
                }
                foreach (TSM.Component c in components)
                {
                    assembly.Add(c);
                    assembly.Modify();
                }
            } catch (Exception ex) {
                ExceptionOccured(ex.Message, ex.StackTrace);
                SetInfoText("Komponentin asettamisessa tapahtui virhe!");
            } finally {
                lock (wHandler) {
                    wHandler.SetCurrentTransformationPlane(originalTransformationplane);
                }
            }
        }