v2.0
 
Reinforcing Mesh Style Template

Let's learn how to create the template for the Reinforcement unit styleReinforcing mesh.

Technical Task

Before creating a style template, we will take a look at the technical task, according to which we will create a file of parameters in JSON format and write a script in Lua.

The technical task can be shown through a drawing that illustrates the parameters and a table with their corresponding values.

Reinforcing mesh drawing

Symbolic representation :

Reinforcing mesh symbolic representation

Group/Parameter Parameter type Default value Min Max
Dimensions
Length Length 1000 200 12000
Width Length 1000 200 12000
LongitudinalReinforcement
RebarStyleId Id
Step Length 100 0 9999999
FreeEnd Length 25 0 9999999
TransverseReinforcement
RebarStyleId Id
Step Length 100 0 9999999
FreeEnd Length 25 0 9999999

Description of parameters

According to the technical task, we create a parameters file using the structure detailed in the Style Templates of Reinforcement Units.

See the resulting file in the Reinforcing Mesh and Ports file.

Script

Getting parameters and declaring variables

First, we get the parameter values the user sets in the reinforcement unit style editor. Then we declare the variables.

local parameters = Style.GetParameterValues()
local length = parameters.Dimensions.Length
local width = parameters.Dimensions.Width
local longRebarStyleID = parameters.LongitudinalReinforcement.RebarStyleId
local longFreeEnd = parameters.LongitudinalReinforcement.FreeEnd
local longStep = parameters.LongitudinalReinforcement.Step
local transRebarStyleID = parameters.TransverseReinforcement.RebarStyleId
local transFreeEnd = parameters.TransverseReinforcement.FreeEnd
local transStep = parameters.TransverseReinforcement.Step
The Style namespace contains functions to set geometry, get parameters and ports.
Definition GeometryStyleMethodRegistrator.h:12

Creating a reinforcing mesh model

According to the technical task, the reinforcement mesh is composed of longitudinal and transverse reinforcing bars, which are repeated with a step defined by the user and an additional step calculated according to the length and width of the mesh and the free end of the reinforcement.

To set the position of rebars, we need to know the radius of the rebar, for its calculation we will create a function:

function GetRebarRadius(rebarStyleId)
local style = Project.GetRebarStyle(rebarStyleId)
local parameters = CastToParameterContainer(style)
return parameters:GetParameterValues().RebarDiameter / 2
end
ParameterContainer CastToParameterContainer(Entity entity)
Casts an entity to parameter container, if casting is allowed.
The Project namespace contains functions to get styles.

To shift objects by vector, let's create a function:

function ShiftedByVector(object, vector, length)
return object:Shift(vector:GetX() * length, vector:GetY() * length, vector:GetZ() * length)
end

We will also create a function to lay out the reinforcement for a given length along one direction:

function CreateRebarLayoutWithFreeEnd(rebarStyleId, curve3d, fullLength, freeEnd, step, vector)
local rebarRadius = GetRebarRadius(rebarStyleId)
-- When calculating the length, we take into account the full length of the mesh as well as the lengths of the free ends
local length = fullLength - freeEnd * 2 - rebarRadius * 2
-- To calculate the number of rebars we round the value
local number = math.floor(length / step)
-- Determine if an additional step is required
local lastStep = length - step * number
if lastStep < rebarRadius * 2 and lastStep ~= 0 then
number = number - 1
end
ShiftedByVector(curve3d, vector, freeEnd + rebarRadius)
-- Create a group of rebars with equal steps
Style.AddRebarSet(rebarStyleId, curve3d, vector, step, number + 1)
-- If an additional step is required, add a rebar.
if lastStep ~= 0 then
ShiftedByVector(curve3d, vector, length)
Style.AddRebar(rebarStyleId, curve3d)
end
end

Next, we set variables to specify the rebar height position:

-- Height of placement of longitudinal rebars
local longHeight = GetRebarRadius(longRebarStyleID)
-- Height of placement of transverse rebars
local transHeight = GetRebarRadius(longRebarStyleID) * 2 + GetRebarRadius(transRebarStyleID)

Define the curve and vector for the longitudinal rebars:

local longRebarLine = CreateLineSegment3D(Point3D(-length / 2, -width / 2, longHeight),
Point3D(length / 2, -width / 2, longHeight))
local longVector = Vector3D(0, 1, 0)
Three-dimensional point.
Three-dimensional vector.
Curve3D CreateLineSegment3D(Point3D startPoint, Point3D endPoint)
Creates line segment.

Define the curve and vector for the transverse rebars:

local transRebarLine = CreateLineSegment3D(Point3D(-length / 2, -width / 2, transHeight),
Point3D(-length / 2, width / 2, transHeight))
local transVector = Vector3D(1, 0, 0)

Using the CreateRebarLayoutWithFreeEnd() function, we create the longitudinal and transverse rebars of the mesh:

CreateRebarLayoutWithFreeEnd(longRebarStyleID, longRebarLine, width, transFreeEnd, longStep, longVector)
CreateRebarLayoutWithFreeEnd(transRebarStyleID, transRebarLine, length, longFreeEnd, transStep, transVector)

Creating a symbolic representation of a reinforcing mesh

To create a symbolic representation of the reinforcing mesh, it is necessary to create a rectangle with a diagonal line. Let's create a function that allows to create it from a set of geometric primitives:

function MakeSymbolicGeometrySet()
local rectangle = CreateRectangle2D(Point2D(0, 0), 0, length, width)
local line = CreateLineSegment2D(Point2D(-length / 2, -width / 2), Point2D(length / 2, width / 2))
local geometrySet = GeometrySet2D()
geometrySet:AddCurve(rectangle)
geometrySet:AddCurve(line)
return geometrySet
end
A set of geometric primitives that can include 2D curves and fills.
Two-dimensional point.
Curve2D CreateRectangle2D(Point2D center, double angle, number width, number height)
Creates a rectangle as composite curve of four line segments.
Curve2D CreateLineSegment2D(Point2D startPoint, Point2D endPoint)
Creates a line segment based on two points.

Next, set a variable to specify the height position of the symbol:

local symbolicHeight = GetRebarRadius(longRebarStyleID) + GetRebarRadius(transRebarStyleID)

Now we create a symbolic geometry, define its position and set it for the reinforcement unit style:

local symbolicGeometry = ModelGeometry()
local symbolicGeometryPlacement = Placement3D(Point3D(0, 0, symbolicHeight), Vector3D(0, 0, 1), Vector3D(1, 0, 0))
symbolicGeometry:AddGeometrySet2D(MakeSymbolicGeometrySet(), symbolicGeometryPlacement)
Style.SetSymbolicGeometry(symbolicGeometry)
Model geometry.
Local coordinate system in three dimensional space.

For a full style template sample, see link.