Loop through multiple input values ArcPy Toolbox

808
4
06-23-2021 05:51 AM
Nicola
by
New Contributor II

Hello everybody,

I'm trying to create a tool in ArcGIS, that creates 3D Multipatches from multiple input values.

The tool should extrude between input TIN 1 and input TIN 2, then between input TIN 2 and input 3 and so on...

Somehow my loop is not working. It gives me three 3D Multipatches back, but 3 times the same.

Below I post my code. Maybe someone has an idea or a hint what is wrong with my loop.

 

 

# IMPORT MODULES
import arcpy, os, sys, string, traceback


# Input layers
from typing import List, Any

inLayers = arcpy.GetParameterAsText(0)
inLayerslist = inLayers.split(";")
# Output workspace
outFolder = arcpy.GetParameterAsText(1)



# OTHER FRONT STUFF
for lyr in inLayerslist:
    n=len(inLayerslist)
    arcpy.AddMessage(str(inLayerslist))
    arcpy.AddMessage(str(len(inLayerslist)))

    for i in range (0,n-1):
        arcpy.AddMessage(str(inLayerslist[i]))
        arcpy.AddMessage(str(i))
        inPoly = arcpy.GetParameterAsText(2)
        layerName = lyr + "solid" + str(n)
        solid = arcpy.ExtrudeBetween_3d(inLayerslist[i],inLayerslist[i+1],inPoly,layerName)

 

 

 

0 Kudos
4 Replies
BlakeTerhune
MVP Regular Contributor

Do you also need to extrude between the first TIN and the last TIN?

0 Kudos
Nicola
by
New Contributor II

No.... Am I doing this 😅? I only need to extrude between the consecutive ones.

0 Kudos
BlakeTerhune
MVP Regular Contributor

What about something like this?

 

inLayers = arcpy.GetParameterAsText(0)
inLayerslist = inLayers.split(";")
outFolder = arcpy.GetParameterAsText(1)
inPoly = arcpy.GetParameterAsText(2)

arcpy.AddMessage(inLayerslist)
arcpy.AddMessage(len(inLayerslist))
for index, lyr in enumerate(inLayerslist):
    next_lyr = inLayerslist[index + 1]
    arcpy.AddMessage(f"Extrude between {lyr} and {next_lyr}")
    layerName = f"{lyr}solid{index}"
    solid = arcpy.ExtrudeBetween_3d(lyr, next_lyr, inPoly, layerName)

 

0 Kudos
KevinWiley13
New Contributor

Hi Nicola,

Did you ever work out a solution to your Extrude Between script? I am facing a similar problem and am hoping to build off of any results you may have. Thanks for any help you can provide.

Kevin

0 Kudos