Tekla Open API: Cast Units

Tags

, , ,

This article explains how you can create cast unit using  the Tekla Open API in VB.Net.


Step 1:

Add reference to the Tekla.Structures.Model and the Tekla.Structures library located in the path “C:\Program Files\Tekla Structures\20.0\nt\bin\plugins” and manually open the tekla model. This has been covered in the article below:

 


Step 2:

The next step would be to get reference to the parts you would like to add to an assembly. This can be done in different ways. Below are a couple of example for achieving this:


Creating a Cast Unit:

Consider the model below:
Blog_Tekla_API_CastUnit_1
The model consists of 3 columns and 2 beams. In reinforced concrete models it is beneficial to add the beams to cast units. The beams in the model can be added to a cast unit using the code below:

 Private Sub CreateCastUnit(ByRef objBeam1 As TSM.Beam, ByRef objBeam2 As TSM.Beam)
        Dim objAssembly As TSM.Assembly

        objBeam1.CastUnitType = Tekla.Structures.Model.Part.CastUnitTypeEnum.CAST_IN_PLACE
        objBeam2.CastUnitType = Tekla.Structures.Model.Part.CastUnitTypeEnum.CAST_IN_PLACE
        objAssembly = objBeam1.GetAssembly

        objAssembly.Add(objBeam2)
        objAssembly.Modify()
    End Sub

If you need assistance with your Tekla model, or you are looking for a Tekla Open API programmer to hire feel free to contact me. Also please visit my home page  www.software-solutions-online.com

Tekla Open API: Views

Tags

, , , ,

This article explains how you can create/modify/delete views in the model using the Tekla Open API in VB.Net. For more information about View Filters please see the article below:


Step 1:

Add reference to the Tekla.Structures.Model and the Tekla.Structures library located in the path “C:\Program Files\Tekla Structures\20.0\nt\bin\plugins” and manually open the tekla model. This has been covered in the article below:


Delete Existing Views:

Views are defined by their name. In the figure below you can see that the model has only 1 defined view and it has the name “MyNewView”:
Blog_Tekla_API_Views_1
Views can be deleted using the function below:

Imports TSM = Tekla.Structures.Model

    ''' <summary>
    ''' Delete All Views in the Model
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub DeleteAllViews()

        Dim objViews As Tekla.Structures.Model.UI.ModelViewEnumerator

        objViews = TSM.UI.ViewHandler.GetAllViews
        While objViews.MoveNext
            objViews.Current.Delete()
        End While
    End Sub

The code above deletes all views in the model. Using the code below you can be more specific. The code below deletes only the view with the name “GRID A”:


Imports TSM = Tekla.Structures.Model
    ''' <summary>
    ''' Delete the View with the Name "GRID A"
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub DeleteSpecificViews()

        Dim objViews As Tekla.Structures.Model.UI.ModelViewEnumerator

        objViews = TSM.UI.ViewHandler.GetAllViews
        While objViews.MoveNext
            If objViews.Current.Name = "GRID A" Then
                objViews.Current.Delete()
            End If
        End While
    End Sub

 


Creating New Views:

The code below will create a new view with the name “MyNewView”:

Imports TSM = Tekla.Structures.Model
Imports TSG = Tekla.Structures.Geometry3d

    ''' <summary>
    ''' Creates a new view with the name "MyNewView"
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub CreateNewView()

        Dim objView As TSM.UI.View
        objView = New TSM.UI.View

        objView.Name = "MyNewView"
        objView.ViewCoordinateSystem.AxisX = New TSG.Vector(1, 0, 0)
        objView.ViewCoordinateSystem.AxisY = New TSG.Vector(0, 1, 0)

        objView.WorkArea.MinPoint = New TSG.Point(-3000, -3000, 0)
        objView.WorkArea.MaxPoint = New TSG.Point(15000, 33000, 18000)
        objView.ViewDepthUp = 50000
        objView.ViewDepthDown = 25000

        objView.Insert()

    End Sub

The view will not be activated using the code above. You will be able to find it in your view list:
Blog_Tekla_API_Views_2


Modify Existing Views:

In order to modify an existing view, the first step will be to get reference to it. The rest is similar to inserting a new view:

