Using tool validation to select different feature classes from an input CAD file?

305
0
09-17-2021 04:46 AM
RPGIS
by
Occasional Contributor III

Hi,

I am currently working on a project for creating a custom geoprocessing tool for the web. So far things are working great, the only thing is that I am trying to figure out is if there is a way where I can enable the end user to select the feature classes that reside within the CAD file. I haven't had any luck with this and so I was wondering if maybe it could be the way I am going about it but I wanted to check and see if anyone might be able to either give me some pointers or point me in the right direction. I know CAD files are tricky, especially if they are standalone, but if there is anyone who has written scripts to extract information from these kind of file please let me know.

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.
        CADfile = self.params[2].value
        featureclasses = [fc for fc in arcpy.ListFeatureClasses(CADfile)]
        featureclass = self.params[3].filter
        fcs = featureclass.list[featureclasses]
        SubdivisionLayers = self.params[4].filter
        ParcelsLayers = self.params[5].filter
        RoadLayers = self.params[6].filter
        
        if featureclass:
            attributevalues = [row[0] for row in arcpy.da.SearchCursor(featureclass, ["Layer"])]
            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

 

0 Kudos
0 Replies