0

I have multiple scripts I like to add them to QGIS.

I tried adding it via the GUI as well the code under this entry Adding scripts to Processing toolbox via PyQGIS.

For the first script "lines heat density" this works well but all the others scripts can not be added or at least be seen in the toolbox under scripts. There is no error message. The toolboxtree under scripts just closes. When opening nothing new is added. The scripts are located under ...AppData\Roaming\QGIS\QGIS3\profiles\default\processing\scripts.

How to fix this ?

enter image description here

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jul 8 at 10:48
6
  • 1
    Do all your scripts conform to a proper qgis processing algorithm structure as described here: docs.qgis.org/3.40/en/docs/user_manual/processing/…? Either subclassing QgsProcessingAlgorithm or using the @alg decorator. In some cases, errors in the script will just disable the scripts provider (sounds like what happened). Check the Python Error tabs in the logs panel. Commented Jul 8 at 11:08
  • makes sense in the first place. While lines heat density was created with the model builder the script to add was mainly written by AI. Still works but probably does not match the stated requirements for QGIS. The logs panel does not show any error while executing the script. Commented Jul 8 at 12:08
  • 1
    Yes, a model exported as a Python script is a valid processing algorithm. Your AI generated code, although it works when run in the console, is not a processing algorithm. Maybe it's time to dive into the links I provided you here: gis.stackexchange.com/questions/491798/… Commented Jul 8 at 13:28
  • 1
    And to pre-empt your next question, processing algorithms are run in a background thread by default. Knowing that your script is about generating and exporting layouts (not thread-safe) if you implement that logic in the processAlgorithm() method, you will need to override the flags() method and return the no threading flag. See: gis.stackexchange.com/questions/493906/… Commented Jul 8 at 13:34
  • A slightly simpler option for your other scripts (if you don't want to convert them into full processing algorithms) could be the Script Runner 3 plugin. Disclaimer: I've never used this plugin. I know it was around back in the QGIS 2 days and was updated for QGIS 3 but doesn't seem to have had much development activity for a while. Could be worth looking into though. The plugin home page & docs are here. Commented Jul 9 at 2:45

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.