Пример #1
0
        public static void Run(Tekla.Technology.Akit.IScript akit)
        {
            MyModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane());
            Tekla.Structures.Model.UI.ModelObjectSelector MS = new Tekla.Structures.Model.UI.ModelObjectSelector();
            ModelObjectEnumerator Menum          = MS.GetSelectedObjects();
            List <Beam>           AllPartList    = EnumtoArray(Menum).OfType <Beam>().ToList();
            List <int>            AllPartListIds = AllPartList.Select(x => x.Identifier.ID).ToList();
            List <Beam>           BeamList       = AllPartList.Where(x => x.Name == "BEAM").ToList();

            int ConCount = 0;

            foreach (Beam bem in BeamList)
            {
                bem.Select();
                // Start Side
                Beam StartBeam = GetPrimary(bem, AllPartListIds, "Start");
                if (StartBeam != null && !IsConnectionApplied(bem, StartBeam))
                {
                    //MessageBox.Show(StartBeam.Identifier.ID.ToString());
                    ApplyConn(StartBeam, bem, "Start");
                    ConCount++;
                }

                Beam EndBeam = GetPrimary(bem, AllPartListIds, "End");
                if (EndBeam != null && !IsConnectionApplied(bem, EndBeam))
                {
                    ApplyConn(EndBeam, bem, "End");
                    ConCount++;
                }
            }

            MessageBox.Show("Total Connection Applied : " + ConCount.ToString());
        }
            private static ModelObjectEnumerator getSelectedObjects()
            {
                var selector = new TSM.UI.ModelObjectSelector();
                ModelObjectEnumerator selectionEnum = selector.GetSelectedObjects();

                return(selectionEnum);
            }
        public CurrentSelectedObjects(string channelProfile, string channelClass, Model Model)
        {
            Model ThisModel = Model;

            //User interface for the model
            TSMUI.ModelObjectSelector GetSelectedObjects = new TSMUI.ModelObjectSelector();

            // Model Object Enumerator (from Tekla.Structures.Model namespace) collection of selected objects
            ModelObjectEnumerator SelectedObjects = GetSelectedObjects.GetSelectedObjects();

            // Change channel profile to value passed in constructor
            ChannelProfile = channelProfile;
            // Set class to value passed in constructor
            ChannelClass = channelClass;

            // go through objects in model objects enumerator MoveNext returns false at end of collection
            while (SelectedObjects.MoveNext())
            {
                // cast as beam, model 'object' class is just an abstract class, we must call out beams specifically.
                Beam ThisBeam = SelectedObjects.Current as Beam;
                if (ThisBeam != null)
                {
                    // Pass profile and class for beam from constructor
                    ThisBeam.Profile.ProfileString = ChannelProfile;
                    ThisBeam.Class = ChannelClass;
                    //Apply new start point and end point
                    ThisBeam.StartPoint = new T3D.Point(1000, 0, 0);
                    ThisBeam.EndPoint   = new T3D.Point(4000, 1000, 0);

                    // Method to modify beam and apply changes
                    ThisBeam.Modify();
                }
            }
        }
        public static void Run(Tekla.Technology.Akit.IScript akit)
        {
            try
            {
                Model model = new Model();
                TSMUI.ModelObjectSelector modelObjectSelector = new TSMUI.ModelObjectSelector();
                ModelObjectEnumerator     objectsToCopyEnum   = modelObjectSelector.GetSelectedObjects();

                ArrayList objectsToCopyArray = new ArrayList();

                while (objectsToCopyEnum.MoveNext())
                {
                    objectsToCopyArray.Add(objectsToCopyEnum.Current);
                }

                Beam sourceBeam = PickBeam();

                ArrayList modelObjectSelectorArray = new ArrayList();
                modelObjectSelectorArray.Add(sourceBeam);
                modelObjectSelector.Select(modelObjectSelectorArray);
                modelObjectSelectorArray.Clear();

                CopyToAnotherBeamByEndPoint(objectsToCopyArray, sourceBeam);
            }
            catch { }
        }
