# Name: SplitFeatures_sample2.py
# Description: Gets all feature classes in a geodatabase and splits them on the selected cutting feature
# Import System Modules
import arcpy
import os
# Check Out Extensions
arcpy.CheckOutExtension('Foundation')
# Setting Local Variables
cutting_features = r'C:\Temp\MapIndex.gdb\Index_Polygons'
target_database = r'C:\Temp\Test.gdb'
# Getting feature classes from the target geodatabase that are managed in a feature dataset
target_features = r''
arcpy.env.workspace = target_database
datasets = arcpy.ListDatasets('*', 'Feature')
for dataset in datasets:
fclasses = arcpy.ListFeatureClasses('*', '', dataset)
for fclass in fclasses:
desc = arcpy.Describe(fclass)
if desc.shapeType in ('Polygon', 'Polyline'):
target_features += os.path.join(target_database, dataset, fclass) + ';'
target_features = target_features[:-1]
# Setting selection on cutting features
selected_feature = arcpy.management.MakeFeatureLayer(cutting_features, 'AOI').getOutput(0)
arcpy.management.SelectLayerByAttribute(selected_feature, 'NEW_SELECTION', "PRODUCT_ID = 'V795X16573'")
# Splitting all features in a database based on the selected cutting feature
arcpy.topographic.SplitFeatures(selected_feature, target_features, 'DONT_USE_TARGET_Z')
# Check In Extensions
arcpy.CheckInExtension('Foundation')