1

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)

Parameters

The output is set on Type = Derived and Direction = Output.

Model


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")
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked May 17, 2018 at 11:37
2
  • 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. Commented 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. Commented May 17, 2018 at 15:29

1 Answer 1

2

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()?

answered May 17, 2018 at 11:59
2
  • I don't quite get your answer. I tried getOutput() , without result. Commented May 17, 2018 at 13:00
  • 1
    You have to show us your additional code, I cannot comment if I cannot see it. Update your question to show what you have done Commented May 17, 2018 at 13:55

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.