sbrennan

Can't get output parameter of Python toolbox tool to work in Model Builder

Discussion created by sbrennan on May 19, 2014
I have written some tools to help with mosaic dataset creation. By themselves, these tools work fine. However, whenever I try to chain them together in model builder, the mosaic dataset output of the Create Mosaic Dataset-based tool doesn't work properly as the input of the Add Rasters-based tool. I believe it is an issue with the "add rasters" tool (UpdateMosaicsFromRasterCatalog). I've attached an image to show how the tool stays white even though both inputs are specified. When the model is run, it just stops at the second tool with no error. See code below:

class UpdateMosaicsFromRasterCatalog(object):
    
    ...
    
    def getParameterInfo(self):
        """Define parameter definitions"""
        param0 = arcpy.Parameter(
            displayName="Input Mosaic Dataset",
            name="input_mosaic_dataset",
            datatype="DEMosaicDataset",
            parameterType="Required",
            direction="Input")
            
        param1 = arcpy.Parameter(
            displayName="Source Raster Catalog(s)",
            name="source_raster_catalogs",
            datatype="DERasterCatalog",
            parameterType="Required",
            direction="Input",
            multiValue=True)
            
        param2 = arcpy.Parameter(
            displayName="Output Mosaic Dataset",
            name="outout_mosaic_dataset",
            datatype="DEMosaicDataset",
            parameterType="Derived",
            direction="Output")
            
        param2.parameterDependencies = [param0.name]
        
        return [param0, param1, param2]

    def execute(self, parameters, messages):
        """The source code of the tool."""
        # Script arguments
        mosaicDataset = parameters[0].valueAsText
        rasterCatalogs = parameters[1].valueAsText
        
        #split the raster catalogs selected by the user
        #and loop through them, adding them to the mosaic
        rcList = rasterCatalogs.split(";")
        for rc in rcList:
            messages.AddMessage("Updating " + mosaicDataset + " from " + rc)
            try:
                arcpy.AddRastersToMosaicDataset_management(mosaicDataset, "Table", rc, "UPDATE_CELL_SIZES", "UPDATE_BOUNDARY", "NO_OVERVIEWS", "#", "0", "1500", "#", "#", "SUBFOLDERS", "OVERWRITE_DUPLICATES", "NO_PYRAMIDS", "NO_STATISTICS", "NO_THUMBNAILS", "#", "NO_FORCE_SPATIAL_REFERENCE")
            except Exception as e:
                messages.AddMessage("Update Mosaic Dataset From Raster Catalog failed.")
                messages.AddErrorMessage(e.message)
        return








[ATTACH=CONFIG]33895[/ATTACH]

Attachments

Outcomes