Imports TSM = Tekla.Structures.Model
Imports TSG = Tekla.Structures.Geometry3d

    ''' <summary>
    ''' Loops through all the views in the model until the "MyNewView" view is found.
    ''' It will then modify the view
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub ModifyView()
        Dim objViews As Tekla.Structures.Model.UI.ModelViewEnumerator
        Dim objView As TSM.UI.View

        objViews = TSM.UI.ViewHandler.GetAllViews
        While objViews.MoveNext
            If objViews.Current.Name = "MyNewView" Then
                objView = objViews.Current

                objView.ViewCoordinateSystem.AxisX = New TSG.Vector(0, 1, 0)
                objView.ViewCoordinateSystem.AxisY = New TSG.Vector(1, 0, 0)

                objView.WorkArea.MinPoint = New TSG.Point(0, 0, 0)
                objView.WorkArea.MaxPoint = New TSG.Point(1000, 3000, 1000)
                objView.ViewDepthUp = 50000
                objView.ViewDepthDown = 25000

                objView.Modify()
            End If
        End While
    End Sub

The while loop on line 14 iterates through all the views in the model. Line 15 checks its name for a match. If a match is found lines 16~26 modify its properties.

You can download the sample file and code for this article from the link below:

If you need assistance with your Tekla model, or you are looking for a Tekla Open API programmer to hire feel free to contact me. Also please visit my home page  www.software-solutions-online.com

Tekla Open API: Grids

Tags

, , , ,

This article explains how you can create/modify/delete grids in the model using the Tekla Open API in VB.Net.


Step 1:

Add reference to the Tekla.Structures.Model library located in the path “C:\Program Files\Tekla Structures\20.0\nt\bin\plugins” and manually open the tekla model. This has been covered in the article below:


Delete Existing Grids:

The following code will delete the existing grid from the model:

Imports TSM = Tekla.Structures.Model

    ''' <summary>
    ''' Deletes existing grids from the model
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub DeleteExistingGrids()
        Dim appModel As TSM.Model
        Dim objModel As TSM.ModelObject
        Dim objGrid As TSM.Grid

        appModel = New TSM.Model
        For Each objModel In appModel.GetModelObjectSelector.GetAllObjects
            objGrid = TryCast(objModel, Tekla.Structures.Model.Grid)
            If IsNothing(objGrid) = False Then
                objGrid.Delete()

            End If
        Next
        appModel.CommitChanges()

        appModel = Nothing
        objModel = Nothing
        objGrid = Nothing
    End Sub

The code basically loops through all the objects in the model. If the object is of the grid type the object will be deleted.


Add New Grid:

The following code will add a new grid to the model:

Imports TSM = Tekla.Structures.Model

    Private Sub Main()
        DeleteExistingGrids()
        SetGrid()
    End Sub

    ''' <summary>
    ''' Creates the new grid
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub SetGrid()
        Dim objGrid As TSM.Grid
        Dim appTekla As TSM.Model

        Dim strXCoor As String
        Dim strYCoor As String
        Dim strZCoor As String

        Dim strXLabel As String
        Dim strYLabel As String
        Dim strZLabel As String

        'grid spacing
        strXCoor = "0 1000 1000 1000"
        strYCoor = "0 2000 2000 2000 2000"
        strZCoor = "0 3000 3000"

        'grid labels
        strXLabel = "A B C D "
        strYLabel = "1 2 3 4 5"
        strZLabel = "E1 E2 E3"

        appTekla = New TSM.Model
        objGrid = New TSM.Grid

        objGrid.CoordinateX = strXCoor
        objGrid.CoordinateY = strYCoor
        objGrid.CoordinateZ = strZCoor
        objGrid.LabelX = strXLabel
        objGrid.LabelY = strYLabel
        objGrid.LabelZ = strZLabel
        objGrid.Insert()
        appTekla.CommitChanges()

        appTekla = Nothing
        objGrid = Nothing
    End Sub

    ''' <summary>
    ''' Deletes existing grids from the model
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub DeleteExistingGrids()
        Dim appModel As TSM.Model
        Dim objModel As TSM.ModelObject
        Dim objGrid As TSM.Grid

        appModel = New TSM.Model
        For Each objModel In appModel.GetModelObjectSelector.GetAllObjects
            objGrid = TryCast(objModel, Tekla.Structures.Model.Grid)
            If IsNothing(objGrid) = False Then
                objGrid.Delete()

            End If
        Next
        appModel.CommitChanges()

        appModel = Nothing
        objModel = Nothing
        objGrid = Nothing
    End Sub
End Class

Line 5 calls the DeleteExistingGrids function. The new grid will not be inserted when a grid already exists. Lines 26~28 define the grid spacing. It is important that the correct format is used or the grid will not be created.

Result:
blog_Tekla_TeklaAPI_Grid_1


Modify Existing Grid:

Modifying an existing grid can be done using the code below:

Imports TSM = Tekla.Structures.Model

  Private Sub Main2()
        Dim objGrid As TSM.Grid
        objGrid = GetExistingGrids()
        ModifyGrid(objGrid)
    End Sub

    ''' <summary>
    ''' Creates the new grid
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub ModifyGrid(ByRef objGrid As TSM.Grid)

        Dim appTekla As TSM.Model

        Dim strXCoor As String
        Dim strYCoor As String
        Dim strZCoor As String

        Dim strXLabel As String
        Dim strYLabel As String
        Dim strZLabel As String

        'grid spacing
        strXCoor = "0 10000 10000 10000"
        strYCoor = "0 2000 2000 2000 2000"
        strZCoor = "0 3000 3000"

        'grid labels
        strXLabel = "A B C D "
        strYLabel = "1 2 3 4 5"
        strZLabel = "E1 E2 E3"

        appTekla = New TSM.Model
        objGrid = GetExistingGrids()

        objGrid.CoordinateX = strXCoor
        objGrid.CoordinateY = strYCoor
        objGrid.CoordinateZ = strZCoor
        objGrid.LabelX = strXLabel
        objGrid.LabelY = strYLabel
        objGrid.LabelZ = strZLabel
        objGrid.Modify()
        appTekla.CommitChanges()

        appTekla = Nothing
        objGrid = Nothing
    End Sub

    ''' <summary>
    ''' Gets the existing grids from the model
    ''' </summary>
    ''' <remarks></remarks>
    Private Function GetExistingGrids() As TSM.Grid
        Dim appModel As TSM.Model
        Dim objModel As TSM.ModelObject
        Dim objGrid As TSM.Grid

        appModel = New TSM.Model
        For Each objModel In appModel.GetModelObjectSelector.GetAllObjects
            objGrid = TryCast(objModel, Tekla.Structures.Model.Grid)
            If IsNothing(objGrid) = False Then
                appModel = Nothing
                objModel = Nothing
                Return objGrid

            End If
        Next

        Return Nothing
    End Function

The function GetExistingGrids gets reference to the existing grid object in the model.

You can download the sample file and code used in this article from the link below:

If you need assistance with your Tekla model, or you are looking for a Tekla Open API programmer to hire feel free to contact me. Also please visit my home page  www.software-solutions-online.com

Tekla Open API, Hide/Show Objects in Model

Tags

, , , ,

This article explains how you can use the Tekla Open API to hide and show objects in the model. Note that the API doesn’t provide any direct methods for hiding/showing objects in the model. This article will provide a workaround for achieving this.

 


Step 1, Add Libraries:

Add reference to the Tekla.Structures.Model library located in the path “C:\Program Files\Tekla Structures\20.0\nt\bin\plugins” and manually open the tekla model. This has been covered in the article below:


Step 2, Manually Create Filter (One Time Only):

You will need to manually create the following filter:

( Category Property Condition Value ) And/Or
Object User field 1 (USER_FIELD_1) Equals “Show”

Save the filter under the name “MyNewFilter”:
Blog_Tekla_API_HideShowObjects_3

Note: This step is one time only. Once the filter is created you will be able to use it in all other models.


Step 3:

With the previous filter in place all you need to do is change the value of “user field 1” for the objects in the model, and they will be hidden or shown. For example consider the model below:
Blog_Tekla_API_HideShowObjects_2
Lets say we only want to show the parts in the model. This can be achieved using the code below:

Imports TSM = Tekla.Structures.Model

    Private Sub ShowPartsOnly()
        Dim appModel As TSM.Model
        Dim objModel As TSM.ModelObject
        Dim objPart As TSM.Part
        Dim objViewEnum As TSM.UI.ModelViewEnumerator
        Dim objView As TSM.UI.View

        appModel = New TSM.Model

        'change the user field 1 attribute
        For Each objModel In appModel.GetModelObjectSelector.GetAllObjects
            objPart = TryCast(objModel, Tekla.Structures.Model.Part)
            If IsNothing(objPart) = False Then
                objPart.SetUserProperty("USER_FIELD_1", "Show")
            Else
                objModel.SetUserProperty("USER_FIELD_1", "Hide")
            End If
        Next

        'change the view filter
        objViewEnum = TSM.UI.ViewHandler.GetAllViews
        While objViewEnum.MoveNext
            objView = objViewEnum.Current
            objView.ViewFilter = "MyNewFilter"
            objView.Modify()
        End While

        appModel = Nothing
        objModel = Nothing
        objPart = Nothing
        objView = Nothing
        objViewEnum = Nothing
    End Sub

Lines 13~20 loop through all the objects in the model. If the object is a part, the “user field 1” attribute is set to “Show”. For all other objects the “user field 1” attribute is set to “Hide”.

Lines 23~28 loop through all the views in the model and change the view filter to “MyNewFilter” which was defined in step 2. By changing the view filters, all objects whos “user field 1” is not set to “show” will be hidden from the model.

Result:
Blog_Tekla_API_HideShowObjects_4
You can download the sample file and code used in this article from the link below:

See also:

If you need assistance with your Tekla model, or you are looking for a Tekla Open API programmer to hire feel free to contact me. Also please visit my home page  www.software-solutions-online.com

Tekla Open API: Change View Filters

Tags

, , ,

View filters cannot be directly modified using the Tekla Open API. The only possible option regarding view filters and the API, is to change the current view filter to another view filter from the list of available views filters.


Step 1, Add Libraries:

Add reference to the Tekla.Structures.Model library located in the path “C:\Program Files\Tekla Structures\20.0\nt\bin\plugins” and manually open the tekla model. This has been covered in the article below:


Change View  Types:

Using the code below the view filters of all the available views are changed to a view filter with the name “MyNewFilter”

Imports TSM = Tekla.Structures.Model

    Private Sub ChangeViews()
        Dim objViewEnum As TSM.UI.ModelViewEnumerator
        Dim objView As TSM.UI.View

        objViewEnum = TSM.UI.ViewHandler.GetAllViews
        While objViewEnum.MoveNext
            objView = objViewEnum.Current

            objView.ViewFilter = "MyNewFilter"
            objView.Modify()
        End While

    End Sub

You can download the sample file and code used in this article from the link below:

If you need assistance with your Tekla model, or you are looking for a Tekla Open API programmer to hire feel free to contact me. Also please visit my home page  www.software-solutions-online.com

Tekla Structures: Hide/Show Specific Objects in Model

Tags

, ,

Models made in Tekla can get very crowded with objects. Working in such a model can get very difficult without hiding some of the objects. This can be done by applying filters.

Consider the reinforced concrete model below:
Blog_Tekla_TeklaSoftware_Filter
Everything is visible in this model:

  • Foundation
  • Foundation Rebars
  • Columns
  • Column Rebars
  • Beams
  • Beam Rebars
  • ….

Working in such a model can be quite confusing. By applying filter we will be able to hide the objects we don’t need and only display the objects we are trying to work with.


Step 1, Select the View:

The first step in applying a view filter is to select the view. This may seem like an unnecessary thing when you are working with only one view, but it can be very useful when you’ve got multiple views open.

Make sure you have View Selection enabled:
Blog_Tekla_TeklaSoftware_Filter_3
Click an empty spot on the view, until the red border appears around the view:
Blog_Tekla_TeklaSoftware_Filter_4
1- Right click then select properties

or

2- From the view tab select View Properties.


Example 1, Display Parts Only:

In this example only the concrete parts will be displayed in the model. The filter requires only one row:
Blog_Tekla_TeklaSoftware_Filter_2

( Category Property Condition Value ) And/Or
Object Object Type Equals Part

Result:
Blog_Tekla_TeklaSoftware_Filter_5


Example 2, Display Columns and Column Rebars Only:

Lets you would like to only view column and column rebars in the model. One method for achieving this would be to assign different classes to the different objects in the model . In the table below you can see the different classes assigned to the different objects in the model:

Object Type Location Class
Part Beam 1
Part Columns 2
Longitudinal Reinforcement Beam 3
Tie Beam 4
Longitudinal Reinforcement Column 5
Tie Column 6
Part Shear Wall 7
Longitudinal Reinforcement Shear Wall 8
Part Foundation 9
Bottom Reinforcement in Y Dir Foundation 10
Upper Reinforcement in Y Dir Foundation 11
Bottom Reinforcement in X Dir Foundation 12
Uppper Reinforcement in X Dir Foundation 13

In order to only display the column parts and their associated rebars we would need to use the filter below:
Blog_Tekla_TeklaSoftware_Filter_6

( Category Property Condition Value ) And/Or
Part Class Equals 2 And
( Reinforcing Bar Class Equals 5 or
Reinforcing Bar Class Equals 6 )

Note the start, end parenthesis and the and/or phrases.

Result:
Blog_Tekla_TeklaSoftware_Filter_7


Example 3, Show Parts With “User Field 1” Set to “1”:

All objects in the model accept user defined attribute. In the figure below you can see the user define attributes associated with  the columns parts:
Blog_Tekla_TeklaSoftware_Filter_8
These properties are mainly for the designers reference and will not directly impact the model. Using the filter below all parts with a “User Field 1” set to the value “1” will be displayed:
Blog_Tekla_TeklaSoftware_Filter_9

 

( Category Property Condition Value ) And/Or
Part User field 1 Equals 1 And
Object Object Type Equals Part

If you need assistance with your Tekla model, or you are looking for a Tekla Open API programmer to hire feel free to contact me. Also please visit my home page  www.software-solutions-online.com

Tekla Open API: Get/Set User Defined Attributes

Tags

, , ,

This article explains how you can get/set user defined attributes using the tekla open api.

 


Step 1, Add Libraries:

Add reference to the Tekla.Structures.Model library located in the path “C:\Program Files\Tekla Structures\20.0\nt\bin\plugins” and manually open the tekla model. This has been covered in the article below:


Step 2, Get Reference to Object:

You will need to get reference to the object you wish to get/set its user defined attributes. Below are some of the options for achieving this:

1- Get reference to an existing part in the tekla model: VB.Net Get Reference to Object, Tekla Open API

2- Ask the user to select parts from the model: Tekla Open API: Ask User to Select Objects.


Set User Defined Attributes:

The following code will set the “User Field 1” property of the input part object to “New Value”:

Imports TSM = Tekla.Structures.Model

    Private Sub SetUserDefinedField(ByRef objBeam As TSM.Beam)
        objBeam.SetUserProperty("USER_FIELD_1", "New Value")
        objBeam.Modify()
    End Sub

Line 4 sets the user defined attribute for the input part object. The first parameter to the function is the name of the user defined attribute to modify (User field 1 in this example). The second parameter is the value to set it to (“New Value”).
Result:
Blog_Tekla_GetSetUserdefinedProperties_1


Get User Defined Attributes:

The following code will get the “User Field 1” property of the input part object:

Imports TSM = Tekla.Structures.Model

    Private Function GetserDefinedField(ByRef objBeam As TSM.Beam) As String
        Dim strOutput As String

        strOutput = ""
        objBeam.GetUserProperty("USER_FIELD_1", strOutput)
        Return strOutput

    End Function

User Defined Attributes:

You can find all the user defined attribute in the file “objects.inp” located in the path “C:\ProgramData\Tekla Structures\20.0\Environments\Common\inp”. Where 20.0 is the version you are using.

Below I have compiled a list of user defined attribute from the file:

String Parameter User Defined Attribute
IFC_ENTITY IFC entity
IFC_EXPORT_TYPE IFC export type
IFC_BUILDING IFC building
IFC_BUILDING_STOREY IFC building storey
comment comment
xs_shorten xs shorten
cambering cambering
PRELIM_MARK PRELIM MARK
PRELIM_ASSEM_MARK Preliminary assembly mark
OBJECT_LOCKED Locked
fabricator fabricator name
USER_FIELD_1 user field 1
USER_FIELD_2 user field 2
USER_FIELD_3 user field 3
USER_FIELD_4 user field 4
USER_PHASE UserPhase effects numbering
FixedMainView FixedDrawingMainView
TOCOMANOBJECTTYPE Tocoman object type
PRODUCT_CODE Product code
PRODUCT_DESCR Product description
PRODUCT_WEBSITE Product website
PRODUCT_WEIGHT Product weight
PRODUCT_UNIT Product unit
initial_GUID initial GUID
EN1090_EXC_PART Execution class
comment comment
PRELIM_MARK PRELIM MARK
OBJECT_LOCKED Locked
fabricator fabricator name
USER_FIELD_1 user field 1
USER_FIELD_2 user field 2
USER_FIELD_3 user field 3
USER_FIELD_4 user field 4
USER_PHASE UserPhase effects numbering
FixedMainView TopInFormFace
NUMBERING_ORDER Numbering Order
TOCOMANOBJECTTYPE Tocoman object type
ACN ACN control number
ACN_STATUS ACN control number status
PRODUCT_CODE Product code
PRODUCT_DESCR Product description
PRODUCT_WEBSITE Product website
initial_GUID initial GUID
start AD start node
end AD end node
reactions End reactions
shear Shear Vy
moment Moment Mz
tension Tension Nt
compression Compression Nc
shearZ Shear Vz
momentY Moment My
torsion Torsion Mx
UDL_CODE UDL code
releases MomentConnection
CONN_CAP ConnectionCapacity
utilityratio1 Utility ratio1
conn_code conn code
AD_saved_prop AD saved prop
ADUtilityRatio Utility ratio
ADReinfArea Reinforcement area
__DisableOrient Main axis direction
DR_ASSIGNED_TO AssignedTo
DR_ASSIGNED_BY AssignedBy
DR_DRAWN_BY DrawnBy
DR_CHECKED_BY CheckedBy
DR_CHECKED_DATE CheckedDate
DR_APPROVAL_SENT SentforApproval
DR_APPROVAL_DATE ApprovalDate
DR_APPROVED_BY ApprovedBy
comment comment
DRAWING_USERFIELD_1 user field 1
DRAWING_USERFIELD_2 user field 2
DRAWING_USERFIELD_3 user field 3
DRAWING_USERFIELD_4 user field 4
DRAWING_USERFIELD_5 user field 5
DRAWING_USERFIELD_6 user field 6
DRAWING_USERFIELD_7 user field 7
DRAWING_USERFIELD_8 user field 8
comment comment
USER_FIELD_1 user field 1
USER_FIELD_2 user field 2
USER_FIELD_3 user field 3
USER_FIELD_4 user field 4
USER_PHASE UserPhase effects numbering
REBAR_SEQ_NO rebar sequence number
PRODUCT_DESCR Product description
UT_REBAR_TYPE unitechnik reinforcement type
comment comment
USER_FIELD_1 user field 1
USER_FIELD_2 user field 2
USER_FIELD_3 user field 3
USER_FIELD_4 user field 4
WELD_COMMENT weld comment
WELD_USERFIELD_1 weld ufield 1
WELD_USERFIELD_2 weld ufield 2
WELD_USERFIELD_3 weld ufield 3
WELD_USERFIELD_4 weld ufield 4
WELD_USERFIELD_5 weld ufield 5
WELD_USERFIELD_6 weld ufield 6
WELD_USERFIELD_7 weld ufield 7
WELD_USERFIELD_8 weld ufield 8
OBJECT_LOCKED Locked
BOLT_COMMENT bolt comment
BOLT_USERFIELD_1 bolt ufield 1
BOLT_USERFIELD_2 bolt ufield 2
BOLT_USERFIELD_3 bolt ufield 3
BOLT_USERFIELD_4 bolt ufield 4
BOLT_USERFIELD_5 bolt ufield 5
BOLT_USERFIELD_6 bolt ufield 6
BOLT_USERFIELD_7 bolt ufield 7
BOLT_USERFIELD_8 bolt ufield 8
OBJECT_LOCKED Locked
PROJECT_COMMENT proj comment
PROJECT_USERFIELD_1 user field 1
PROJECT_USERFIELD_2 user field 2
PROJECT_USERFIELD_3 user field 3
PROJECT_USERFIELD_4 user field 4
PROJECT_USERFIELD_5 user field 5
PROJECT_USERFIELD_6 user field 6
PROJECT_USERFIELD_7 user field 7
PROJECT_USERFIELD_8 user field 8
EN1090_EXC Execution class
IFC_SITE IFC site
IFC_BUILDING IFC building
IFC_BUILDING_STOREY IFC building storey
Longitude_grad Longitude grad
Longitude_minutes Longitude minutes
Longitude_seconds Longitude seconds
Longitude_millionths Longitude millionths
Latitude_grad Latitude grad
Latitude_minutes Latitude minutes
Latitude_seconds Latitude seconds
Latitude_millionths Latitude millionths
Elevation Elevation
North_direction North direction angle
label AssignedTo
label AssignedBy
label Checked by
label Check date
FACTORY_LOCATION factory location
comment comment
example_string ample string
example_integer ample integer
example_float ample float
ref_description Description
OBJECT_LOCKED Locked
ref_info_string Infotext
ref_logical_name Logical name
subref_description Description
subref_info_string Infotext
subref_logical_name Logical name
OBJECT_LOCKED Locked
comment a comment
USER_FIELD_1 a user field 1
USER_FIELD_2 a user field 2
USER_FIELD_3 a user field 3
USER_FIELD_4 a user field 4
PRELIM_ASSEM_MARK Preliminary assembly mark
ACN ACN control number
EN1090_EXC_ASSEMBLY Execution class
IFC_ASSEMBLY IFC entity
comment comment
USER_FIELD_1 user field 1
USER_FIELD_2 user field 2
USER_FIELD_3 user field 3
USER_FIELD_4 user field 4
ACN ACN control number
comment comment
USER_FIELD_1 user field 1
USER_FIELD_2 user field 2
USER_FIELD_3 user field 3
USER_FIELD_4 user field 4
ACN ACN control number
OBJECT_LOCKED Locked
OBJECT_LOCKED Locked
SCENARIO_UDANAME enario
TASKTYPE_UDANAME sk Type
CONTRACTOR_UDANAME ntractor
POUR_NUMBER Pour number
POUR_TYPE Pour type
CONCRETE_MIXTURE Pour concrete mixture
COMMENT comment
USER_FIELD_1 user field 1
USER_FIELD_2 user field 2
USER_FIELD_3 user field 3
USER_FIELD_4 user field 4
COMMENT comment
BREAK_TYPE Pour break type

You can download the sample code and file for this article from the link below:

If you need assistance with your Tekla model, or you are looking for a Tekla Open API programmer to hire feel free to contact me. Also please visit my home page  www.software-solutions-online.com

Tekla Open API: Get Part Bounds

Tags

, ,

This article explains how you can get the min max bounds of a part object in a tekla model. Note part bounds will not be very useful when the part is not aligned in one of the 3 main directions.


Step 1:

Add reference to the Tekla.Structures.Model and the Tekla.Structures library located in the path “C:\Program Files\Tekla Structures\20.0\nt\bin\plugins” and manually open the tekla model. This has been covered in the article below:


Step 2:

You will need to get reference to the part you wish to get this information from . Below are some of the options for achieving this:

1  – Create a new part and keep a reference to the part: Insert Concrete Beam Using VB.Net (Tekla Open API)

2 – Get reference to an existing part in the tekla model: VB.Net Get Reference to Object, Tekla Open API

3- Ask the user to select parts from the model: Tekla Open API: Ask User to Select Objects.


Get Part Bounds:

You can get the part bounds using the function below. Note the part object attained in the previous step must be passed as input to the function below:

Imports TSM = Tekla.Structures.Model


    Private Sub GetPartBounds(ByRef objBeam As TSM.Beam)
        Dim XMax As Double
        Dim YMax As Double
        Dim ZMax As Double
        Dim XMin As Double
        Dim YMin As Double
        Dim ZMin As Double

        XMax = objBeam.GetSolid.MaximumPoint.X
        YMax = objBeam.GetSolid.MaximumPoint.Y
        ZMax = objBeam.GetSolid.MaximumPoint.Z
        XMin = objBeam.GetSolid.MinimumPoint.X
        YMin = objBeam.GetSolid.MinimumPoint.Y
        ZMin = objBeam.GetSolid.MinimumPoint.Z

    End Sub

If you need assistance with your Tekla model, or you are looking for a Tekla Open API programmer to hire feel free to contact me. Also please visit my home page  www.software-solutions-online.com

Tekla Open API: Ask User to Select Objects

Tags

, , , , , , ,

This article explains how you can ask the user to select objects from the model using the Tekla Open API. It also provides examples as to how to filter the objects selected by the user.


Step 1:

Add reference to the Tekla.Structures.Model and Tekla.Structures.Drawing library located in the path “C:\Program Files\Tekla Structures\20.0\nt\bin\plugins” and manually open the tekla model. This has been covered in the article below:


Ask User to Select Objects:

The following code asks the user to select objects from the model. It returns a list of all selected objects by the user.

Imports TSM = Tekla.Structures.Model
Imports TSD = Tekla.Structures.drawing

    ''' <summary>
    ''' Ask the user to select objects from the model
    ''' </summary>
    ''' <returns>The list of selected objects by the user</returns>
    ''' <remarks></remarks>
    Private Function SelectObjects() As List(Of Object)
        Dim objUIPICker As TSM.UI.Picker
        Dim objModelObjectEnumerator As TSM.ModelObjectEnumerator
        Dim lstOutput As List(Of Object)

        objUIPICker = New TSM.UI.Picker()
        lstOutput = New List(Of Object)

        Try
            'This line asks the user to select an object from the model
            objModelObjectEnumerator = objUIPICker.PickObjects(Tekla.Structures.Model.UI.Picker.PickObjectsEnum.PICK_N_OBJECTS, "Select Objects")
            'loops through all the objects selected by the user
            While objModelObjectEnumerator.MoveNext
                'adds the object to the output list
                lstOutput.Add(objModelObjectEnumerator.Current)
            End While
        Catch
        End Try
        Return lstOutput
    End Function

