Tekla Open API: Move Part

This article explains how you can move existing parts in a Tekla Structure model using the Tekla Open API in VB.Net.


Step 1:

Add reference to the Tekla.Structures.Model and Tekla.Structures library located in the path “C:Program FilesTekla Structures20.0ntbinplugins” 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 move. 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:

Using the code below you will be able to move the part 2m in the X direction:

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

    ''' <summary>
    ''' Moves the input part, 2m in the X direction
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub MovePart(ByRef objBeam As TSM.Beam)
        Dim objPoint1 As TSG.Point
        Dim objPoint2 As TSG.Point
        Dim appTekla As TSM.Model

        appTekla = New TSM.Model
        'get the current part coordinates
        objPoint1 = objBeam.StartPoint
        objPoint2 = objBeam.EndPoint

        'move the point 2m in the X directoin
        objPoint1.X += 2000
        objPoint2.X += 2000

        'assign the new points to the part again
        objBeam.StartPoint = objPoint1
        objBeam.EndPoint = objPoint2

        'apply changes
        appTekla = Nothing

    End Sub

Lines 15 and 16 get the current start and end coordinates of the part. Lines 19 and 20 create new coordinates 2m in the X direction. Lines 23 and 24 assign the new coordinates to the part. Lines 27 and 28 apply the changes to 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

Leave a Reply

Your email address will not be published. Required fields are marked *