Script & Tool之CreateFetureClasses

 批量创建图形结构

import arcpy,os,sys,string
out_path = arcpy.GetParameterAsText(0)
in_feature_classes = arcpy.GetParameterAsText(1)
#out_path="Database Connections\gisinfo116.sde\gisinfo.bj"
#in_feature_classes="d:\nanning\cydl.shp"
def SplitMulti(multi_input):
    try:
        # Split the multivalue on the semi-colon delimiter
        #
        multi_as_list = string.split(multi_input, ";")
        return multi_as_list
    except:
        ErrDesc = "Error: Failed in parsing the inputs."
        raise StandardError, ErrDesc


in_feature_classes = SplitMulti(in_feature_classes)  
for in_feature_class in in_feature_classes:
    try:
        FeatureNames=in_feature_class.split("\\")
        leng=len(FeatureNames)-1
        FeatureName=FeatureNames[leng].replace(".shp","")
        arcpy.CreateFeatureclass_management(out_path,FeatureName,"",in_feature_class)
    except StandardError, ErrDesc:
        arcpy.AddWarning("Failed to create: " + in_feature_class)
        arcpy.AddWarning(ErrDesc)
    except:
        arcpy.AddWarning("Failed to create: " + in_feature_class)
        if not arcpy.GetMessages(2) == "":
            arcpy.AddError(arcpy.GetMessages(2))

转载自:https://blog.csdn.net/gisinfo/article/details/6712364

You may also like...