Skip to content

Common properties

Common properties

Every geometrical object in Allplan has format properties like line thickness, type and color. In Python API, they are represented with CommonProperties class. This class contains information about:

  • 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.

Global settings

The class AllplanGlobalSettings gives the access the current setting in Allplan. To get the current settings regarding common properties, use the method GetCurrentCommonProperties.

>>> AllplanSettings.AllplanGlobalSettings.GetCurrentCommonProperties()
CommonProperties(
   Color                       (1)
   Layer                       (0)
   Stroke                      (1)
   Pen                         (1)
   ColorByLayer                (0)
   PenByLayer                  (0)
   StrokeByLayer               (0)
   HelpConstruction            (0)
   DrawOrder                   (0))

Reading properties

The result of an element selection is a BaseElementAdapter object. You can get the common properties directly from it using the GetCommonProperties

>>> element_adapter.GetCommonProperties()
CommonProperties(
   Color                       (1)
   Layer                       (3800)
   Stroke                      (1)
   Pen                         (1)
   ColorByLayer                (0)
   PenByLayer                  (0)
   StrokeByLayer               (0)
   HelpConstruction            (0)
   DrawOrder                   (0))

Modifying properties

Currently, modifying common properties using BaseElementAdapter is limited only to modifying the layer. For that purpose you can use the ChangeLayer method of the ElementsLayerService.

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

See how it's done in the example ModifyFormatProperties located in:

  • …\etc\Examples\PythonParts\InteractorExamples\GeneralModification\ModifyFormatProperties.pyp
  • …\etc\PythonPartsExampleScripts\InteractorExamples\GeneralModification\ModifyFormatProperties.py

To modify other properties, you must perform a specific object modification. When you get a python object out of the element adapter, it will most likely be a subclass of AllplanElement, so you can call the SetCommonProperties method on it.

Tip

In this article you can learn how to place the controls for common properties on your property palette all-in-one.

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