Extract feature classes from CAD file

179
0
09-13-2021 07:01 AM
RPGIS
by
Regular Contributor

Hi,

I am currently working on a tool that converts CAD files submitted by users and then extracts the data and processes it in such a way that we can use that data internally. I need to enable the end user to select or upload the cad dataset and select the type of feature classes that are involved. So my question is, is there a way to set up the tool validation to select all of the feature classes that are in the CAD dataset?

class ToolValidator:
    # Class to add custom behavior and properties to the tool and tool parameters.

    def __init__(self):
        # set self.params for use in other function
        self.params = arcpy.GetParameterInfo()

    def initializeParameters(self):
        # Customize parameter properties. 
        # This gets called when the tool is opened.
        return

    def updateParameters(self):
        # Modify parameter values and properties.
        # This gets called each time a parameter is modified, before 
        # standard validation.
        CAD_Dataset = self.params[2].value
        featureclasses = self.params[3].filter
        fieldname = self.params[4].valueAsText
        SubdivisionLayers = self.params[5].filter
        ParcelsLayers = self.params[6].filter
        RoadLayers = self.params[7].filter
        
        if CAD_Dataset:
            featureclasses.list = [fc for fc in arcpy.ListFeatureClasses(CAD_Dataset)]
            fieldname = "Layer"
            fcfields = [fieldname]
            attributevalues = [row[0] for row in arcpy.da.SearchCursor(featureclass, fcfields)]
            UniqueAttributes = set(attributevalues)
            SubdivisionLayers.list = [str(value) for value in UniqueAttributes]
            ParcelsLayers.list = [str(value) for value in UniqueAttributes]
            RoadLayers.list = [str(value) for value in UniqueAttributes]
            
        return

    def updateMessages(self):
        # Customize messages for the parameters.
        # This gets called after standard validation.
        return

    # def isLicensed(self):
    #     # set tool isLicensed.
    #     return True

Any help on this would be greatly appreciated.

0 Kudos
0 Replies