Skip to content

Reinforcement labeling

Abstract

In this article you'll learn how to:

  • label rebars and meshes
  • how to do it for newly created as well as existing reinforcement
  • place rebar or mesh schemas

Rebars

Rebar labels are represented with BarLabel class. There are four main type of labels (see also LabelTypes class):

Label type Scheme
Label with pointer Reinforcement label with pointer
Label with fan Reinforcement label with fan
Label with comb Reinforcement label with comb
Label with dimension line Reinforcement label with dimension line

Class diagram

classDiagram 
direction BT

class BarLabel {
    str AdditionalText
    BarLabelPointerProperties PointerProperties
    bool ShowTextPointer
    list[int] VisibleBars
    TextProperties TextProperties
}
class LabelType{
    <<Enumeration>>
    LabelWithComb
    LabelWithDimensionLine
    LabelWithFan
    LabelWithPointer
}
class BarLabelProperties{
    bool ShowPositionNumber
    bool ShowBarDiameter
    bool ShowBarDistance
    bool ShowBarCount
    bool ShowSteelGrade
}
class TextProperties{
    eTextAlignment Alignment
    int BackgroundColor
    int Font
}
class BarLabelPointerProperties {
    int Color
    float CombLineAngle
    int EndSymbol
    float EndSymbolSize
    int Pen
    bool ShowTextPointerEndSymbol 
    int Stroke
}

LabelType "1" --o BarLabel
BarLabelProperties "1" --o BarLabel
BarLabelPointerProperties "1" --o BarLabel
TextProperties "1" --o BarLabel

The composition of BarLabel is shown on the UML diagram above:

Info

BarLabel can be used to label only placements represented with BarPlacement i.e., linear and rotational ones! Currently, it is not possible to label other placements, such as CircularAreaElement or ExtrudeBarPlacement.


BarLabel should not be confused with LabelElement, which represents general label texts in ALLPLAN, whereas BarLabel is an object dedicated for rebars.

Define bar label

First, define what information the label should include. This is done with BarLabelProperties:

label_properties                    = AllplanReinf.BarLabelProperties()
label_properties.ShowPositionNumber = True
label_properties.ShowBarDiameter    = True
label_properties.ShowBarDistance    = False
...

Next, define the styling of the label with TextProperties:

text_properties                 = AllplanBasisElements.TextProperties()
text_properties.Alignment       = AllplanBasisElements.TextAlignment.eRightMiddle
...

Next, define the styling of the leader with BarLabelPointerProperties. Skip this step if your label does not include any leader (ShowTextPointer set to False):

pointer_properties = AllplanReinf.BarLabelPointerProperties()
pointer_properties.EndSymbol = 1
pointer_properties.Color = 1

# options relevant only for label with comb
pointer_properties.CombLineByLength = True #(1)!
pointer_properties.CombLineValue = 200 #(2)!
pointer_properties.CombLineAngle = 45
...
  1. When set to True, the comb tines will have a fixed length, defined in combLineValue. Otherwise, the combLineValue will be the distance between labeled rebar and the tip of the comb tine
  2. This length/distance is given in millimeter on a print layout! It will therefore vary depending on the scale set in DF.

Tip

For the leader styling, you can use a dedicated parameter of value type ReinfBarLabelPointer. Here you can learn more.

Now you can construct BarLabel. The definition varies, depending on the label type:

Reinforcement label with pointer

This type of label is recommended, when the rebar shape is displayed in its real dimensions (view direction is perpendicular to the rebar plane). This type of label consists of the label text and (optionally) a leader. There are two ways to define it:

By providing the reference point of the label in the global coordinate system (as a Point2D):

label = AllplanReinf.BarLabel(
    reinforcementType = AllplanReinf.Bar,
    type              = AllplanReinf.LabelType.LabelWithPointer,
    positionNumber    = 1,
    labelProp         = label_properties,
    labelPoint        = AllplanGeo.Point2D(...), #(1)!
    angle             = AllplanGeo.Angle())
  1. The placement point. The Alignment you set in text_properties will be consider.

    Reinforcement label ref points

By providing an offset from a point located on a specified leg of the labeled rebar (as a Vector2D):

