Input dimension value by handle

This example shows the usage of a handle to input a dimension value:

../../_images/HandleDimensionValues.png

The Length handle is used to input the value for the PythonPart parameter Length. The source code for creating the handle looks like this:

handle_length = HandleProperties("Length", point2, point1,
                                  [HandleParameterData("Length", HandleParameterType.POINT_DISTANCE, show_input_controls)],
                                  HandleDirection.XYZ_DIR)

handle_length.info_text = "Length handle"

handle_list.append(handle_length)

Special details

  • the handle parameter type POINT_DISTANCE is used to make the value calculation for Length independent from a rotation of the PythonPart. The Length value is the distance between the reference and handle point.

  • the creation of the input fields is controlled by the value of show_input_controls.

The modification of the handle is limited to the values of the following tags of the parameter

  • <MinValue> for the minimal value

  • <MaxValue> for the maximal value

  • <ValueList> for the allowed values

  • <IntervalValue> as grid length


Handle processing

The processing of the handle click and move can be done inside the PythonPart script as follows:

def move_handle(build_ele,
                handle_prop: HandleProperties,
                input_pnt: AllplanGeo.Point3D,
                doc: AllplanElementAdapter.DocumentAdapter):
    """
    Modify the element geometry by handles

    Args:
        build_ele:  the building element.
        handle_prop handle properties
        input_pnt:  input point
        doc:        input document
    """

    build_ele.change_property(handle_prop, input_pnt)

    return create_element(build_ele, doc)

Clicking and moving the handle shows a preview like this:

../../_images/HandleDimensionValuesPreview.png