The code in line 19 asks the user to select objects. The first parameter is the type of object the user will be selecting. In this example we have used the generic “Object” type. The second parameter is the text that is displayed at the bottom of the screen when prompting the user to select objects.
Blog_Tekla_AskUser2SelectObjects_1

Lines 21~24 loop through the list of objects selected by the user.


Ask User to Select Specific Object Types (Parts, Rebars, Welds, ….):

In the previous example the user was asked to select objects of any kinds. In this example the user will be asked to only select a specific type of object. For example parts:

Imports TSM = Tekla.Structures.Model
Imports TSD = Tekla.Structures.drawing

    ''' <summary>
    ''' Ask the user to select parts from the model
    ''' </summary>
    ''' <returns>The list of selected parts by the user</returns>
    ''' <remarks></remarks>
    Private Function SelectParts() As List(Of TSM.Part)
        Dim objUIPICker As TSM.UI.Picker
        Dim objModelObjectEnumerator As TSM.ModelObjectEnumerator
        Dim lstOutput As List(Of TSM.Part)

        objUIPICker = New TSM.UI.Picker()
        lstOutput = New List(Of TSM.Part)

        Try
            'This line asks the user to select an object from the model
            objModelObjectEnumerator = objUIPICker.PickObjects(Tekla.Structures.Model.UI.Picker.PickObjectsEnum.PICK_N_PARTS, "Select Objects")
            'loops through all the objects selected by the user
            While objModelObjectEnumerator.MoveNext
                'adds the object to the output list
                lstOutput.Add(objModelObjectEnumerator.Current)
            End While
        Catch
        End Try
        Return lstOutput
    End Function

When the function is called the user will only be able to select parts from the model.

Other options include:

  • PICK_N_OBJECTS
  • PICK_N_PARTS
  • PICK_N_REINFORCEMENTS
  • PICK_N_WELDS
  • PICK_N_BOLTGROUPS

Filter Selected Objects:

Assume we set the first parameter to PICK_N_REINFORCEMENTS. The user will only be able to select reinforcements  But lets we are only interested in “Single Rebars”. Using the previous function the user will be able to end up selecting not only Single Rebars but also all other reinforcements as well:

  • Single Rebars
  • Group Reinforcements
  • Meshes

In order to overcome this problem the function below can be used:

Imports TSM = Tekla.Structures.Model
Imports TSD = Tekla.Structures.drawing

   ''' <summary>
    ''' Ask the user to select SingleRebars from the model
    ''' </summary>
    ''' <returns>The list of selected Single Rebars by the user</returns>
    ''' <remarks></remarks>
    Private Function SelectSingleRebars() As List(Of TSM.SingleRebar)
        Dim objUIPICker As TSM.UI.Picker
        Dim objModelObjectEnumerator As TSM.ModelObjectEnumerator
        Dim lstOutput As List(Of TSM.SingleRebar)
        Dim objSingleRebars As TSM.SingleRebar

        objUIPICker = New TSM.UI.Picker()
        lstOutput = New List(Of TSM.SingleRebar)

        Try
            'This line asks the user to select an object from the model
            objModelObjectEnumerator = objUIPICker.PickObjects(Tekla.Structures.Model.UI.Picker.PickObjectsEnum.PICK_N_REINFORCEMENTS, "Select Singel Rebars")
            'loops through all the objects selected by the user
            While objModelObjectEnumerator.MoveNext
                objSingleRebars = TryCast(objModelObjectEnumerator.Current, TSM.SingleRebar)
                If IsNothing(objSingleRebars) = False Then
                    'adds the object to the output list
                    lstOutput.Add(objSingleRebars)
                End If

            End While
        Catch
        End Try
        Return lstOutput
    End Function

