Skip to content

Connections

Docking points

The docking points of the PythonPart can be used to connect other Allplan objects with these points. A good example are the associative dimension lines.

Depending on the dynamic state of the PythonPart elements, the docking points are created differently.

Static PythonPart

In a PythonPart, in which:

  • the geometry element count and order are static AND
  • the point count and order inside the geometry elements is static

the docking points are generated automatically from the geometry elements of the PythonPart without further action needed.

Dynamic element count

In a PythonPart, in which:

  • the geometry element count and order are dynamic AND
  • the point count and order inside the geometry elements is static

The docking points must be made unique. To do it, a docking point key must be assigned to each model element of the PythonPart. This must be implemented in the script using the SetDockingPointsKey method:

polyhedron_element = AllplanBasisEle.ModelElement3D(com_prop, polyhed)

polyhedron_element.SetDockingPointsKey("Polyhed")

The docking point keys should be assigned in a way that the elements, whose points can be used for meaningful dimension lines, always become the same key.

Example

In the following example, a PythonPart is created with a dynamic count of polyhedrons. The docking point keys are created from the left and right side, meaning that the far-left and far-right polyhedrons always become the same docking point key, the L0 and R0 respectively. The objects next to them become the keys L1 and R1 respectively and so one...

Docking points key

This results in last polyhedrons having the same docking point key, regardless of the total number of the polyhedrons. This makes it possible to place an associative dimension line from the far-left to the far-right polyhedron, which will remain after changing the count of polyhedrons:

Dynamic PythonPart

In a PythonPart, in which:

  • the geometry element count and order are dynamic AND
  • the point count and order inside the geometry elements is dynamic

The function create_docking_points must be implemented in the script. This function must be used only for creating the docking points of the dynamic elements. For the creation of the docking points of the other elements, only the docking point key must be set.

Example

The following example shows a PythonPart element with possible recesses at the left and right side. The docking point keys are represented by a unique name of the element and the point index, as shown below. The number of docking points is reduced to the docking points that are still present in the case where a recess is missing. This allows to adjust the dimension lines in case of a missing recess:

Dynamic Docking Points before

Dynamic Docking Points after

Example

The complete example of creating docking points is implemented in the PythonPart DockingPoints located here:

  • …\etc\Examples\PythonParts\BasisExamples\General\DockingPoints.pyp
  • …\etc\PythonPartsExampleScripts\BasisExamples\General\DockingPoints.py

To evaluate the functionality of the docking points, the following steps can be performed:

  • start Allplan and create a DockingPoints PythonPart
  • create associative dimension lines by using the docking points from the PythonPart
  • change the created PythonPart by modifying the size, number of elements or by disabling the recesses
  • see, how the associative dimension lines are adjusted

Plane connection

The elements of a PythonPart can be connected to a plane. The creation of the plane connection can be done by adding a Plane references dialog in the .pyp file. This entry creates a PlaneReferences object, that can be used to get the plane heights as follows:

plane_ref = build_ele.PlaneReferences.value

abs_bottom_elevation = plane_ref.GetAbsBottomElevation()
abs_top_elevation    = plane_ref.GetAbsTopElevation()

height = abs_top_elevation - abs_bottom_elevation

cuboid_geo = AllplanGeo.Polyhedron3D.CreateCuboid(build_ele.Width.value, 
                                                  build_ele.Depth.value, 
                                                  height)

Plane connection

When the planes are changed in the Allplan project, all PythonParts with plane connections are checked for and, if necessary, recalculation of the PythonPart geometry is executed.

Example

For a complete usage of plane connection, see the example PlaneConnection located in:

  • …\etc\Examples\PythonParts\BasisExamplesGeneral\PlaneConnection.pyp
  • …\etc\PythonPartsExampleScripts\BasisExamplesGeneral\PlaneConnection.py

Surface planes

If the selected plane is a surface plane, the BottomTopPlaneService can be used to get the geometry of the surface plane as follows:

build_ele.ReferencePlaneBottom.value = \
    AllplanArchEle.BottomTopPlaneService.GetBottomReferencePlane(AllplanEleAdapter.BaseElementAdapter(),
                                                                 doc, build_ele.Plane.value)

The return value can be a:

depending on the geometry type of the selected surface plane.

BottomTopPlaneService

Example

How to use this plane geometry to fit the geometry of the PythonPart to the plane is explained in the example BottomTopPlaneService located in:

  • …\etc\Examples\PythonParts\ServiceExamples\BottomTopPlaneService.pyp
  • …\etc\PythonPartsExampleScripts\ServiceExamples\BottomTopPlaneService.py