AnsweredAssumed Answered

Trouble with loops

Question asked by alex1fly on Feb 5, 2015
Latest reply on Feb 12, 2015 by alex1fly

I am having trouble setting up a basic loop. Most of the examples I'm finding online are either rudimentary "this is what a loop does" examples or don't seem to apply to what I'm doing. It's entirely probable that my workflow is just still not right. Please take a look at my code and help me become less of an amateur!


I have multiple processes to run on multiple files of the same type. So I build out the workflow in ModelBuilder and export that to a python script. In this case, I'm running the Minimum Bounding Geometry tool on a multipoint feature, converting the resultant vertices to points, then adding XY fields. It works great running in ModelBuilder or as a script on a single file, and the code is below in bold; however, I want to run this tool on a whole folder's worth of files.







import arcpy



# Local variables:

N2E100 = "D:\\Broomfield.Lidar\\Projection\\ReProject.gdb\\N2E100"

N2E100_MinimumBoundingGeomet = "D:\\Broomfield.Lidar\\GeometryResults.gdb\\N2E100_MinimumBoundingGeomet"

N2E100_MinimumBoundingGeomet1 = "D:\\Broomfield.Lidar\\GeometryResults.gdb\\N2E100_MinimumBoundingGeomet1"


# Process: Minimum Bounding Geometry

arcpy.MinimumBoundingGeometry_management(N2E100, N2E100_MinimumBoundingGeomet, "RECTANGLE_BY_AREA", "ALL", "", "NO_MBG_FIELDS")


# Process: Feature Vertices To Points

arcpy.FeatureVerticesToPoints_management(N2E100_MinimumBoundingGeomet, N2E100_MinimumBoundingGeomet1, "ALL")


# Process: Add XY Coordinates



I'm quite familiar with the syntax of loops and how they work in theory, but it's putting the loops into practice that I struggle with.