//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); }
public static dynamic GetTSObject(StringConstantFilterExpression dynObject) { if (dynObject is null) { return(null); } return(dynObject.teklaObject); }
/// <summary>Selects all objects which are on the phase</summary> /// <param name="phaseNumber">Number of the phase</param> /// <exception cref="Exceptions.FilteringToolTeklaSettingsException">When macro directory not exsists</exception> public static void SelectObjects(int phaseNumber) { var assemblyPhase = new TemplateFilterExpressions.CustomString("ASSEMBLY.PHASE"); var phase = new StringConstantFilterExpression(phaseNumber.ToString()); var expresion1 = new BinaryFilterExpression(assemblyPhase, StringOperatorType.IS_EQUAL, phase); var objectType = new ObjectFilterExpressions.Type(); var partF = new NumericConstantFilterExpression(Tekla.Structures.TeklaStructuresDatabaseTypeEnum.PART); var expresion2 = new BinaryFilterExpression(objectType, NumericOperatorType.IS_EQUAL, partF); var expresion = new BinaryFilterExpressionCollection(); expresion.Add(new BinaryFilterExpressionItem(expresion1, BinaryFilterOperatorType.BOOLEAN_AND)); expresion.Add(new BinaryFilterExpressionItem(expresion2, BinaryFilterOperatorType.BOOLEAN_AND)); var filter = new Filter(expresion); var objects = new Tekla.Structures.Model.Model().GetModelObjectSelector().GetObjectsByFilter(expresion); objects.SelectInstances = false; var ar = new System.Collections.ArrayList(); while (objects.MoveNext()) { var part = objects.Current as Tekla.Structures.Model.Part; if (part != null) { var assembly = part.GetAssembly(); ar.Add(assembly); break; } } var mos = new Tekla.Structures.Model.UI.ModelObjectSelector(); mos.Select(new System.Collections.ArrayList()); mos.Select(ar); if (Tekla.Structures.TeklaStructures.Connect()) { TeklaMacroDirectory.CheckIfExists(); var akit = new Tekla.Structures.MacroBuilder(); akit.PushButton("butCancel", "diaPhaseManager"); akit.Callback("acmd_display_active_system_dialog", "", "main_frame"); akit.PushButton("butSelectPhases", "diaPhaseManager"); akit.PushButton("butSelectObjects", "diaPhaseManager"); akit.PushButton("butCancel", "diaPhaseManager"); akit.Run(); akit = null; } }