Default favorite file in interactor PythonPart¶
The functions for the default favorite file handling are used to save the parameter values from the current input and read this parameter values in the next input.
If the PythonPart is created as an interactor, the default favorite file handling must be implemented in the interactor. The xxx.pyv file is the standard default favorite file for the PythonPart.
Save default parameter values¶
The current parameter values of the PythonPart can be written to the default favorite file “PythonPart-name”.pyv by calling the function
BuildingElementListService.write_to_default_favorite_file(build_ele_list)
The parameter values are taken from the build_ele_list and written to the favorite file. The default favorite file is located in the Allplan …\usr\local\tmp directory.
As a general solution, saving the current parameter values as default favorite can be implemented in the __del__ function of the interactor as follows:
def __del__(self):
""" save the default favorite data """
BuildingElementListService.write_to_default_favorite_file(build_ele_list)
This function is called after the input inside the PythonPart is finished.
Read default parameter values¶
The default parameter values of the PythonPart can be read from the default “PythonPart-name”.pyv file by calling the function
BuildingElementListService.read_from_default_favorite_file(build_ele_list)
The parameter values are read from the default favorite file and assigned to the parameter in the build_ele_list. By default this call can be implemented after reading the data from the pyp file like
result, build_ele_script, build_ele_list, control_props_list, \
build_ele_composite, part_name, file_name = \
build_ele_service.read_data_from_pyp(pyp_path + "\\Line2DInteractor.pal", str_table_service.str_table, False,
str_table_service.material_str_table)
if not result:
return
BuildingElementListService.read_from_default_favorite_file(build_ele_list)
Reset parameter values to initial values¶
The parameter values of the PythonPart can be reset to the initial values, which are defined in the *xxx.pyp file of the PythonPart, by calling the function
BuildingElementListService.reset_param_values(build_ele_list)
For more detailed information, see BuildingElementListService
.