public override void Run()
        {
            var model = new TSM.Model();

            TSM.ModelObjectEnumerator.AutoFetch = true;
            var beams = model.GetModelObjectSelector().GetAllObjectsWithType(new Type[] { typeof(TSM.Beam) });

            int i = 0;

            while (beams.MoveNext())
            {
                var beam = beams.Current as TSM.Beam;

                Console.WriteLine("Beam: ");
                Console.WriteLine(beam.Name);
                Console.WriteLine(beam.Profile.ProfileString);
                Console.WriteLine(beam.StartPoint);
                Console.WriteLine();
                i++;
                if (i == 5)
                {
                    break;
                }
            }
        }
Example #2
0
        //Example from official documentation: developer.tekla.com
        public void CreateSelectionFilter()
        {
            // Creates the filter expressions
            PartFilterExpressions.Name     PartName = new PartFilterExpressions.Name();
            StringConstantFilterExpression Beam1    = new StringConstantFilterExpression("BEAM1");
            StringConstantFilterExpression Beam2    = new StringConstantFilterExpression("BEAM2");
            StringConstantFilterExpression Beam3    = new StringConstantFilterExpression("BEAM3");

            // Creates a custom part filter
            PartFilterExpressions.CustomString PartComment = new PartFilterExpressions.CustomString("Comment");
            StringConstantFilterExpression     Test        = new StringConstantFilterExpression("test");

            // Creates the binary filter expressions
            BinaryFilterExpression Expression1 = new BinaryFilterExpression(PartName, StringOperatorType.IS_EQUAL, Beam1);
            BinaryFilterExpression Expression2 = new BinaryFilterExpression(PartName, StringOperatorType.IS_EQUAL, Beam2);
            BinaryFilterExpression Expression3 = new BinaryFilterExpression(PartName, StringOperatorType.IS_EQUAL, Beam3);
            BinaryFilterExpression Expression4 = new BinaryFilterExpression(PartComment, StringOperatorType.STARTS_WITH, Test);

            // Creates the binary filter expression collection
            BinaryFilterExpressionCollection ExpressionCollection = new BinaryFilterExpressionCollection();

            ExpressionCollection.Add(new BinaryFilterExpressionItem(Expression1, BinaryFilterOperatorType.BOOLEAN_OR));
            ExpressionCollection.Add(new BinaryFilterExpressionItem(Expression2, BinaryFilterOperatorType.BOOLEAN_OR));
            ExpressionCollection.Add(new BinaryFilterExpressionItem(Expression3, BinaryFilterOperatorType.BOOLEAN_OR));
            ExpressionCollection.Add(new BinaryFilterExpressionItem(Expression4));

            var    modelPath      = new TSM.Model().GetInfo().ModelPath;
            string AttributesPath = Path.Combine(modelPath, "attributes");
            string FilterName     = Path.Combine(AttributesPath, this.filterName);

            Filter Filter = new Filter(ExpressionCollection);

            // Generates the filter file
            Filter.CreateFile(FilterExpressionFileType.OBJECT_GROUP_SELECTION, FilterName);
        }
Example #3
0
        public override void Run()
        {
            Console.WriteLine("Creating selection filter: " + filterName);
            CreateSelectionFilter();

            var model = new TSM.Model();

            Console.WriteLine("Trying to get objects form model ...");
            var filteredObjects = model.GetModelObjectSelector().GetObjectsByFilterName(filterName);

            Console.WriteLine($"{nameof(filteredObjects)}.GetSize() = {filteredObjects.GetSize()}");

            int i = 0;

            while (filteredObjects.MoveNext())
            {
                Console.WriteLine("Filtered object id: " + filteredObjects.Current.Identifier.ID);
                i++;
                if (i == 50)
                {
                    break;
                }
            }

            Console.WriteLine("End of test");
        }
        public override void Run()
        {
            var model = new TSM.Model();
            var modelObjectSelector = model.GetModelObjectSelector();

            TSM.ModelObjectEnumerator.AutoFetch = true;

            Console.WriteLine("Getting all objects from opened model");
            var allObjects = modelObjectSelector.GetAllObjects();

            allObjects.SelectInstances = false;

            Console.WriteLine(nameof(allObjects) + " cout: " + allObjects.GetSize());

            for (int i = 0; i < 20 && allObjects.MoveNext(); i++)
            {
                allObjects.Current.GetPhase(out TSM.Phase phase);
                Console.WriteLine(allObjects.Current.GetType() + "\tPhase number: " + phase.PhaseNumber);
            }

            Console.WriteLine();
            Console.WriteLine("Getting beams from opened model");
            var beams = modelObjectSelector.GetAllObjectsWithType(TSM.ModelObject.ModelObjectEnum.BEAM);

            Console.WriteLine(nameof(beams) + " cout: " + beams.GetSize());

            for (int i = 0; i < 20 && beams.MoveNext(); i++)
            {
                var beam = beams.Current as TSM.Beam;
                Console.WriteLine(beams.Current.GetType() + "\tProfile: " + beam.Profile.ProfileString);
            }
        }
        public override void Run()
        {
            var model = new TSM.Model();
            var info  = model.GetInfo();

            Console.WriteLine("ModelName:\t" + info.ModelName);
            Console.WriteLine("ModelPath:\t" + info.ModelPath);
            Console.WriteLine("CurrentPhase:\t" + info.CurrentPhase);
        }
        public override void Run()
        {
            //Crate beam
            var beam = new TSM.Beam();

            beam.Material.MaterialString = "S235JR";
            beam.Profile.ProfileString   = "HEB300";
            beam.StartPoint = new T3D.Point(0, 0, 0);
            beam.EndPoint   = new T3D.Point(5000, 5000, 5000);
            beam.Class      = "2";
            beam.Name       = "Hello beam";
            beam.Insert();

            //Commit changes in model
            var model = new TSM.Model();

            model.CommitChanges();

            //Show beam identifiers
            Console.WriteLine("Beam inserted");
            Console.WriteLine("Beam name:\t" + beam.Name);
            Console.WriteLine("Beam id:\t" + beam.Identifier.ID);
            Console.WriteLine("Beam guid:\t" + beam.Identifier.GUID);

            //Get phase
            beam.GetPhase(out TSM.Phase phase);
            Console.WriteLine("Beam phase:\t" + phase.PhaseNumber);

            //Check weight
            double weight = 0;

            beam.GetReportProperty("WEIGHT", ref weight);
            Console.WriteLine("Beam weight:\t" + weight);

            //Check profile
            string profile = "";

            beam.GetReportProperty("PROFILE", ref profile);
            Console.WriteLine("Beam profile:\t" + weight);

            //Select beam
            var selector = new TSM.UI.ModelObjectSelector();

            selector.Select(new ArrayList()
            {
                beam
            });
        }