Hello,
i have a script which works well and changes the pre-defined symbol
QuarterCircle's color and angle :

vLayer = QgsVectorLayer(uri, "myData" , "delimitedtext") #some vector layer

symbol = QgsSymbolV2.defaultSymbol(vLayer.geometryType())

simple_marker = QgsSimpleMarkerSymbolLayerV2()
simple_marker.setShape(QgsSimpleMarkerSymbolLayerBase.QuarterCircle )
simple_marker.setSize(6.0)

ddpAngle=QgsDataDefined( True, True, "Direction")
ddpColor= QgsDataDefined( True, True, "CASE WHEN DATA % 3 = 0 then
color_rgb( 255,0,0) WHEN DATA % 3 = 1 then  color_rgb( 0,255,0) WHEN
DATA % 3 = 2 then  color_rgb( 0,0,255) END" )
simple_marker .setDataDefinedProperty( "angle", ddpAngle)
simple_marker .setDataDefinedProperty( "color", ddpColor)

symbol.changeSymbolLayer(0,simple_marker)

vLayer.rendererV2().setSymbol(symbol)vLayer.triggerRepaint()


  Then i wanted to change the QgsSimpleMarkerSymbolLayerBase.QuarterCircle
symbol to a user defined .svg format symbol.

symbol = QgsSymbolV2.defaultSymbol(vLayer.geometryType())
svg_marker = QgsSvgMarkerSymbolLayerV2( 'D:\\sample.svg' )
svg_marker.setSize(12.0)
svg_marker.setOutlineWidth(0.25)
ddpAngle=QgsDataDefined( True, True, "Direction")
ddpColor= QgsDataDefined( True, True, "CASE WHEN DATA % 3 = 0 then
color_rgb( 255,0,0) WHEN DATA % 3 = 1 then  color_rgb( 0,255,0) WHEN
DATA % 3 = 2 then  color_rgb( 0,0,255) END" )
svg_marker.setDataDefinedProperty( "angle", ddpAngle)
svg_marker.setDataDefinedProperty( "color", ddpColor)

symbol.changeSymbolLayer(0,svg_marker)

vLayer.rendererV2().setSymbol(symbol) vLayer.triggerRepaint()

for this one it changes the angle but the color part doesnt work and all
the colors are black. Can you please help me to find the problem? or  Can
you please give an example portion of code that imports an svg and modify
its color according to some data belongs to a vector layer(data defined
override)?

Qgis Version : 2.18.22
_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to