Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify and adjust use of runAndLoadResults method #9068

Merged
merged 2 commits into from
May 15, 2024

Conversation

DelazJ
Copy link
Collaborator

@DelazJ DelazJ commented Apr 30, 2024

Goal:

Ticket(s): #

  • Backport to LTR documentation is requested

@DelazJ DelazJ added Training Manual Processing refers to the processing framework settings or features backport release_3.34 On merge create a backported pull request to 3.34 labels Apr 30, 2024
Comment on lines 66 to 68
Or, after you ran the pasted command, and depending on the output layer type, you can type e.g.::

Otherwise, you can use::

processing.runAndloadResults
iface.addVectorLayer('/path/to/output/filename', 'Layer name in legend', 'ogr')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The manual mentions the use of a load() method but I can't find it nor figure out how it would work. Should probably be suggested here. So if anyone knows...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nyalldawson can you show how the load() method can be used here, please? Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That load method is deprecated, we shouldn't mention it: https://github.com/qgis/QGIS/blob/master/python/plugins/processing/tools/dataobjects.py#L111

(it won't work as desired anyway)

If you want to do it by hand you'd do something like:

 results = processing.run("native:buffer", {'INPUT':'/home/nyall/dev/QGIS/tests/testdata/points.shp','DISTANCE':10,'SEGMENTS':5,'END_CAP_STYLE':0,'JOIN_STYLE':0,'MITER_LIMIT':2,'DISSOLVE':False,'SEPARATE_DISJOINT':False,'OUTPUT':'TEMPORARY_OUTPUT'})
 buffered_layer = results['OUTPUT']
 QgsProject.instance().addMapLayer(buffered_layer)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nyalldawson

@DelazJ DelazJ merged commit 28e0b3b into qgis:master May 15, 2024
2 of 3 checks passed
@DelazJ DelazJ deleted the tm_runAndLoadResults branch May 15, 2024 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport release_3.34 On merge create a backported pull request to 3.34 Processing refers to the processing framework settings or features Training Manual
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants