Tekle Open API: Get All Parts With Specific Class
This article explains how you can get reference to all existing objects in a Tekla Structure model with a specific class using the Tekla Open API in VB.Net.
Add reference to the Tekla.Structures.Model library located in the path “C:Program FilesTekla Structures20.0ntbinplugins” and manually open the tekla model. This has been covered in the article below:
You will need to choose what type of object you are looking for. Is it going to be a beam? A single rebar? Group Reinforcement?, … In this example I will assume we are trying to get all concrete parts (beam objects) with a class value equal to 5. This can be achieved using the following code:
Imports TSM = Tekla.Structures.Model ''' <summary> ''' Returns a list of beam objects whose class equals 5 ''' </summary> ''' <remarks></remarks> Private Function GetPartsWithClass() As List(Of TSM.Beam) Dim lstOutput As List(Of TSM.Beam) Dim appModel As TSM.Model Dim objModel As TSM.ModelObject Dim objBeam As TSM.Beam lstOutput = New List(Of TSM.Beam) appModel = New TSM.Model For Each objModel In appModel.GetModelObjectSelector.GetAllObjects objBeam = TryCast(objModel, Tekla.Structures.Model.Beam) If IsNothing(objBeam) = False Then 'check if classes matches If objBeam.Class = 5 Then lstOutput.Add(objBeam) End If End If Next Return lstOutput End Function
Line 20 checks the class of the beam object. If it is equal to 5, it is added to the list of beam objects.
You can download the file and code related to this article from the link below: