Exercise 4: Create rebars to pad footings
You will learn how to select objects from the model and then use an enumerator to loop through those objects.
After downloading the TSOpenAPISelfLearningExercises package from GitHub (button above), find the example code for this exercise at \Exercise4-Rebars\ folder.
Before you start, Open the project that you created in exercise 3.
Create rebars to pad footings
Modify the last exercise so that you add two more methods:
-
Create rebar on the given object to given position using FootingSize from dialog.
-
Loop through all footings and create rebar on those.
Follow these steps to create your application:
-
Create a textbox to the form for the user to give the size of the footings. Initialize the value to 1500.
-
Get the size of the footing from the textbox.
-
Create a method that adds the circular rebars around the footing. Use the RebarGroup and Polygon classes. Use these values (remember to localize needed values):
//Polygon: //Use pad footings corner points as polygon points, remember that the end point is same as the start point. //Rebar: Class = 3 Name = "FootingRebar" Father = PadFooting Grade = "A500HW" Size = "12" Radiusvalues.Add(40.0) SpacingType = SPACING_TYPE_TARGET_SPACE Spacings.Add(100.0) ExcludeType = EXCLUDE_TYPE_BOTH NumberingSeries.StartNumber = 0 NumberingSeries.Prefix = "Group" OnPlaneOffsets.Add(25.0) FromPlaneOffset = 40 //StartPoint and EndPoint, use pad footings position and height.
- Add hooks to make the rebar stronger. Use these values:
StartHook.Shape = HOOK_90_DEGREES EndHook.Shape = HOOK_90_DEGREES OnPlaneOffsets.Add(10.0) OnPlaneOffsets.Add(25.0)
- Add a new button to the form that creates rebars. The method should include the following:
-
Select all objects from model to enumerator (ModelObjectEnumerator).
-
Loop through enumerator.
-
See if an object is a pad footing, then create rebar group to that using the pad footings StartPoint as position.
-
Commit changes to Tekla Structures
-
-
Test your application.
The result should look similar to this: