[Qgis-developer] Expression context and custom functions

Hugo Mercier hugo.mercier at oslandia.com
Sun Sep 13 23:50:27 PDT 2015



On 13/09/2015 11:50, Nyall Dawson wrote:
> On 11 September 2015 at 23:53, Hugo Mercier <hugo.mercier at oslandia.com> wrote:
> 
>> Another question: I am trying to access the current atlas geometry from
>> a plugin, but fail to do so.
>> From the python console, with a atlas in preview mode :
>> QgsExpression.specialColumn("$atlasgeometry") -> None
>> QgsExpression("$atlasgeometry").evaluate() -> None
>>
>> However, if I set a layer's label to "$atlasfeatureid", I get the right
>> label ...
>>
>> Is it intended ? I guess that is because the "global" expression
>> evaluation has no atlas context ?
> 
> That's true. Is there any reason you aren't accessing the atlas
> feature/geometry directly? Why go through the expression engine to
> retrieve this?

Thanks for the clarification.
I now retrieve it through the atlas composition in the new version of
the plugin.


More information about the Qgis-developer mailing list