English

How To: Run the Edit TIN tool in the batch mode by setting Edit TIN parameters for input layers

Summary

In ArcToolbox, a user can 'batch' the Edit TIN process located under ArcToolBox > 3D Analyst Tools > TIN Creation, but the user will not have any control on setting the Edit TIN parameters such as height_field, tag_field, SF_type, and user_z for input layers. Instructions provided describe how to run the Edit TIN tool in the batch mode, by setting the Edit TIN parameters for input layers.

Procedure

The code included within this article is in Python and can be completely customized. Many settings such as folder\file names, number of feature layers, feature layer types, and Edit TIN parameters can be changed as required. The code can be compiled into a Python script that can be run by adding it into an ArcToolbox or can be executed from inside an existing code.

Prerequisites:

  • This code currently considers only three feature layers: one point, one polyline and a multipatch.
  • Edit TIN parameters' values such as, height_field, tag_field, SF_type, and user_z should be consistent for all the feature layers based on their geometry types. For example, a polyline feature layer in the dataset uses ‘softline’ SF_type, or any MultiPatch feature layer has the use_z value set to ‘TRUE’.
    These parameters values are hardcoded in the script based on this assumption.
  • Create a folder Workspace on the root of the C: drive with two nested folders 'TINs' and 'FCs'. First, the empty TINs should be created in the ‘TINs’ folder, and they should be named in numerical order starting with '1'. Similarly, the feature layers that will be used in the edit TIN process should be saved in separate subfolders that are named in numerical order starting with ‘1’. All the subfolders are stored under the folder ‘FCs’.
    By doing this, the feature layers that will be used for the Edit TIN process are based on the numbers that match between a TIN and a folder that contains the feature layers.

    For example:
    Feature layers in folder ‘1’ under ‘FCs’ are used for TIN ‘1’ under the ‘TINs’ folder in the Edit TIN process.

    [O-Image]

  • Code:
    # Import system modules
    import sys, string, os, arcgisscripting

    # Create the Geoprocessor object
    gp = arcgisscripting.create()

    # Check out any necessary licenses
    gp.CheckOutExtension("3D")

    # Load required toolboxes...
    gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/3D Analyst Tools.tbx")

    # Find only TIN datasets
    gp.workspace = "C:\\WorkSpace\\TINs"

    # Get a list of TINs in the workspace.
    datasets = gp.listdatasets("", "TINs")

    datasets.reset()
    dataset = datasets.next()
    try:
    while dataset:
    ds = gp.workspace + "\\" + dataset

    #For accessing different FCs under different subfolders
    # List all folder workspaces in the current workspace
    ws = "C:\\WorkSpace\\FCs\\" + dataset

    print "3: " + ws

    gp.workspace = ws
    print "4: " + gp.workspace
    # Get a list of feature classes in the workspace.
    fcs = gp.ListFeatureClasses()
    # Loop through the list of feature classes.
    fc = fcs.next()
    while fc:
    print "5: " + fc

    print "6: " + gp.describe(fc).ShapeType
    type = gp.describe(fc).ShapeType
    #Only three types of feature types are considered for this Edit TIN process, a point, a polyline and a multipatch
    if type == "Point":
    pointFC = ws + "\\" + fc
    print "7: " + pointFC
    elif type == "Polyline":
    lineFC = ws + "\\" + fc
    print "7: " + lineFC
    elif type == "MultiPatch":
    multiPatchFC = ws + "\\" + fc
    print "7: " + multiPatchFC

    fc = fcs.next()
    print "1: " + ds
    # Edit TIN parameters are hard-coded below that could be changed according to application needs
    gp.EditTin_3d(ds, pointFC, " shape shape masspoints true;", lineFC, " shape shape softline true;", multiPatchFC, " shape shape # true")
    pointFC = ""
    lineFC = ""
    multiPatchFC = ""
    print "TIN " + ds + " finished!"


    gp.workspace = "C:\\WorkSpace\\TINs"
    dataset = datasets.next()
    except:
    print gp.getmessages(2)