Пример #5
0
        private void connectParts()
        {
            List <BoltGroup> boltGroups = new List <BoltGroup>();

            Picker picker = new Picker();

            Tekla.Structures.Model.UI.ModelObjectSelector selector = new Tekla.Structures.Model.UI.ModelObjectSelector();
            ModelObjectEnumerator enumerator = selector.GetSelectedObjects();

            foreach (ModelObject modelObject in enumerator)
            {
                BoltGroup boltGroup = (BoltGroup)modelObject;
                boltGroups.Add(boltGroup);
            }

            foreach (BoltGroup group in boltGroups)
            {
                int partsBoltedBefore;
                int partsBoltedAfter;
                do
                {
                    Solid solid = group.GetSolid();
                    partsBoltedBefore = group.GetOtherPartsToBolt().Count;
                    Double boltLength   = 0.0;
                    Point  maximumPoint = solid.MaximumPoint;
                    Point  minimumPoint = solid.MinimumPoint;
                    Tekla.Structures.Model.ModelObjectSelector groupSelector = model.GetModelObjectSelector();
                    ModelObjectEnumerator collidingObjects = groupSelector.GetObjectsByBoundingBox(minimumPoint, maximumPoint);
                    while (collidingObjects.MoveNext())
                    {
                        Part part = collidingObjects.Current as Part;
                        if (part != null)
                        {
                            group.AddOtherPartToBolt(part);
                        }
                    }
                    group.BoltStandard = "4017-8.8";
                    group.Modify();
                    group.GetReportProperty("LENGTH", ref boltLength);
                    if (group.BoltStandard == "4017-8.8" && boltLength % 10 != 0)
                    {
                        group.BoltStandard = "4014-8.8";
                    }
                    group.Modify();
                    partsBoltedAfter = group.GetOtherPartsToBolt().Count;
                    group.CutLength  = boltLength + 20;
                } while (partsBoltedBefore != partsBoltedAfter);
            }
            model.CommitChanges();
        }
Пример #6
0
        public ThisDataToFile(bool allObjects, Model model)
        {
            this.AllObjects = allObjects;
            this.Model      = model;

            ModelObjectEnumerator ModelObjectsToWriteOut = null;

            if (allObjects)
            {
                // Select all objects in the model that are beams and add to enumeration
                ModelObjectsToWriteOut = model.GetModelObjectSelector().GetAllObjectsWithType(ModelObject.ModelObjectEnum.BEAM);
            }
            else
            {
                // use model object selector to get selected objects
                TSMUI.ModelObjectSelector GetSelectedObjects = new TSMUI.ModelObjectSelector();
                // Get selected objects in model and add to enumeration
                ModelObjectsToWriteOut = GetSelectedObjects.GetSelectedObjects();
            }

            // get file name
            string FileName = "BeamsToTextFile";
            // Write directly into model folder using System.IO namespace.
            string FinalFileName = Path.Combine(model.GetInfo().ModelPath, FileName);

            // use new StreamWriter from System.IO to write new text file in specified location
            using (StreamWriter FileWriter = new StreamWriter(FinalFileName))
            {
                while (ModelObjectsToWriteOut.MoveNext())
                {
                    // Move through beams in collection
                    Beam ThisBeam = ModelObjectsToWriteOut.Current as Beam;
                    if (ThisBeam != null)
                    {
                        string DataLineForFile = "GUID: " + model.GetGUIDByIdentifier(ThisBeam.Identifier) + "," +
                                                 "Profile: " + ThisBeam.Profile.ProfileString + "," +    // Write beam profile
                                                 "Material: " + ThisBeam.Material.MaterialString + "," + // write beam material
                                                 "Class: " + ThisBeam.Class;                             // write beam class

                        FileWriter.WriteLine(DataLineForFile);
                    }
                }
            }

            // Inform user that file has been exported
            MessageBox.Show("File Exported");
            Tekla.Structures.Model.Operations.Operation.DisplayPrompt("File Exported and Written to Model Folder");
        }
 private List<ModelObjectEnumerator> GetObjectsToCheck(bool checkAll)
 {
     Model model = new Model();
     List<ModelObjectEnumerator> list = new List<ModelObjectEnumerator>();
     if (checkAll)
     {
         list.Add(model.GetModelObjectSelector().GetAllObjectsWithType(ModelObject.ModelObjectEnum.BEAM));
         list.Add(model.GetModelObjectSelector().GetAllObjectsWithType(ModelObject.ModelObjectEnum.CONTOURPLATE));
         list.Add(model.GetModelObjectSelector().GetAllObjectsWithType(ModelObject.ModelObjectEnum.POLYBEAM));
     }
     else
     {
         Tekla.Structures.Model.UI.ModelObjectSelector modelObjectSelector = new Tekla.Structures.Model.UI.ModelObjectSelector();
         ModelObjectEnumerator selectedObjects = modelObjectSelector.GetSelectedObjects();
         list.Add(selectedObjects);
     }
     return list;
 }
        private void Button_ModifySelected_Click(object sender, RoutedEventArgs e)
        {
            TSMUI.ModelObjectSelector GetSelectedObjects = new TSMUI.ModelObjectSelector();
            ModelObjectEnumerator     SelectedObjects    = GetSelectedObjects.GetSelectedObjects();

            while (SelectedObjects.MoveNext())
            {
                Beam ThisBeam = SelectedObjects.Current as Beam;
                if (ThisBeam != null)
                {
                    ThisBeam.Profile.ProfileString = "I20_8239_89";
                    ThisBeam.Class      = "6";
                    ThisBeam.StartPoint = new T3D.Point(0, 1000, 0);
                    ThisBeam.EndPoint   = new T3D.Point(4000, 1000, 0);
                    ThisBeam.Modify();
                }
            }
            Model.CommitChanges();
        }
