¿Por qué se produce un error al cargar una función definida por el usuario en QGIS 3.12.2?
La expresión:
@qgsfunction(args='auto', group='Custom'):
def getHeight(layId, itemId, feature, parent):
layout = QgsProject.instance().layoutManager().layoutByName(layId)
item = layout.itemById(itemId)
#item.refreshItemSize()
return item.rect().height()
El mensaje de error:
2020-05-16T21:01:46 WARNING getLayoutByName
Traceback (most recent call last):
File "C:/PROGRA1/QGIS31.12/apps/qgis/./python\qgis\user.py", line 46, in load_user_expressions
import("expressions.{0}".format(name), locals(), globals())
File "C:/PROGRA1/QGIS31.12/apps/qgis/./python\qgis\utils.py", line 744, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:/Users/genf/AppData/Roaming/QGIS/QGIS3\profiles\default/python\expressions\getLayoutByName.py", line 1, in
@qgsfunction(args='auto', group='Custom')
NameError: name 'qgsfunction' is not defined
2020-05-16T21:01:46 WARNING getTop
Traceback (most recent call last):
File "C:/PROGRA1/QGIS31.12/apps/qgis/./python\qgis\user.py", line 46, in load_user_expressions
import("expressions.{0}".format(name), locals(), globals())
File "C:/PROGRA1/QGIS31.12/apps/qgis/./python\qgis\utils.py", line 744, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:/Users/genf/AppData/Roaming/QGIS/QGIS3\profiles\default/python\expressions\getTop.py", line 1, in
@qgsfunction(args='auto', group='Custom')
NameError: name 'qgsfunction' is not defined