How can I manipulate the TOC display name of my output parameters when using a Python toolbox (.pyt) Tool class. I tried adding a symbology layer, however this has no affect on the TOC name. Is it possible to reference the layer(s) added as output from the execute method of a tool. The expected results are added to map and TOC, but I can't figure out how to manipulate the TOC display name. I could loop through the layers in the TOC after exectution and check each layers datasource, but this seems problematic. I've searched the help and applied the extent of my Google Foo.

In my tool class I define my parameters as follows:

def getParameterInfo(self):
    extent = arcpy.Parameter(
            displayName='Analysis Extent', name='extent_features'
            , datatype='GPFeatureLayer', parameterType='Required'
            , direction='Input')
    extent.filter.list = ['Polygon', ]

    tilelayer = arcpy.Parameter(
            displayName='Analysis Tiles', name='tile_layer'
            , datatype='GPFeatureLayer', parameterType='Required'
            , direction='Output')
    tilelayer.symbology = os.path.join(os.path.dirname(__file__), 'pyltk/analysis_tiles.lyr')

Follow Up: This normally would not be a problem as the output would reflect the name of the feature class. However, I've been evaluating the use of the new SQLite workspace for integration with external libraries, etc. ArcGIS prepends the internal SQLite database name 'main' to all my feature classes and tables. When ArcPy adds the results to the map it only adds the database name, and not the whole name. For instance if the output feature class is called "..\analysis_tiles" ArcGIS will refer to this as "..\main.analysis_tiles", but the resulting TOC name is just "main".

1 Answer 1


What name does the output layer have? I would think it would be "Analysis Tiles"...

If that's not what is happening I think an approach that would work would be to create a layer in your script and return it as a derived parameter, with the layer returned using SetParameterAsText().

  • The output layer name reflects whatever I name the feature class. The displayName and name arguments to Parameter() only specify properties for the Tool and not the output. SetParameterAsText() is a script tool (in a .tbx) method. It did nothing for me in the context of a Python Toolbox.
    – tharen
    Jul 7, 2014 at 19:17
  • Seems to me the best solution is to set up an output GPLayer as a derived parameter, this gives you full control of the layer. But this doesn't really solve the problem as I suspect your feature class and layer outputs will both be added to the TOC. Jul 7, 2014 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.