Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[RFC] Summer of code project to re-think plug-in/filter development resources
#15
(06-19-2025, 02:34 PM)MrsP-from-C Wrote: This is what I get using the official 3.0.4 appimage:

I confirm, had the same problem recently. when I used that to create a call in the Python console.

Otherwise, I'm using this in my code:

Code:
def callProcedure(procId: str, run_mode=Gimp.RunMode.NONINTERACTIVE, **kwargs):
    procedure=Gimp.get_pdb().lookup_procedure(procId)
    if procedure is None:
        raise Exception(f'Procedure "{procId}" no found')
    config: Gimp.ProcedureConfig = procedure.create_config()
    #configuration.set_property('run-mode',run_mode)
    for name,value in kwargs.items():
        if isinstance(value,list):
            config.set_core_object_array(name.replace('_','-'),value)
        else:
            config.set_property(name.replace('_','-'),value)
    result=procedure.run(config)
    results = [result.index(i) for i in range(result.length())]
    if results[0] is not Gimp.PDBStatusType.SUCCESS:
        raise Exception(f'Error returned from procedure "{procId}": {results[0].value_name}')
    return results[1:]

This infers the config data from keyword arguments (python_style_names being replaced by equivalent config-element-names), and handles the set_property/set_core_object_array automatically.

Used like this:

Code:
# Other args of sel2path are default values
    res = callProcedure('plug-in-sel2path', image=scaledImage, drawables=[layer])
Reply


Messages In This Thread
RE: [RFC] Summer of code project to re-think plug-in/filter development resources - by Ofnuts - 06-19-2025, 08:30 PM

Forum Jump: