Allplan elements
Every component, that can be created in a drawing file, from a simple 2D line to multi-layered wall, is referred to as Allplan element and represented by an abstract base class AllplanElement. In this chapter, we describe briefly the most important ones.
-
Architecture
Architecture elements like walls, slabs, beams and columns are all represented by an abstract class ArchElement
-
Library
Elements saved in the library are represented by LibraryElement
-
Generic components
Generic components like lines, circles, surfaces or 3D objects are represented by a ModelElement2D and ModelElement3D
-
Reinforcement
Reinforcement components, like rebars, meshes and couplers are represented with placement classes.
Architecture elements
Work in progress
This paragraph will be created soon
Library elements
Elements saved in the Allplan library are represented by the LibraryElement class. Currently, following element types can be accessed by the API:
- symbols
- smart symbols (macros)
- fixtures
To do that, a LibraryElement object must be constructed using appropriate LibraryElementProperties. These are defined differently depending on the type of the library element.
To place a symbol or a smart symbol, you must specify the absolute path to the .sym or .nmk file:
path = r"c:\Data\Allplan\2025\std\Library\2D Objects\Exterior\2D animals\Cat.sym" #(1)!
library_element_properties = AllplanBasisElements.LibraryElementProperties(
fullPathName = path,
elementType = AllplanBasisElements.LibraryElementType.eSymbol, #(2)!
placementMatrix = AllplanGeo.Matrix3D()) #(3)!
library_element = AllplanBasisElements.LibraryElement(library_element_properties)
- The method get_global_standard_path
will help you get an absolute path (like
C:\Data\...\std\Library\...
out of a relative path beginning with a keyword likeSTD\Library\...
) - Set the type accordingly:
eSymbol
for a symbol (.sym) oreSmartSymbol
for smart symbol (.nmk) - When you want to place the same (smart)symbol multiple times on different locations, instead of a single Matrix3D, provide a list of placement matrices (Matrix3DList). This will speed up the process significantly.
When accessing a fixture from the library, provide the absolute path to the .pfx or .lfx file as the fourth argument, leaving the first three empty, like this:
library_element_properties = AllplanBasisElements.LibraryElementProperties(
"", "", "", fixture_path, #(1)!
AllplanBasisElements.LibraryElementType.eFixtureSingleFile,
AllplanGeo.Matrix3D()) #(2)!
- The method get_global_standard_path
will help you get an absolute path (like
C:\ProgramData\...\std\Library\...
out of a relative path beginning with a keyword likeSTD\Library\...
) - When you want to place the same fixture multiple times on different locations, instead of a single Matrix3D, provide a list of placement matrices (Matrix3DList). This will speed up the process significantly.
When accessing a fixture from the legacy catalog, provide the path, group and element in the LibraryElementProperties constructor, like this:
fixture = build_ele.Fixture.value #(1)!
library_element_properties = AllplanBasisElements.LibraryElementProperties(
path = fixture.Path,
group = fixture.Group,
element = fixture.Element,
elementType = AllplanBasisElements.LibraryElementType.eFixture,
placementMatrix = AllplanGeo.Matrix3D())
- If you defined the parameter
Fixture
in the .pyp file, as described here, theFixture.value
will be a FixtureProperties object and will containpath
,group
andelement
properties. You can, of course, construct the object yourself.
In case of a line or plane fixture, at this point you have to specify a polyline using the SetPolyline method:
fixture_pol = AllplanGeo.Polyline3D()
fixture_pol += AllplanGeo.Point3D()
fixture_pol += AllplanGeo.Point3D(1500, 0, 0)
fixture_pol += AllplanGeo.Point3D(2500, 2000, 0)
library_element_properties.SetPolyline(fixture_pol)
library_fixture_element = AllplanBasisElements.LibraryElement(library_element_properties)
Now, you can construct the LibraryElement:
The created LibraryElement object can then directly be
appended to the elements property of the CreateElementResult data class
(in case of Standard PythonPart) or to the model_ele_list
argument of the
PythonPartTransaction.execute() method (in case of Interactor PythonPart).
Example
To see the full implementation, refer to the example LibraryDialogs. It also shows, how to implement dialogs for Allplan library. It is located in:
- …\etc\Examples\PythonParts\PaletteExamples\Dialogs\LibraryDialogs.pyp
- …\etc\PythonPartsExampleScripts\PaletteExamples\Dialogs\LibraryDialogs.py
Appending to a PythonPart
For a library element to be an integral part of a PythonPart, it must be appended to it as a child object. For that purpose, the PythonPartUtil offers the method add_library_elements. Refer to the article about PythonParts to learn more about appending child elements to a PythonPart.
Tip
If the PythonPart should solely consists of a library element, it is advisable to create at least a bounding box around it as an unprintable help construction and add it to the PythonPart container with add_pythonpart_view_2d3d. As a result, the user is still able to modify the PythonPart by double-click on the bounding box, whereas the library element remains a child-element of the PythonPart.
Example
The example SymbolLibraryElement shows, how to append a library symbol to a PythonPart, that should consist only of this symbol, and a bounding box. It is located in:
- …\etc\Examples\PythonParts\BasisExamples\UserObjects\SymbolLibraryElement.pyp
- …\etc\PythonPartsExampleScripts\BasisExamples\UserObjects\SymbolLibraryElement.py
Model elements
Work in progress
This paragraph will be created soon