5

I am pretty much following the procedure of this answer but I can't get my head around as to where to set the 'Units' from 'Map Units' (default) to Millimeters that is.

So far, I tried several variants to define a unit type and set the symbol layer to it:

millimeters = QgsUnitTypes.DistanceUnit.Millimeters
renderer().symbol().symbolLayer(1).setUnits(millimeters)

1 Answer 1

10

You have to use QgsUnitTypes.RenderMillimeters.

layer = iface.activeLayer()

mm = QgsUnitTypes.RenderMillimeters
layer.renderer().symbol().symbolLayer(1).setUnits(mm)

symbolLayer(1) must be an instance of QgsGeometryGeneratorSymbolLayer.

You can find different unit types in source code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.