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.
Usage
-
Input feature class or layer must have multipatch geometry.
-
Only closed multipatches will be processed. All other multipatches will be skipped and an error written to the geoprocessing log. Use the Is Closed 3D geoprocessing tool to see if any features are not closed.
The output feature class will not have any of the attributes of the input feature class. If necessary, you can use spatial join to reconnect the attributes from the original input features.
Difference 3D is a 3D set operator as part of the 3D Features toolset. See Working with 3D set operators for more information on what set operators are and how to use them.
Syntax
| Parameter | Explanation | Data 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
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')
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)