Skip to content

Handle processing in standard PythonPart

Creation

Objects of HandleProperties class representing handles can be appended to a Python list, which can be then passed to the data class CreateElementResult for the element creation:

def create_element(build_ele, doc):
    ...
    handle_1 = HandleProperties(...)
    handle_2 = HandleProperties(...)

    handle_list = [handle_1, handle_2]
    ...
    return CreateElementResult(elements = model_elements_list,
                               handles =  handle_list)

Modification

After every handle modification, the new value of the property must be written back in the property palette and the element must be recreated. To handle this process the function move_handle() must be implemented in the script.

A template script for creating a standard PythonPart

move_handle(build_ele, handle_prop, input_pnt, doc)

Called after modification of the element geometry using handles

Parameters:

Name Type Description Default
build_ele BuildingElement

building element with the parameter properties

required
handle_prop HandleProperties

handle properties

required
input_pnt Point3D

input point

required
doc DocumentAdapter

input document

required

Returns:

Type Description
CreateElementResult

Object with the result data of the element creation

Example

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

    Args:
        build_ele:  the building element.
        handle_prop handle properties
        input_pnt:  input point
        doc:        input document
    """
    if handle_prop.handle_id == build_ele.MirrorCuboid.name: #(1)!
        build_ele.MirrorCuboid.value = not build_ele.MirrorCuboid.value

    else:
        HandlePropertiesService.update_property_value(build_ele, handle_prop, input_pnt) #(3)!

    return create_element(build_ele, doc) #(2)!
  1. This is an example, of how processing of the modification of a specific handle (in this case the MirrorCuboid handle) can be handled differently than others.
  2. With this return value the PythonPart is recreated with every movement of the handle
  3. For a standard case you just need to implement this line of code in the move_handle function. The update_property_value method updates the values in the property palette after the handle is modified.