label = AllplanReinf.BarLabel(
    reinforcementType = AllplanReinf.ReinforcementType.Bar,
    type              = AllplanReinf.LabelType.LabelWithPointer,
    positionNumber    = 1,
    labelProp         = label_properties,
    shapeSide         = 3, #(1)!
    shapeSideFactor   = 0.5, #(2)!
    labelOffset       = AllplanGeo.Vector2D(-123, 123),
    angle             = AllplanGeo.Angle())
  1. The label will be created relative to the 3rd leg. Leg numerations starts with 1 and hooks are considered as legs.

  2. This means, that the offset is calculated from the middle of the leg (indicated by the red point on the image). According to the vector in label_offset, the label will be created 200mm to the left from this point (the offset vector is indicated by the blue arrow on the image).

    reinforcement label with pointer by offset

Reinforcement label with dimension line

This type of label is recommended for linear placements shown on UVS, where the placement line is displayed in its real dimension. In other words: the view direction is perpendicular to the placement line.

Failure

Do not create this kind of label in a UVS, which view direction is parallel to the placement line, as this will create damaged data in the DF!

Construct the label object like so:

label = AllplanReinf.BarLabel(
    reinforcementType    = AllplanReinf.Bar,
    type                 = AllplanReinf.LabelWithDimensionLine,
    positionNumber       = 1,
    labelProp            = label_properties,
    bDimLineAtShapeStart = False, #(1)!
    dimLineOffset        = 200)  #(2)!
  1. Assuming the placement line goes in X+ direction, setting this argument to False will create the dimension line above the placement.
  2. This is the distance between the placement line and the dimension line:

    Label with dimension line offset

Reinforcement label with fan

This type of label is recommended when labeling multiple rebars in a UVS. But, unlike label with pointer:

  • multiple leaders (a fan of leaders) to each displayed rebar are generated instead of just single one
  • it is possible to place the label only by a point in global coordinate system, and not by an offset to a rebar leg

Construct the label object like so:

label = AllplanReinf.BarLabel(
    reinforcementType = AllplanReinf.Bar,
    type              = AllplanReinf.LabelType.LabelWithFan,
    positionNumber    = 1,
    labelProp         = label_properties,
    labelPoint        = AllplanGeo.Point2D(...), #(1)!
    angle             = AllplanGeo.Angle())
  1. The placement point. The Alignment you set in text_properties will be consider.

    Reinforcement label ref points

Example on GitHub

The entire implementation is shown in the example LabelWithFan ( PYP | PY).

Reinforcement label with comb

This type of label is recommended, when labeling longitudinal bars which are visible in a UVS as points. It is a mixture of a fan and a dimension line:

  • like the fan, it has multiple leaders
  • like the dimension line, it is placed by offset to the placement line

Failure

Do not create this kind of label in a UVS, which view direction is parallel to the placement line, as this will create damaged data in the DF!

Construct the label object like so:

label = AllplanReinf.BarLabel(
    reinforcementType    = AllplanReinf.Bar,
    type                 = AllplanReinf.LabelType.LabelWithComb, #(1)!
    positionNumber       = 1,
    labelProp            = label_properties,
    pointerProp          = pointer_properties,
    bDimLineAtShapeStart = True,
    dimLineOffset        = 200)
  1. This will create a comb with a number of tines equal to the number of labeled rebars. Alternatively, we can create a comb pointing only the first and last two or three rebars. See the documentation of the class LabelType to see all possible options.

Now, apply TextProperties, BarLabelProperties BarLabelPointerProperties or any other properties:

label.TextProperties = text_props

pointer_props = BarLabelPointerProperties(...)

label.ShowTextPointer = True    #(1)!
label.PointerProperties = pointer_props

label.VisibleBars = [-1, 0, 1] #(2)!
label.LabelOffset = AllplanGeo.Vector2D(0,200) #(3)!
label.ShowAllBars(True) #(4)!
  1. For a label with comb, this option is irrelevant.
  2. This will result in only the first, last and the middle rebar being displayed. Relevant only for labels with comb and dimension line.
  3. The label can be moved away from its initial position by a vector.

    Info

    Label with dimension line with label at the end

    Setting the TextProperties.Alignment in the text_props object to eLeftMiddle or eRightMiddle results in the Label being placed at the end or start of the dimension line respectively, as shown on the image above. In this case, the method SetLabelOffset will have no influence on the position of the label in relation to the dimension line

  4. Relevant for a label with dimension line. True will show all rebar markers on the dimension line, like this:

    Reinforcement label with dimension line with all markers

Example on GitHub

