<div dir="ltr">Hi,<br><br>I'm developing a plugin that, amongst other things, generates maps automatically.<br><br>I have two presets :<br>- one which is relative to the current map visualization, the standard one, named "main"<br>- and another one, which is relative to the atlas generation, embedding the styles of masks, named "atlas"<br><br>Each preset checks a different combination of layers.<br><br>The problem is that I don't really know which class to use : I noticed the QgsVisibilityPresetCollection class and used the method applyPresetCheckedLegendNodesToLayer(presetName, layerId), but it doesn't affect the layer panel, nor the layer styles.<div><br></div><div>Here, I want to apply the "main" preset to a layer named Cities<br><div><br></div><div><pre style="margin-top:0px;margin-bottom:0px;padding:0px;list-style:none;font-size:1.2em;color:rgb(51,51,51)">layerName = 'Cities'
layer = QgsMapLayerRegistry.instance().mapLayersByName(layerName)[0]<br>QgsProject.instance().visibilityPresetCollection().applyPresetCheckedLegendNodesToLayer('main', <a href="http://layer.id">layer.id</a>())</pre><br>(Doesn't work)</div><div><br></div><div>Could you tell me how to achieve the preset selection ?</div></div><div><br></div><div>Any help would be appreciated,</div><div><br></div><div>Mathieu</div></div>