Need help with Python script, loop & adding values

Discussion created by unigisromy on Aug 6, 2011
Latest reply on Aug 12, 2011 by unigisromy
Hello everybody,

I am currently working on a new tool for ArcGis 10. What I have done so far is to build a workflow combining different tools in the Model Builder.
Then I exportet it to a Python script.

Now, I want to add a few things to the script which can not be done in the Model Builder.
I am a beginner in Python and have difficulties with the next steps.
In the attached sketch I made a draft of how the tool should work.

1. How to implement a user-defined selection of the input features that should be analyzed, the user should be able to select the objects that should be analyzed

2. For every selected object an analysis will be performed inside a loop which should create a new output feature (shapefile), these result files should contain the ID of the selected input object as name;  (the analyzing process inside the loop is already done )

3. One or many field values from each output file should be added as a new field(s) to the input file

4. Non-selected objects in the input file should have a "0" in the new field

Anybody having ideas for that? A script example with some explanations would be very helpful for me an an Python beginner.