Guides and Articles

Use this documentation when building your Tekla Structures apps

Code example: Create single rebars and stirrups using system connections (application)

Updated: 2 Oct 2018

This code example creates single bars and stirrups using Tekla Structures system components. System components are intelligent components included in Tekla Structures configuration.

We will use two simple system components. With the help of these components you can increase the intelligence of the application due to their ability to manage notches and openings in the part. 

After downloading the TSOpenAPIExamples package from GitHub (button above), find RebarSample2 example at \Model\Applications\RebarExamples\RebarSample2.

The basic structure of the application is the same as in Code example: Create single rebars and stirrups (application)

This is also a static application. However, unlike basic reinforcement objects the components add intelligence into the model. For example, adding or deleting the notches at beam ends will cause the components to be updated and the reinforcement adjusted.

Watch the video to see how to build the application

 

 

Code explained

The next paragraphs go through parts of the program code which are different from the other example, Code example: Create single rebars and stirrups (application).

Use system component to create longitudinal bars

  1. Create new instance of the class Component. 
    // initialize the component used to model longitudinal bars 
    Component component1 = new Component(); 
    component1.Number = 30000070;  // unique number for "longitudinal rebars" component
  2. Initialize the objects properties. For components you can use the "save as" files and load the base values for all properties and only set the necessary values explicitly. 
    // manage the settings i.e. load standard defaults and set the few important attribute values explicitly
    component1.LoadAttributesFromFile("standard"); 
    component1.SetAttribute("bar1_no", 4);      // number of bars 
    component1.SetAttribute("cc_side", 45.0);   // cover thickness at side 
    component1.SetAttribute("cc_bottom", 45.0); // cover thickness at bottom
  3. Set up the input for the component. The input sequence shall be same as the input when the component is applied interactively. In this case the input contains the part and three points. Point class is included to Tekla.Structures.Geometry3d namespace. 
    // prepare input points for the "longitudinal rebars" component
    Point p1 = new Point(solid.MinimumPoint.X, solid.MinimumPoint.Y, solid.MaximumPoint.Z); 
    Point p2 = new Point(solid.MaximumPoint.X, solid.MinimumPoint.Y, solid.MaximumPoint.Z); 
    Point p3 = new Point(solid.MinimumPoint.X, solid.MinimumPoint.Y, solid.MinimumPoint.Z);
    
    // set up component input sequence 
    ComponentInput input1 = new ComponentInput(); 
    input1.AddInputObject(myPart); 
    input1.AddTwoInputPositions(p1, p2); 
    input1.AddOneInputPosition(p3);   
    
    // Add the input for component  
    component1.SetComponentInput(input1);
  4. Insert the component into Tekla Structures model. 

    // insert new component instance into model 
    component1.Insert();
  5. To add the longitudinal bars also to the top of the beam, you can reuse the same component object. First, modify the input points, moving them to the top of the beam.
    // modify input points
    p1.Y = p2.Y = p3.Y = solid.MaximumPoint.Y;  // "move" points to top of beam
  6.  Reduce the number of bars to two, and insert the component again into Tekla Structures model.
    // modify necessary settings & insert component instance into model
    component1.SetAttribute("bar1_no",2);  
    component1.Insert();

Use system component to create stirrups

  1. Initialize a new component, and set the number property to identify it as a stirrup reinforcement.
    // initialize the component to be used to model stirrups
    Component component2 = new Component();
    component2.Number = 30000067;    // unique number for "Stirrup reinforcement" component
  2. Set input for the component. This time, the input contains the part as the object, a polygon, and two points, to indicate the range to reinforce. 

    // prepare input polygon for the component
    Polygon polygon = new Polygon();
    polygon.Points.Add(new Point(solid.MinimumPoint.X, solid.MaximumPoint.Y, solid.MinimumPoint.Z));
    polygon.Points.Add(new Point(solid.MinimumPoint.X, solid.MaximumPoint.Y, solid.MaximumPoint.Z));
    polygon.Points.Add(new Point(solid.MinimumPoint.X, solid.MinimumPoint.Y, solid.MaximumPoint.Z));
    polygon.Points.Add(new Point(solid.MinimumPoint.X, solid.MinimumPoint.Y, solid.MinimumPoint.Z));
    polygon.Points.Add(new Point(solid.MinimumPoint.X, solid.MinimumPoint.Y, solid.MinimumPoint.Z));
    
    // set up component input sequence
    ComponentInput input2 = new ComponentInput();
    input2.AddInputObject(myPart);
    input2.AddInputPolygon(polygon);
    input2.AddTwoInputPositions(new Point(solid.MinimumPoint.X, 0, 0), new Point(solid.MaximumPoint.X, 0, 0));
    
    // Add the input for component 
    component2.SetComponentInput(input2);
  3. Load the standard attributes, set bar size to 8, and insert the component into Tekla Structures model.

    // mamange the settings i.e. load standard defaults and set the few important attribute values explicitely
    component2.LoadAttributesFromFile("standard");
    component2.SetAttribute("bar1_size", "8");      
    
    // insert new component instance into model
    component2.Insert();

Test example application

You can test the application in Tekla Structures as follows:

  1. In Tekla Structures, open a model.

  2. Create some rectangular beams.

  3. Select the beams in model view.

  4. Open an build RebarSample2.csproj In Microsoft Visual Studio to create the application file. The file is located at \Examples\Model\Applications\RebarExamples\RebarSample2.

  5. Run the application RebarSample2.exe located at \Examples\Model\Applications\RebarExamples\RebarSample2\bin \Debug.

 

The result should look something like this:

Tekla Structures Open API code example create single rebars and stirrups system connections
The application is able to recognize the notches at beam end which causes the longitudinal bar at the bottom being shorter like the stirrup range.