Skip to content

Element modification

Modifying the existing elements in the DF can be done in two ways.

  • General modification


    Modifying some generic data, like attributes or format properties, is easy as it requires only a BaseElementAdapter, but limited to certain types of operations.

    Learn how.

  • Specific modification


    Manipulation of specific element data gives you more flexibility, but it requires getting the instance of a specific python class and is therefore limited to only certain types of elements.

    Learn how.

General modification

Allplan Python API offers some possibilities of modifying elements in a generic way. Generic means in this case performing operations, that can be applied to any element, like moving, rotating or changing format properties.

Transformation

The function CopyElements can be used to copy existing elements. The function needs a list of element adapter as argument.

Tip

The fromPoint argument can be by default set to Point3D(). It becomes relevant only if the elements need to be rotated. In this case the fromPoint is used as the rotation center point.

Example

For a complete usage see the example CopyElements located in:

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

Specific modification

To modify specific properties of an element, you have to get the python object representing this element in the API out of the BaseElementAdapter. We explain, how to do it here.

Once you have the python object, you can modify any of its properties. After you are done, you write the modified element back to the data base using the function ModifyElements.

Warning

As writing elements into the database is a relatively slow process, make sure you call this function as seldom as possible. Modify you python objects first and put them all into one element_list. At the end, call the function.

Info

The method goes the modified python objects one by one and tries to use the most performant internal function to modify them. If there is no internal modification function implemented for the kind of modification, you are trying to perform, the function won't do anything to the element.

We are constantly developing the API, so inform us if your kind of modification is not supported.

Example

The implementation of the ModifyElements function is shown in the example ModifyPlaneReferences located in:

  • …\etc\Examples\PythonParts\BasisExamples\ObjectModification\ModifyPlaneReferences.pyp
  • …\etc\PythonPartsExampleScripts\BasisExamples\ObjectModification\ModifyFormatProperties.py

Document adapter

The DocumentAdapter class is needed for the access to the Allplan model and can be get:

  • by parameter in a PythonParts framework function implemented in the .py file
  • by a call to the function GetInputViewDocument e.g., from a CoordinateInput object
  • by a call to the function GetDocument from a BaseElementAdapter object.