Following examples show full implementation of the above mentioned label types:

Meshes

Mesh label

Mesh labels are represented with MeshLabel class. Unlike for rebar labels, there is only one label type for meshes and its definition is similar to rebar label with pointer.

Class diagram

classDiagram 
direction BT

class MeshLabel {
    Point2D LabelPoint
    MeshLabelPointerProperties PointerProperties
    Point2D PointerStartPoint
    bool ShowTextPointer
    ReinforcementLabelTextProperties TextProperties
}

class MeshLabelProperties{
    bool ShowMeshCount
    bool ShowMeshDimensions
    bool ShowMeshType
    bool ShowPositionNumber
}
class ReinforcementLabelTextProperties{
    TextAlignment Alignment
    int Font
    int TextAngle
    int TextColor
}
class MeshLabelPointerProperties {
    int Color
    int EndSymbol
    float EndSymbolSize
    int Pen
    bool ShowTextPointerEndSymbol
    int Stroke
}

MeshLabelProperties "1" --o MeshLabel
MeshLabelPointerProperties "1" --o MeshLabel
ReinforcementLabelTextProperties "1" --o MeshLabel

The composition of MeshLabel is shown on the UML diagram above:

Define mesh label

First, define what information the label should include. This is done with MeshLabelProperties:

label_properties                    = AllplanReinf.MeshLabelProperties()
label_properties.ShowPositionNumber = True
label_properties.ShowMeshType       = True
label_properties.ShowMeshDimensions = False
...

Next, define the styling of the label with ReinforcementLabelTextProperties. Skip this step, if you want to leave the settings to default:

text_properties           = AllplanReinf.ReinforcementLabelTextProperties()
text_properties.Alignment = AllplanBasisElements.TextAlignment.eRightMiddle
...

Next, define the styling of the leader with MeshLabelPointerProperties. Skip this step if your label does not include any leader (ShowTextPointer set to False) or you are fine with the default settings:

pointer_properties = AllplanReinf.MeshLabelPointerProperties()
pointer_properties.EndSymbol = 1
pointer_properties.Color = 1
...

Tip

For the leader styling, you can use a dedicated parameter of value type ReinfMeshLabelPointer. Here you can learn more.

Next, create the MeshLabel object

There are two ways to define it:

By providing the reference point of the label in the global coordinate system (as a Point2D):

label = AllplanReinf.MeshLabel(
    positionNumber = 1,
    labelProp      = label_properties,
    labelPoint     = AllplanGeo.Point2D(...))
  1. The placement point. The Alignment you set in text_properties will be consider.

    Reinforcement label ref points

By providing an offset from a point located on a specified leg of the labeled rebar (as a Vector2D):

label = AllplanReinf.MeshLabel(
    positionNumber  = 1,
    labelProp       = label_properties,
    shapeSide       = 3, #(1)!
    shapeSideFactor = 0.5, #(2)!
    labelOffset     = AllplanGeo.Vector2D(-123, 123))
  1. The label will be created relative to the 3rd leg. Leg numerations starts with 1 and hooks are considered as legs.

  2. This means, that the offset is calculated from the middle of the leg (indicated by the red point on the image). According to the vector in label_offset, the label will be created 200mm to the left from this point (the offset vector is indicated by the blue arrow on the image).

    reinforcement label with pointer by offset

