<div dir="ltr">Hi Peter,<div><br></div><div>You are correct with the analysis of the situation.</div><div><br></div><div>Even if `qgis --help` states the following:</div><div> [--] treat all following arguments as FILEs<br></div><br><div>it does in fact already interpret parameters as files before the `--` parameter.</div><div>Changing this behavior is risky (it will break many startup scripts out there) and can be considered for QGIS 4.</div><div>For now, we could add another marker as a band aid, e.g. we add a `--ex` (extra-parameters) that indicates that any parameters that follow should NOT be interpreted as files:<br></div><div><br></div><div> qgis -p 1234.qgs --code script.py [files could be here] --ex --myparam=1324 -- [more files can still be here]</div><div><br></div><div>If that sounds like what you are looking for, we are happy to help you with that</div><div><br></div><div>Best regards</div><div>Matthias</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Aug 8, 2022 at 3:55 PM Drexel Peter via QGIS-Developer <<a href="mailto:qgis-developer@lists.osgeo.org">qgis-developer@lists.osgeo.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="DE-AT">
<div class="gmail-m_8421945636739483364WordSection1">
<p class="MsoNormal"><span lang="EN-US">Hi everyone,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">My goal: I want to open QGIS using the Command-Line, load a specific project, select specific features and zoom to the selected features.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">What sounds rather difficult is actually mostly solvable using the following:<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">"C:\Program Files\QGIS 3.16\bin\qgis-ltr-bin.exe" -p "d:\standardebenen.qgs" --code myscript.py<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">This opens QGIS with the Project d:\standardebenen.qgs and after that it runs the script “myscript.py”.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Within the scrip I can do everything what I can do in a Python-script, so there I can select some features in a layer and show that selection.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">But this selections are “hard-coded” in the script, I cannot pass over these parameters to the myscript.py.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">In “Pure Python” I can pass parameters to a Python Script using “python myscript.py arg1 arg2 arg3”.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">This seems to be not working in the QGIS-Command-Line as the parameters are interpreted as “layers to load”.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Am I right with my analysis?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">One workaround is to write the parameters to al file and use this file within the myscript.py to define the selections. But this is very unhandy…<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Are there any ideas from any QGIS-Expert to solve my problem?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">If this cannot be solved in the current version of QGIS is one of the developers willing to get in contact with me to make an offer the implement this feature ?
<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Thanks<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Peter<u></u><u></u></span></p>
</div>
</div>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div>
<br>
<div style="text-align:left"><a href="https://qfield.org/get/" target="_blank"><img src="https://www.opengis.ch/wp-content/uploads/2022/04/Qfield_Banner_email.png" alt="https://qfield.org/get/"></a><span style="font-family:Arial"><a><br></a></span></div><div style="text-align:left"><span style="font-family:Arial">QFIELD 2.0 IS HERE!<span style="font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif"><font size="3"> </font></span>- Hold the power of QGIS in your hand</span><span style="font-family:Arial"> - <a href="https://www.opengis.ch/2022/04/05/qfield-2-0-is-here/" target="_blank">learn more</a> - <a href="https://qfield.org/get" target="_blank">get it now</a><br></span></div>