thank you, @GKmieliauskas
unfortunately, that's not my problem. my problem is how i return the value from the python script to the gpResult-variable. maybe I can make it clearer with a minimal example.
I've got my python-toolbox:
import arcpy
if arcpy.GetLogHistory():
arcpy.SetLogHistory(False)
if arcpy.GetLogMetadata():
arcpy.SetLogMetadata(False)
from tkinter import messagebox
from osgeo import gdal
import os
import ast
from arcpy.arcobjects import convertArcObjectToPythonObject
import sys
class Toolbox(object):
def __init__(self):
"""Define the toolbox (the name of the toolbox is the name of the
.pyt file)."""
self.label = "Toolbox"
self.alias = "toolbox"
# List of tool classes associated with this toolbox
self.tools = [ParcsVectors]
def load_vector():
try:
messagebox.showinfo(title="test", message="Hello - this message is from a TEST Python script")
return "test"
except Exception as err:
messagebox.showinfo(title="Load vectors failed", message="Exception: " + str(err))
class ParcsVectors(object):
def __init__(self):
"""Define the tool (tool name is the name of the class)."""
self.label = "ParcsVectors"
self.description = ""
def getParameterInfo(self):
"""Define parameter definitions"""
params = None
return params
def isLicensed(self):
return True
def updateParameters(self, parameters):
return
def updateMessages(self, parameters):
return
def execute(self, parameters, messages):
result = load_vector()
messagebox.showinfo(title="testing", message= result)
return result
The messagebox with "testing" and my result is shown, meaning it works until here.
Then I tried to get it back into my dockpane with your code:
string installPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string toolboxPath = System.IO.Path.Combine(installPath, "ParcsData.pyt\\ParcsVectors");
var gpResult = Geoprocessing.ExecuteToolAsync(toolboxPath, null, null, null, null, GPExecuteToolFlags.AddToHistory);
gpResult.Wait();
if (gpResult.Result.IsFailed)
{
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Geoprocessing to read vectors failed");
}
else
{
var resultValues = gpResult.Result.Values;
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(resultValues.Count().ToString(), "Returned value:");
if (resultValues == null)
{
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("No vectors to read");
}
else
{
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show($"Returned value: {resultValues[0]}");
}
}
The message gave me first an index out of range error, that's why I tried to check if anything is returned at all. It tells me, that there is nothing in my result. How can I return my result back into my dockpane? I assume it's a fairly simple problem but I cant find the solution anywhere...