Пример #9
0
 private void getEnumerator()
 {
     modelObjectEnumerator = selector.GetSelectedObjects();
     if (modelObjectEnumerator.GetSize() > 0)
     {
         return;
     }
     else
     {
         try
         {
             modelObjectEnumerator = picker.PickObjects(Picker.PickObjectsEnum.PICK_N_REINFORCEMENTS);
         }
         catch (Exception)
         {
             MessageBox.Show("No rebars selected");
             return;
         }
     }
 }
Пример #10
0
        public Dictionary <string, Assembly> GetAssemblysFromParts()
        {
            /// <summary>
            ///  Returns assemblies from parts that have been pre-selected in the model.
            /// </summary>
            //1.)make object selector Class:
            Tekla.Structures.Model.UI.ModelObjectSelector selectedObjectsSelector = new Tekla.Structures.Model.UI.ModelObjectSelector();
            //2.)copy selected Object Enumeration to ModelObjectEnumerator:
            ModelObjectEnumerator selectedParts = selectedObjectsSelector.GetSelectedObjects();
            //3.)get all selected single Parts:
            List <Part> parts = new List <Part>();

            while (selectedParts.MoveNext())
            {
                Part ThisAssembly = selectedParts.Current as Part;
                if (ThisAssembly != null)
                {
                    parts.Add(ThisAssembly);
                }
            }
            //4.)make a dictinary with all assemblies from the single parts key= AssemblyPos Nr.
            //   delete duplicates by try-catch:
            Dictionary <string, Assembly> assemblies = new Dictionary <string, Assembly>();

            foreach (var p in parts)
            {
                string s = "";
                p.GetAssembly().GetReportProperty("ASSEMBLY_POS", ref s);
                try
                {
                    assemblies.Add(s, p.GetAssembly());
                }
                catch
                {
                }
            }
            return(assemblies);
        }
Пример #11
0
        private void WriteDataFile(bool AllObjects)
        {
            ModelObjectEnumerator ModelObjectsToWriteOut = null;

            if (AllObjects)
            {
                ModelObjectsToWriteOut = Model.GetModelObjectSelector().GetAllObjectsWithType(ModelObject.ModelObjectEnum.BEAM);
            }
            else
            {
                TSMUI.ModelObjectSelector GetSelectedObjects = new TSMUI.ModelObjectSelector();
                ModelObjectsToWriteOut = GetSelectedObjects.GetSelectedObjects();
            }

            string FileName      = "BeamToTextFile.txt";
            string FinalFileName = System.IO.Path.Combine(Model.GetInfo().ModelPath, FileName);

            using (StreamWriter FileWriter = new StreamWriter(FinalFileName))
            {
                while (ModelObjectsToWriteOut.MoveNext())
                {
                    Beam ThisBeam = ModelObjectsToWriteOut.Current as Beam;
                    if (ThisBeam != null)
                    {
                        string DataLineForFile = Model.GetGUIDByIdentifier(ThisBeam.Identifier) + ", "
                                                 + ThisBeam.Profile.ProfileString + ", "
                                                 + ThisBeam.Material.MaterialString + ", "
                                                 + ThisBeam.Class;
                        FileWriter.WriteLine(DataLineForFile);
                    }
                }
            }

            MessageBox.Show("File Exported");
            Tekla.Structures.Model.Operations.Operation.DisplayPrompt("File Exported and written to Model Folder");
        }
