<div dir="ltr">Hi<div><br></div><div>I'm not sure why the Symbology flag is not working (havent time to look sorry) but a quick fix might be to do this (which worked for me in a quick test):</div><div><br></div><div><div>

error = writer.writeAsVectorFormat(aLayer, r"/tmp/out.shp", "CP1250", None, "ESRI Shapefile", False, None,"","", False, None, QgsVectorFileWriter.NoSymbology, 1.0)</div><div>

aLayer.saveNamedStyle("/tmp/out.qml")</div><div><br></div><div>(u'Created default style file as /tmp/out.qml', True)</div></div><div><br></div><div>Hope that helps!</div><div><br></div><div>Regards</div>

<div><br></div><div>Tim</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Dec 28, 2013 at 4:25 PM, Pim Verver <span dir="ltr"><<a href="mailto:pim@travelingo.nl" target="_blank">pim@travelingo.nl</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div bgcolor="white" lang="NL" link="#0563C1" vlink="#954F72">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">Hi,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">I am using the QGis python console for the use of exporting an active layer from postgist to a shape file
 layer. <i> </i>I want to include the symbology as is possible through the GUI of QGis 2 (Dufour).<br>
I am using the <a href="http://www.qgis.org/api/classQgsVectorFileWriter.html#a289af78b5b609fbcb0572aaf505f2822" target="_blank">
<span style="color:windowtext;text-decoration:none">writeAsVectorFormat</span></a> method of the QgsVectorFileWriter class, but keep getting the message that there are “Too many arguments” as if the parameter doesn´t exist. That seems correct given the fact
 that the mouse popup for the parameters doesn’t indicate a Symbology parameter. However in the  official QGis API the parameter is mentioned:
<a href="http://www.qgis.org/api/classQgsVectorFileWriter.html#a1aac90d30d811d2888d1aab4098ad63c" target="_blank">
http://www.qgis.org/api/classQgsVectorFileWriter.html#a1aac90d30d811d2888d1aab4098ad63c</a>. The symbology parameter seems tob e added in the latest release (QGis 2)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">Am I using it the wrong way or is someting else going on?</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">The alternative would be save the style als SLD and import the style file after creating the shape layer,
 but if I can avoid that …</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">The console code sofar:</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">canvas = iface.mapCanvas()<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">aLayer = iface.activeLayer()<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">if aLayer.dataProvider().name() == 'postgres':<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">    writer =  QgsVectorFileWriter<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">    error = writer.writeAsVectorFormat(aLayer, r"D:\Documenten_Travelingo\SkyDrive Pro\Horeca routes\Projectbestanden\deBaak Driebergen\Shape
 bronnen\\"+ aLayer.name() + ".shp", "CP1250", None, "ESRI Shapefile", False, None,"","", False, None, "NoSymbology", 1.0)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">#    then import the shape file in a new layer<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">if error == QgsVectorFileWriter.NoError:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">    vlayer = QgsVectorLayer(r"D:\Documenten_Travelingo\SkyDrive Pro\Horeca routes\Projectbestanden\deBaak Driebergen\Shape bronnen", aLayer.name()
 + ".shp", "ogr")<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">    QgsMapLayerRegistry.instance().addMapLayer(vlayer)</span><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">Th error is raised at the writeAsVectorFormat method and its parameter NoSymbology.<u></u><u></u></span></p>


<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">Thanx in advance
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">Kinds regards,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">Pim Verver</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif""><u></u> <u></u></span></p>
</div>
</div>

<br>_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Tim Sutton - QGIS Project Steering Committee Member<br>

==============================================<br>Please do not email me off-list with technical<br>support questions. Using the lists will gain<br>more exposure for your issues and the knowledge<br>surrounding your issue will be shared with all.<br>

<br>Irc: timlinux on #qgis at <a href="http://freenode.net" target="_blank">freenode.net</a><br>==============================================</div>
</div>