How to manually configuring halftone filters in python script?

Hi, guys. sorry to bother you.I’m having trouble learning scripting on the krita script school site. When I want to manually configuring halftone filters

from krita import *

application = Krita.instance()
currentDoc = application.activeDocument()
currentLayer = currentDoc.activeNode()

hFilter = application.filter('halftone')
hFilterConfig = hFilter.configuration()

print( hFilterConfig.properties() )


I modify the resolution parameter in gui, So I just added this code to modify the configuration

hFilterConfig.setProperty('CMYKA_channel0_generator_screentone_resolution', 150.0)
hFilterConfig.setProperty('CMYKA_channel1_generator_screentone_resolution', 150.0)
hFilterConfig.setProperty('CMYKA_channel2_generator_screentone_resolution', 150.0)
hFilterConfig.setProperty('CMYKA_channel3_generator_screentone_resolution', 150.0)
hFilterConfig.setProperty('RGBA_channel0_generator_screentone_resolution', 150.0)
hFilterConfig.setProperty('RGBA_channel1_generator_screentone_resolution', 150.0)
hFilterConfig.setProperty('RGBA_channel2_generator_screentone_resolution', 150.0)
hFilterConfig.setProperty('alpha_generator_screentone_resolution', 150.0)
hFilterConfig.setProperty('intensity_generator_screentone_resolution', 150.0)

But it doesn’t work, the halftone filter is still running at the default settings!(300) I tried other parameters as well, but the results didn’t change. Do you have any ideas?

1 Like

Where is your setConfiguration and apply like in scripting school?

https://scripting.krita.org/lessons/filters

I think there may be a bug similar to the recent ones in other filters. In this case, the generator configs are cached internally and that gives issues when using from python.

I creates a MR that tries to fix the issue. The real issue was only with the generator properties. Make halftone filter work well with python (!1900) · Merge requests · Graphics / Krita · GitLab

1 Like