Line 23 tries to convert the select object to a single rebar. If it fails the the variable objsinglerebar will be empty. Line 24 checks if the conversion has been successful. If true then single rebar object is added to the output list.

Another scenario would be, only looking for objects of a certain class, name, material, … . This could also be accomplished using the function below. Similar to the example above, the program asks the user to select reinforcements. Among the selected reinforcements only the single rebars are accepted. Another IF statement is used to filter the single rebars whose class is not equal to 5:

Imports TSM = Tekla.Structures.Model
Imports TSD = Tekla.Structures.drawing

 ''' <summary>
    ''' Ask the user to select SingleRebars from the model. Only return rebars with a class of 5
    ''' </summary>
    ''' <returns>The list of selected Single Rebars by the user</returns>
    ''' <remarks></remarks>
    Private Function SelectSingleRebars() As List(Of TSM.SingleRebar)
        Dim objUIPICker As TSM.UI.Picker
        Dim objModelObjectEnumerator As TSM.ModelObjectEnumerator
        Dim lstOutput As List(Of TSM.SingleRebar)
        Dim objSingleRebars As TSM.SingleRebar

        objUIPICker = New TSM.UI.Picker()
        lstOutput = New List(Of TSM.SingleRebar)

        Try
            'This line asks the user to select an object from the model
            objModelObjectEnumerator = objUIPICker.PickObjects(Tekla.Structures.Model.UI.Picker.PickObjectsEnum.PICK_N_REINFORCEMENTS, "Select Singel Rebars")
            'loops through all the objects selected by the user
            While objModelObjectEnumerator.MoveNext
                objSingleRebars = TryCast(objModelObjectEnumerator.Current, TSM.SingleRebar)
                If IsNothing(objSingleRebars) = False Then
                    If objSingleRebars.Class = 5 Then
                        'adds the object to the output list
                        lstOutput.Add(objSingleRebars)
                    End If
                End If

            End While
        Catch
        End Try
        Return lstOutput
    End Function

Line 25 checks the class of the rebar. If it is equal to 5, it will be added to the output list.

You can download the sample files and codes used in this article from the link below:

If you need assistance with your Tekla model, or you are looking for a Tekla Open API programmer to hire feel free to contact me. Also please visit my home page  www.software-solutions-online.com

Tekla Open API: Get Part Length

Tags

, , ,

This article explains how you can get the length of a part using the Tekla Open API.


Step 1:

Add reference to the Tekla.Structures.Model and Tekla.Structures library located in the path “C:\Program Files\Tekla Structures\20.0\nt\bin\plugins” and manually open the tekla model. This has been covered in the article below:


Step 2:

You will need to get reference to the part you wish to get its length. Below are some of the options for achieving this:

1  – Create a new part and keep a reference to the part: Insert Concrete Beam Using VB.Net (Tekla Open API)

2 – Get reference to an existing part in the tekla model: VB.Net Get Reference to Object, Tekla Open API

3- Ask the user to select parts from the model: Tekla Open API: Ask User to Select Objects.


Step 3:

Pass the reference to the part object obtained in step 2 to the function below to get the length of the part:

Imports TSM = Tekla.Structures.Model
Imports TSG = Tekla.Structures.Geometry3d

    ''' <summary>
    ''' Returns the length of the input part
    ''' </summary>
    ''' <param name="objBeam">The part object to return its length</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function Length(ByRef objBeam As TSM.Beam) As Double
        Dim dblOutput As Double
        Dim objPoint1 As TSG.Point
        Dim objPoint2 As TSG.Point
        objPoint1 = objBeam.StartPoint
        objPoint2 = objBeam.EndPoint
        dblOutput = ((objPoint1.X - objPoint2.X) ^ 2 + (objPoint1.Y - objPoint2.Y) ^ 2 + (objPoint1.Z - objPoint2.Z) ^ 2) ^ 0.5
        Return dblOutput
    End Function

Note: If the part has offset values in the X direction the previous function will not return correct results. In order to account for the offsets the function below could be used:

Imports TSM = Tekla.Structures.Model
Imports TSG = Tekla.Structures.Geometry3d

    ''' <summary>
    ''' Returns the length of the input part
    ''' </summary>
    ''' <param name="objBeam">The part object to return its length</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function LengthWithOffsset(ByRef objBeam As TSM.Beam) As Double
        Dim dblOutput As Double
        Dim objPoint1 As TSG.Point
        Dim objPoint2 As TSG.Point
        objPoint1 = objBeam.StartPoint
        objPoint2 = objBeam.EndPoint
        dblOutput = ((objPoint1.X - objPoint2.X) ^ 2 + (objPoint1.Y - objPoint2.Y) ^ 2 + (objPoint1.Z - objPoint2.Z) ^ 2) ^ 0.5
        dblOutput = dblOutput + objBeam.EndPointOffset.Dx - objBeam.StartPointOffset.Dx
        Return dblOutput
    End Function

You can download the sample file and code for this article from the link below:

If you need assistance with your Tekla model, or you are looking for a Tekla Open API programmer to hire feel free to contact me. Also please visit my home page  www.software-solutions-online.com