Enable and visible options¶
Sometimes it’s useful to disable or hide a control inside the property palette. To do this, the PythonParts framework offers the following options:
Disable or hide by functions¶
Depending on the complexity of the enable or visible condition, it may be useful to implement the condition of the enable or visible state in a function within the py file. Using the utility class ControlPropertiesUtil, the function must be assigned to the control defined by the parameter name as follows
def initialize_control_properties(build_ele : BuildingElement,
ctrl_prop_util: ControlPropertiesUtil,
_doc : AllplanElementAdapter.DocumentAdapter) -> None:
""" initialize the control properties
Args:
build_ele : building element
ctrl_prop_util: control properties utility
_doc : document
"""
def visible_length(...) -> bool:
...
return ...
def enable_length(...) -> bool:
...
return ...
ctrl_prop_util.set_visible_function("Length", visible_length)
ctrl_prop_util.set_enable_function("Length", enable_length)
The parameter … of the functions depend on the type of the parameter value:
value type |
parameter |
---|---|
single value |
() |
value list |
(row_index: int) |
single named tuple |
(field_name: str) |
name tuple list |
(row_index: int, field_name: str) |
A use of the enable and visible functions is shown in the examples
…\etc\Examples\PythonParts\PaletteExamples\Visibility.pyp…\etc\PythonPartsExampleScripts\PaletteExamples\Visibility.py…\etc\Examples\PythonParts\PaletteExamples\NamedTuple.pyp…\etc\PythonPartsExampleScripts\PaletteExamples\NamedTuple.py…\etc\Examples\PythonParts\PaletteExamples\ValueList.pyp…\etc\PythonPartsExampleScripts\PaletteExamples\ValueList.py