Skip to content

Format properties

Common properties

Common properties

CommonProperties class represents format properties common for basically all elements inside a DF, such as:

  • Pen thickness, stroke and color, with which the geometrical object should be drawn, represented with an ID number.
  • Layer, which the object belongs to, also represented by a number.
  • Whether the pen thickness, stroke or color should be taken from layer definition or from the object itself (if so, the pen thickness, stroke and color of the object are ignored).
  • Should the object be printable (see property construction line on the figure below).
  • Draw order (see image below sequence) - in case of overlapping, the object with higher draw order will be visible.

Tip

If you want the user to set these properties, define a parameter in the PYP file as described here and get its value in the script, like:

common_props = build_ele.YourCommonPropertiesParameter.value

To get the common properties currently set in ALLPLAN, call GetCurrentCommonProperties():

>>> AllplanSettings.AllplanGlobalSettings.GetCurrentCommonProperties()
CommonProperties(
   Color                       (1)
   Layer                       (0)
   Stroke                      (1)
   Pen                         (1)
   ...
   DrawOrder                   (0))

Applying on newly created elements

The abstraction of all elements, that can be created in a DF is AllplanElement (learn more about them in this article) which has the SetCommonProperties method. So to apply common properties on any element, call:

column = ColumnElement(column_props, placement_point)
column.SetCommonProperties(common_props)

In case of many ModelElement2D or ModelElement3D (i.e. lines, curves, 3d objects) instead of applying the properties on each element individually, you can create a ModelEleList and append the elements to it using dedicated methods:

from TypeCollections.ModelEleList import ModelEleList
...
model_ele_list = ModelEleList(common_props)
model_ele_list.append_geometry_2d(line)  #(1)!
model_ele_list.append_geometry_3d(polyhedron)  #(2)!
  1. When the line is a Line2D, this call creates a ModelElement2D, applies common_props to it, and appends it to the list. 3 in 1
  2. The same can be done with 3D elements, like Polyhedron3D

When at the end of your script, you are creating a PythonPart element (a parametric container encapsulating the lines/3d objects/etc... which we describe in more detail in this article) you may want to apply the properties to the PythonPart container itself. To do this, use the common_props already when you construct the PythonPartUtil:

from PythonPartUtil import PythonPartUtil
...
python_part_util = PythonPartUtil(common_prop) #(1)!
  1. In a PythonPart container the common properties of the encapsulated model elements become less relevant.

Read and modify existing elements

Any element that already exists in the DF is represented with a BaseElementAdapter. This is what you get as a result of element selection. You can read the common properties directly by calling GetCommonProperties()

>>> element_adapter.GetCommonProperties()
CommonProperties(
   Color                       (1)
   Layer                       (3800)
   Stroke                      (1)
   Pen                         (1)
   ...
   DrawOrder                   (0))

Modifying common properties of BaseElementAdapter is currently limited to the layer. For that purpose, you can call ChangeLayer(), like:

AllplanBaseElements.ElementsLayerService.ChangeLayer(element_adapters, "KO_ALL01") #(1)!
  1. You have to provide a BaseElementAdapterList and the short name of the desired layer. If you only have an ID or the long name, use the methods from LayerService to establish the short name.

Example on GitHub

See how it's done in the example ModifyFormatProperties ( PYP | PY).

To modify other properties, you must perform a specific object modification. Once you get the AllplanElement object out of the element adapter, the procedure is the same as described above

Tip

In this article you can learn how to place the controls for changing common properties on the property palette.

To learn how to place individual controls for pen, stroke, color or layer, refer to this article.

Surface element properties

Surface elements

Elements like architectural components, but also regular 3d objects can be assigned with a surface element: hatching, pattern, filling, bitmap or a face style. This will result in these graphics being shown in a UVS section, when the clipping plane cuts through the element.

Applying on architectural component

As described in detail in this article, every architecture component has its specific properties (e.g. ColumnElement have ColumnProperties). The abstraction of all these specific properties is the class ArchBaseProperties which has SurfaceElementProperties. See the UML diagram below.

classDiagram 
direction BT
    class ArchElement

    class ColumnElement {
        +Properties
        +PlacementPoint
    }

    class ColumnProperties

    class ArchBaseProperties {
        +SurfaceElementProperties
    }

    class SurfaceElementProperties {
        +BitmapSelected bool
        +BitmapID str
        +FaceStyleSelected bool
        +FaceStyleID int
        +FillingSelected bool
        +FillingID int
        +HatchSelected bool
        +HatchID int
        +PatternSelected bool
        +PatternID int
        +UseAreaInGroundplan bool
    }

    ColumnElement --|> ArchElement
    ColumnProperties --o ColumnElement
    ColumnProperties --|> ArchBaseProperties
    SurfaceElementProperties  --o ArchBaseProperties

    style SurfaceElementProperties stroke:,stroke-width:2px

So to apply a hatching/pattern/filling/etc... on an architectural component, construct SurfaceElementProperties and assign it to the properties, and these to the element, like:

surface_ele_props = AllplanArchElements.SurfaceElementProperties()
surface_ele_props.HatchingSelected = True
surface_ele_props.HatchingID = 303
surface_ele_props.UseAreaInGroundplan = True

column_prop = AllplanArchElements.ColumnProperties()
column_prop.SurfaceElementProperties = surface_ele_props

column = AllplanArchElements.ColumnElement(column_props, placement_point)

Tip

If you want the user to have the control over the surface element, add an appropriate parameter to your PYP file and get the SurfaceElementProperties object from it, like:

column_prop = AllplanArchElements.ColumnProperties()
column_prop.SurfaceElementProperties = build_ele.YourSurfaceElementProperties.value

column = AllplanArchElements.ColumnElement(column_props, placement_point)

Warning

Be aware, that not all combination are possible. E.g. you can combine a hatching with a filling, but not with a bitmap. We recommend to use the surface element properties parameter as it will handle these constraints for you.

Example on GitHub

Refer to the following example Column ( PYP | PY)

Placeholder