Пример #12
0
        private void GetSelected()
        {
            if (!checkBoxLockTrees.Checked)
            {
                treeView1.Nodes.Clear();
                treeView2.Nodes.Clear();
                HideTree2();
                toolStripButtonCure.Visible = false;

                int index = 0;
                UI.ModelObjectSelector selector     = new UI.ModelObjectSelector();
                ModelObjectEnumerator  selectedEnum = selector.GetSelectedObjects();

                while (index < 2 && selectedEnum.MoveNext())
                {
                    Assembly assembly = null;

                    try
                    {
                        assembly = selectedEnum.Current as Assembly;
                    }
                    catch
                    {
                    }

                    if (assembly != null)
                    {
                        if (index == 0)
                        {
                            FillTree(assembly, treeView1);
                        }
                        else
                        {
                            FillTree(assembly, treeView2);
                            ShowTree2();
                            toolStripButtonCure.Visible = false;
                        }
                    }

                    index++;
                }
            }
            else
            {
                UI.ModelObjectSelector selector     = new UI.ModelObjectSelector();
                ModelObjectEnumerator  selectedEnum = selector.GetSelectedObjects();

                if (selectedEnum.MoveNext())
                {
                    Identifier identifier = (selectedEnum.Current as ModelObject).Identifier;

                    TreeNode[] nodes1 = treeView1.Nodes.Find(identifier.ID.ToString(), true);
                    TreeNode[] nodes2 = treeView2.Nodes.Find(identifier.ID.ToString(), true);

                    if (nodes1 != null && nodes1.Length > 0)
                    {
                        treeView1.SelectedNode = nodes1[0];
                        treeView1.Focus();
                    }
                    else if (nodes2 != null && nodes2.Length > 0)
                    {
                        treeView2.SelectedNode = nodes2[0];
                        treeView2.Focus();
                    }
                }
            }
        }
