Difference 3D (3D Analyst)

Summary

Computes the geometric intersection of two volumes defined by closed multipatch features, based upon the geometric intersection of their patches. Subtracts all the volumes of one feature class from the other and writes the result to a new output feature class.

Learn more about how Difference 3D works

Usage

Syntax

Difference3D_3d (in_features_minuend, in_features_subtrahend, out_feature_class)
ParameterExplanationData Type
in_features_minuend

The collection of multipatch features from which the subtrahend multipatch features will be removed.

Feature Layer
in_features_subtrahend

The collection of multipatch features which will be subtracted from the minuend multipatch features.

Feature Layer
out_feature_class

The multipatch feature class into which the newly generated multipatches will be placed.

Feature Class

Code Sample

Difference 3D Example 1 (Python window)

The following Python Window script demonstrates how to use the Difference 3D function in immediate mode.

import arcpy
from arcpy import env

arcpy.CheckOutExtension('3D')
env.workspace = 'C:/data'
arcpy.Difference3D_3d('input_mp.shp', 'erase_mp.shp', 'difference_mp.shp')
Difference 3D Example 2 (stand-alone script)

The following Python script demonstrates how to use the Difference 3D function in a stand-alone script.

'''****************************************************************************
Name: Difference3D Example
Description: This script demonstrates how to create 
             shadow volumes that fall along a specified surface using the
             Difference3D tool.
****************************************************************************'''
# Import system modules
import arcpy
import exceptions, sys, traceback
from arcpy import env

try:
    # Obtain a license for the ArcGIS 3D Analyst extension
    arcpy.CheckOutExtension('3D')
    # Set environment settings
    env.workspace = 'C:/data'
    # Set Local Variables
    inMP = 'buildings.shp'
    eraseMP = 'bldg_extensions.shp'
    outMP = arcpy.CreateUniqueName('bldgs_without_extensions.shp')
    # Execute Difference3D
    arcpy.Difference3D_3d(inMP, eraseMP, outMP)

except arcpy.ExecuteError:
    print arcpy.GetMessages()
except:
    # Get the traceback object
    tb = sys.exc_info()[2]
    tbinfo = traceback.format_tb(tb)[0]
    # Concatenate error information into message string
    pymsg = 'PYTHON ERRORS:\nTraceback info:\n{0}\nError Info:\n{1}'\
          .format(tbinfo, str(sys.exc_info()[1]))
    msgs = 'ArcPy ERRORS:\n {0}\n'.format(arcpy.GetMessages(2))
    # Return python error messages for script tool or Python Window
    arcpy.AddError(pymsg)
    arcpy.AddError(msgs)

Environments

This tool does not use any geoprocessing environments

Related Topics

Licensing Information

ArcView: Requires 3D Analyst
ArcEditor: Requires 3D Analyst
ArcInfo: Requires 3D Analyst

6/10/2013