I’m using a lot the live link for data manipulation and I’m loving it.
I have a query, is there a way of getting data from the model itself and not an element? Like the name of the model I’m linked to? or the path where the model is? That type of data.
Also it could be ideal, and I know someone mentioned this in the forum, to have the possibility of replicating Tekla filters but from GH. I know Sebastian did an example with selecting GUID using Get Property, Match Text and Cull Pattern, and I’ve used it already, but could be nice to create filters from GH.
For the model info there’s no component, although the info can be queried rather easily with the API and a C# component if you’re into that. Check the ModelInfo class and example code:
With the Tekla Object Pipeline component you can select objects based on existing filters as you probably know. Creating new filters on the fly is an interesting proposal but not possible at the moment.
You might have already mastered C# and the Tekla Open API by now.
If not, you can refer to the sample code below to create your own filter directly from GH.
By connecting the output “b” to the Object Pipeline, you can optain the required parts without first creating a filter in the Tekla model.
Cheers,
region Usings
using System; #r “C:\Program Files\Tekla Structures\2025.0\bin\Tekla.Structures.Model.dll” #r “C:\Program Files\Tekla Structures\2025.0\bin\Tekla.Structures.Geometry3d.Compatibility.dll” #r “C:\Program Files\Tekla Structures\2025.0\bin\Tekla.Structures.dll”
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using Rhino;
using Rhino.DocObjects;
using Rhino.Geometry;
using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Types;
using System;
using System.IO;
using Tekla.Structures.Model;
using Tekla.Structures.Model.UI;
using Tekla.Structures.Geometry3d;
using Tekla.Structures.Filtering;
using Tekla.Structures.Filtering.Categories;
#endregion
private void RunScript(bool Zooming, ref object a, ref object b, ref object c)
{
//Get model path
Tekla.Structures.Model.Model model = new Tekla.Structures.Model.Model();
ModelInfo modelInfo = model.GetInfo();
string modelPath = modelInfo.ModelPath;
// Creates the filter expressions
AssemblyFilterExpressions.Prefix assemblyPrefix = new AssemblyFilterExpressions.Prefix();
StringConstantFilterExpression assemblyPrefix_content = new StringConstantFilterExpression("Column Beam");
PartFilterExpressions.Profile partProfile = new PartFilterExpressions.Profile();
StringConstantFilterExpression partProfile_content = new StringConstantFilterExpression("H* [*");
// Creates the binary filter expressions
BinaryFilterExpression expression_1 = new BinaryFilterExpression(assemblyPrefix, StringOperatorType.STARTS_WITH, assemblyPrefix_content);
BinaryFilterExpression expression_2 = new BinaryFilterExpression(partProfile, StringOperatorType.IS_EQUAL, partProfile_content);
// Creates the binary filter expression collection
BinaryFilterExpressionCollection expressionCollection = new BinaryFilterExpressionCollection();
expressionCollection.Add(new BinaryFilterExpressionItem(expression_1, BinaryFilterOperatorType.BOOLEAN_AND));
expressionCollection.Add(new BinaryFilterExpressionItem(expression_2, BinaryFilterOperatorType.EMPTY));
string attributesPath = Path.Combine(modelPath, "attributes");
string filterName = Path.Combine(attributesPath, "FilterForGrasshopper");
Filter filter = new Filter(expressionCollection);
filter.CreateFile(FilterExpressionFileType.OBJECT_GROUP_SELECTION, filterName);
//Result
a = filterName;
c = filter;
//Gets file name
List<string> list_filePathSplitted = new List<string>(filterName.Split('\\'));
b = list_filePathSplitted[list_filePathSplitted.Count - 1];
Print(modelPath);
}