Пример #13
0
        public void Process()
        {
            var model            = new Tekla.Structures.Model.Model();
            var modelObjSelector = new Tekla.Structures.Model.UI.ModelObjectSelector();
            var selectedObj      = modelObjSelector.GetSelectedObjects();

            var objlist = new List <Beam>();

            while (selectedObj.MoveNext())
            {
                Tekla.Structures.Model.Part thisPart = selectedObj.Current as Tekla.Structures.Model.Part;

                if (thisPart != null)
                {
                    var objBeam = thisPart as Beam;
                    objlist.Add(objBeam);
                }
            }

            List <ConnectionInfo> conInfo = new List <ConnectionInfo>();
            var pairlist = new List <CollectionPair>();

            foreach (var item in objlist)
            {
                var currentitem = item;


                var items = objlist.Where
                                (layer =>
                                Math.Round(layer.StartPoint.Z, 1) == Math.Round(currentitem.StartPoint.Z, 1) ||
                                (
                                    Math.Round(layer.StartPoint.Z, 1) >= Math.Round(currentitem.StartPoint.Z, 1) &&
                                    Math.Round(layer.StartPoint.Z, 1) <= Math.Round(currentitem.EndPoint.Z, 1)
                                ) ||
                                (
                                    Math.Round(layer.EndPoint.Z, 1) >= Math.Round(currentitem.StartPoint.Z, 1) &&
                                    Math.Round(layer.EndPoint.Z, 1) <= Math.Round(currentitem.EndPoint.Z, 1)
                                )
                                ).ToList();

                foreach (var subitem in items)
                {
                    if (pairlist.Exists(
                            c => (c.Primary == currentitem.Identifier.ToString() && c.Secondary == subitem.Identifier.ToString()) ||
                            (c.Primary == subitem.Identifier.ToString() && c.Secondary == currentitem.Identifier.ToString())
                            ))
                    {
                        continue;
                    }

                    if (currentitem.Identifier != subitem.Identifier)
                    {
                        ConnectionInfo info  = new ConnectionInfo();
                        Line           line1 = new Line(currentitem);
                        Line           line2 = new Line(subitem);

                        var linechecker = new LineChecker(line1, line2);

                        if (linechecker.ValidConnection)
                        {
                            info.Primary          = linechecker.GetPrimary();
                            info.PrimaryId        = info.Primary.Id;
                            info.Secondary        = linechecker.GetSecondary();
                            info.SecondaryProfile = GetSecondaryBeamProfile(info.Secondary.ObjSource);
                            info.PrimaryType      = info.Primary.ObjSource.Type.ToString();
                            info.XIntersection    = (double)linechecker.X_Coord;
                            info.YIntersection    = (double)linechecker.Y1_Coord;
                            info.Level            = info.Secondary.ObjSource.StartPoint.Z.RoundDown(3);


                            Beam primary   = info.Primary.ObjSource;
                            Beam secondary = info.Secondary.ObjSource;


                            conInfo.Add(info);

                            // create pair of collection
                            // identify primary and secondary objects
                            // iterate pair of collection

                            var pairs = new CollectionPair()
                            {
                                Profile   = (linechecker.GetSecondary().Id == currentitem.Identifier.ID) ? currentitem.Profile.ProfileString : subitem.Profile.ProfileString,
                                Primary   = linechecker.GetPrimary().Id.ToString(),
                                Secondary = linechecker.GetSecondary().Id.ToString()
                            };
                            pairlist.Add(pairs);
                        }
                    }
                }
            }

            ProcessCollection(conInfo);

            Console.WriteLine("+++++++++++++++++++++++++++++");
            Console.WriteLine("Beam To Beam-Web Connection");
            Console.WriteLine();
            foreach (var i in BeamToBeamWebColl)
            {
                Console.WriteLine($"IsSingleConnection: {i.IsSingleConnection}");
                Console.Write($"{((Beam)i.PrimaryObject).Identifier.ID}");
                if (i.IsSingleConnection)
                {
                    Console.Write($">>{((Beam)i.SecondaryObject).Identifier.ID}");
                }
                else
                {
                    //Console.WriteLine($"Secondary ids:");
                    foreach (var l in i.SecondaryObjects)
                    {
                        var o = l as Beam;
                        Console.Write($">>{o.Identifier.ID}");
                    }
                }
                Console.WriteLine();
                Console.WriteLine("-------------------");
                Console.WriteLine();
            }
            Console.WriteLine("+++++++++++++++++++++++++++++");
            Console.WriteLine("Beam To Column-Web Connection");
            Console.WriteLine();
            foreach (var i in BeamToColumnWebColl)
            {
                Console.WriteLine($"IsSingleConnection: {i.IsSingleConnection}");
                Console.Write($"{((Beam)i.PrimaryObject).Identifier.ID}");
                if (i.IsSingleConnection)
                {
                    Console.Write($">>{((Beam)i.SecondaryObject).Identifier.ID}");
                }
                else
                {
                    //Console.WriteLine($"Secondary ids:");
                    foreach (var l in i.SecondaryObjects)
                    {
                        var o = l as Beam;
                        Console.Write($">>{o.Identifier.ID}");
                    }
                }
                Console.WriteLine();
                Console.WriteLine("-------------------");
                Console.WriteLine();
            }
            Console.WriteLine("+++++++++++++++++++++++++++++");
            Console.WriteLine("Beam To Column-Flange Connection");
            Console.WriteLine();
            foreach (var i in BeamToColumnFlangeColl)
            {
                Console.WriteLine($"IsSingleConnection: {i.IsSingleConnection}");
                Console.Write($"{((Beam)i.PrimaryObject).Identifier.ID}");
                if (i.IsSingleConnection)
                {
                    Console.Write($">>{((Beam)i.SecondaryObject).Identifier.ID}");
                }
                else
                {
                    //Console.WriteLine($"Secondary ids:");
                    foreach (var l in i.SecondaryObjects)
                    {
                        var o = l as Beam;
                        Console.Write($">>{o.Identifier.ID}");
                    }
                }
                Console.WriteLine();
                Console.WriteLine("-------------------");
                Console.WriteLine();
            }

            model.CommitChanges();
            //Console.ReadKey();
        }
            private static ModelObjectEnumerator getSelectedObjects()
            {
                var selector = new TSM.UI.ModelObjectSelector();
                ModelObjectEnumerator selectionEnum = selector.GetSelectedObjects();

                return selectionEnum;
            }