I'm trying to connect my Python Script (it's already in my toolbox and working) with the rest of my Model. So the Script should be my input, but it is not working. I don't know why.
This is how the script looks like:
import arcpy, os
from arcpy import env
env.workspace = arcpy.GetParameter(0)
Topic = arcpy.GetParameterAsText(1)
Alternative = arcpy.GetParameterAsText(2)
featureclasses = arcpy.ListFeatureClasses(feature_dataset='A_'+str(Topic))
Output = arcpy.Union_analysis(featureclasses,r"C:01円_Data15円_Test.gdb\V_"+str(Alternative)+"_"+str(Topic),"NO_FID")
arcpy.SetParameterAsText(3, Output)
The output is set on Type = Derived and Direction = Output.
I tried also this:
import arcpy, os
from arcpy import env
env.workspace = arcpy.GetParameter(0)
Topic = arcpy.GetParameterAsText(1)
Alternative = arcpy.GetParameterAsText(2)
featureclasses = arcpy.ListFeatureClasses(feature_dataset='A_'+str(Topic))
result = arcpy.CreateFeatureclass_management(r"C:01円_Data15円_Test.gdb", ""V_"+str(Alternative)+"_"+str(Topic)")
Output = result.getOutput(0)
arcpy.SetParameterAsText(3,Output)
arcpy.Union_analysis(featureclasses,r"C:01円_Data15円_Test.gdb\V_"+str(Alternative)+"_"+str(Topic),"NO_FID")
-
Your logic is wrong... You create a FeatureClass which you retrieve from your result object and call "output". You set that as your output parameter then immediately destroy it with the Union tool. Get rid of the create featureclass. Get the output of your union tool and assign that to your output parameter.Hornbydd– Hornbydd2018年05月17日 15:08:08 +00:00Commented May 17, 2018 at 15:08
-
i didn't use the create featureclass tool in the first attempt. The first script works fine - but the union result exists only in the gdb and I was not able to connect it in a Model. I executed the script 10 times by now - changing the Alternative and the topic manually so I can put in the results in my model. But i just want to now why the result object is not recognized as the feature class itself.Lisa– Lisa2018年05月17日 15:29:16 +00:00Commented May 17, 2018 at 15:29
1 Answer 1
output
is a result object, all geoprocessing tools return a result object. So you are setting your output to be a result object and not a FeatureClass.
To return the output you need to query the result object using getOutput() have a look at the help file and the code samples.
Don't know it this also influences the data type of your output but you may want to experiment with arcpy.SetParameter()
?
-
I don't quite get your answer. I tried getOutput() , without result.Lisa– Lisa2018年05月17日 13:00:47 +00:00Commented May 17, 2018 at 13:00
-
1You have to show us your additional code, I cannot comment if I cannot see it. Update your question to show what you have doneHornbydd– Hornbydd2018年05月17日 13:55:35 +00:00Commented May 17, 2018 at 13:55
Explore related questions
See similar questions with these tags.