Code example: Manage work planes

Updated: 13 May 2019

This Tekla Open API code example has two methods that manage the work plane in Tekla Structures model. With help of this code example it is easier to place parts accurately when modeling sloped parts.

  • The first method shows how to change the work plane according to a part selected from the Tekla Structures model.
  • The second method sets the work plane parallel to the XZ plane in Tekla Structures model.

Note:
Unfortunately, the whole source code of this example is not available for downloading. You can copy-paste the code snippets to your own project. 

Set work plane to a part

The following method changes the work plane according to a part selected from the Tekla Structures model.

public static void setUCStoPart()
{
    //Create a new instance from the picker class and ask the user to pick a part
    Tekla.Structures.Model.UI.Picker picker = new Tekla.Structures.Model.UI.Picker();
    ModelObject modelObject = picker.PickObject(Tekla.Structures.Model.UI.Picker.PickObjectEnum.PICK_ONE_PART);

    // Get the coordinate system of the part
    TSG3D.CoordinateSystem PartCoordinate = modelObject.GetCoordinateSystem();

    //Create a new transformation plane defined based on the parts coordinate system
    TransformationPlane PartPlane = new TransformationPlane(PartCoordinate);

    //Set the current transformation plane to the part plane.
    model.GetWorkPlaneHandler().SetCurrentTransformationPlane(PartPlane);

    model.CommitChanges();
}

 

In this example, user picked the footing located at the intersection of grid lines B and 1. The result should look similar to this:

Tekla structures Open API code example manage work planes part

Set work plane to XZ plane

The following method sets the work plane pararell to the XZ plane in Tekla Structures model.

public static void setUCStoXZplane()
{
    //The transformation plane to be set as the current transformation plane
    model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane());

    //Define origin and two vectors to set the UCS to the XZ plane
    TSG3D.Point Origin = new TSG3D.Point(0, 0, 0);  //Represents the origin
    TSG3D.Vector X = new TSG3D.Vector(1, 0, 0);     //Represents x-axis
    TSG3D.Vector Y = new TSG3D.Vector(0, 0, 1);     //Represents y-axis

    //Create a new transformation plane defined by the given origin and two vectors
    TransformationPlane XZ_Plane = new TransformationPlane(Origin, X, Y);

    //Setting the current transformation plane to be (XZ plane)
    model.GetWorkPlaneHandler().SetCurrentTransformationPlane(XZ_Plane);
    model.CommitChanges();
}

 

The result should look similar to this:

Tekla structures Open API code example manage work planes xz

Was this helpful?
The feedback you give here is not visible to other users. We use your comments to improve the content.