English

How To: Create a TIN with Avenue

Summary

This article contains basic instructions on how to create a TIN data set using Avenue code. The 3D Analyst extension is required.

Procedure

The following steps will demonstrate how to create a TIN using a point shapefile and a polygon shapefile. There are different enumerations to the AddShapesFromFTab request that will allow you to use different data sources. Please reference the ArcView Online Help for the entire listing.

Please note the use of "Null" field objects created in the code. These are used when the values of "<None>" are specified in the Create TIN dialog.

When creating a TIN with code, always add the FTab containing Z values to the new TIN first.

  1. Add the desired shapefiles to a view.
  2. Copy and paste the following code into a new script window.

    Note:
    Be sure to change the referenced themes in the FindTheme requests below to match your data.


    Code:
    'Sets some necessary variables.
    theView = av.GetActiveDoc
    thePointTheme = theView.FindTheme("Point.shp")
    thePolyTheme = theView.FindTheme("Polygon.shp")
    pointFTab = thePointTheme.GetFtab
    polyFTab = thePolyTheme.GetFTab

    'Prepares the field variables to be used in the TIN creation.
    pointHeight = pointFTab.FindField("Z")
    nullField = Field.Make("NO_DATA",#FIELD_DECIMAL,16,0)
    valueField = Field.Make(" ",#FIELD_DECIMAL,16,0)
    theBox = thePolyTheme.ReturnExtent

    'Create the TIN
    theTIN = TIN.MakeNew("c:\temp\testtin".AsFileName,theBox)
    theTIN.SetEditable
    theTIN.AddShapesFromFTab(pointFTab,pointHeight,#SURFACEFEATURE_TYPE_MASS,valueField,Prj.MakeNull)
    theTIN.AddShapesFromFTab(polyFTab,nullField,#SURFACEFEATURE_TYPE_ZLESS_SOFTCLIP,valueField,Prj.MakeNull)
    theTIN.StopEditing(TRUE)

    'Creates a new TIN theme and adds it to theView
    theTheme = STheme.Make(theTIN)
    theView.AddTheme(theTheme)
    theTheme.SetVisible(TRUE)
    theTheme.SetActive(TRUE)
    theView.Invalidate

  3. Compile the code.
    [O-Image] Script compile button
  4. Click on the view and then script window.
  5. Run the script.
    [O-Image] Run compiled script button