API Reference

Detailed and full API reference helps you master Tekla development

This is the most recent version of Tekla Open API.
For older versions, please visit Tekla Warehouse.

Meta.Microsoft.Help.Id
T:Tekla.Structures.Filtering.Filter

Filter Class

The Filter class creates a filter file based on the input FilterExpression object.
Inheritance Hierarchy
SystemObject
  Tekla.Structures.FilteringFilter

Namespace:  Tekla.Structures.Filtering
Assembly:  Tekla.Structures (in Tekla.Structures.dll) Version: 2020.0.0.0 (2020.0.55582.0)
Syntax
public class Filter

The Filter type exposes the following members.

Constructors
  Name Description
Public method Filter(FilterExpression)
Initializes a new instance of the Filter class.
Public method Filter(String, IFormatProvider)
Initializes a new instance of the Filter class.
Top
Properties
  Name Description
Public property FilterExpression
Gets the current FilterExpression instance.
Top
Methods
Examples
The following example creates a Tekla Structures object group selection filter file. The expression generated is the following: (PartName == BEAM1 OR PartName == BEAM2 OR PartName == BEAM3 OR PartComment StartsWith test)
using System;
using System.IO;
using Tekla.Structures.Filtering;
using Tekla.Structures.Filtering.Categories;

public class FilterExample
{
       // Creates a selection filter for the following filter expression:
       // (PartName == BEAM1 OR PartName == BEAM2 OR PartName == BEAM3 OR PartComment StartsWith test)
       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));

           string AttributesPath = Path.Combine(@"c:\modelPath", "attributes");
           string FilterName = Path.Combine(AttributesPath, "filter");

           Filter Filter = new Filter(ExpressionCollection);
           // Generates the filter file
           Filter.CreateFile(FilterExpressionFileType.OBJECT_GROUP_SELECTION, FilterName);
       }
}
See Also