Finally, apply the text and leader properties (if you've defined these):

label.ShowTextPointer   = True
label.PointerProperties = pointer_properties
label.TextProperties    = text_properties

Labeling new elements

Follow these instructions, when you would like to create reinforcement elements and label them (e.g. in a UVS) at one go. If your goal is to only label existing reinforcement (e.g. created with another PythonPart or witch native ALLPLAN functionality), scroll further down .

To label reinforcement elements on a specific UVS, put the bar labels in a BarLabelList and mesh labels in MeshLabelList and assign them to the properties BarLabels and MeshLabels respectively of this specific uvs instance:

view_element = AllplanBasisEle.ViewSectionElement()
...
view_element.BarLabels = AllplanReinf.BarLabelList([bar_label_1, ...])
view_element.MeshLabels = AllplanReinf.MeshLabelList([mesh_label_1, ...])

To label reinforcement elements on the original position where it has been placed (not within any UVS), append the label to the instance of BarPlacement or MeshPlacement using the SetLabel() method:

placement_to_label.SetLabel(label, AllplanEleAdapter.AssocViewElementAdapter())

Labeling existing elements

Follow these steps to label existing reinforcement elements. I.e. elements, that were created using native ALLPLAN functions or other PythonPart.

Warning

Currently it is only possible to label rebar elements, and not meshes!

  1. Get the BaseElementAdapter of the rebar representation line. Typically by implementing a selection.

    Info

    • To learn more about what an element adapter actually is, refer to this article .
    • To learn how to implement a selection, refer to this article .
    • To get adapters of all the elements in the current drawing file, call SelectAllElements()

    The element adapter you'll need must be of type BarsRepresentationLine_TypeUUID. Here's how a filter function may look like:

    def bars_representation_line_filter(element: AllplanElementAdapter.BaseElementAdapter) -> bool:
        return element.GetElementAdapterType().Guid == AllplanElementAdapter.BarsRepresentationLine_TypeUUID
    
  2. Extract the BarsRepresentation object from the element adapter by calling GetElement():

    bars_representation = AllplanBaseElements.GetElements(element_adapter)
    
  3. Create a label, as explained above . When constructing BarLabel object, use the position number from the selected placement, like:

    label = AllplanReinf.BarLabel(
        reinforcementType = AllplanReinf.Bar,
        type              = AllplanReinf.LabelType.LabelWithFan,
        positionNumber    = bars_representation.GetBarPlacement().PositionNumber,
        labelProp         = label_properties,
        labelPoint        = AllplanGeo.Point2D(...),
        angle             = AllplanGeo.Angle())
    
  4. Attach the label to the bars representation instance you want to label. Specifically, to the property Label

    bars_representation.Label = label
    
  5. Create a label

    In a script object, add the BarsRepresentation instance with the assigned label to the ModelEleList which you will then pass to the CreateElementResult, like:

    def execute(self) -> CreateElementResult:
        model_ele_list = ModelEleList()
        model_ele_list.append(bars_representation)
        return CreateElementResult(model_ele_list)
    

    Create a python list and add the BarsRepresentation instance with the assigned label to it. Then use PythonPartTransaction to create the labels.

    labeled_bars = [bars_representation, ...]
    
    pyp_transaction = PythonPartTransaction(self.document)
    pyp_transaction.execute(
        AllplanGeo.Matrix3D(),
        self.coord_input.GetViewWorldProjection(),
        labeled_bars,
        self.modification_ele_list
    )
    

Example on GitHub

LabelBarPlacementWithDimLine ( PYP | PY) is an advanced example showcasing the creation of label with dimension line for existing rebar elements

Schemas

Bar schema

Warning

Currently it is only possible to create bending schemas for newly created rebars.

It's not possible to create a schema for a mesh and for an existing rebar.

A bending schema can be created for all placements of a specific mark number (full schema) or for specific placements of that mark number (partial schema). To create a schema for a rebar position, follow these steps:

  1. Create an instance of BarSchema and set up the options:

    schema = AllplanReinf.BarSchema(
        positionNumber = 1, #(1)!
        placementPoint = AllplanGeometry.Point2D(...)
    )
    
    schema.AngleDimensioning   = True
    schema.Dimensioning        = False
    schema.SegmentDimensioning = True
    ...
    
    1. This is the script-internal mark number, and not the actual mark number visible to the user after creation of the reinforcement.
  2. If you want to create a partial schema (include only specific placements, for full schema you can skip this step), associate the schema with the desired instances of BarPlacement using the method SetPartialSchema():

    placement.SetPartialSchema(schema)
    
  3. Add the schema instance to the list of model elements you want to create:

    def execute(self) -> CreateElementResult:
        model_ele_list = ModelEleList()
        model_ele_list.append(placement)
        model_ele_list.append(schema)
        return CreateElementResult(model_ele_list)
    
    model_elements = [schema, placement]
    
    pyp_transaction = PythonPartTransaction(self.document)
    pyp_transaction.execute(
        AllplanGeo.Matrix3D(),
        self.coord_input.GetViewWorldProjection(),
        model_elements,
        self.modification_ele_list
    )
    

Warning

When creating a full schema with native functionality, ALLPLAN checks whether there is already a schema for the mark number and if so, prevents the user for creating a duplicate. This check is not done when creating schemas by the API. You have to check it by yourself.

Example on GitHub

Full implementation is shown in the example BarSchema ( PYP | PY)

Placeholder