2

I have feature layers that have a different name in the TOC then that they do in the GDB. I cannot change either of these and I need the name of the feature class from the GDB in order to make my model work. I have tried things such as parse path but I only get the name of the layer as it is in the TOC.

I have tried a few ArcPy/Python methods, but with my little knowledge of these things, I could not figure out how to get the GDB name as an output parameter.

I am using ArcMap version 10.3.1

Below I have added an example of my model and the code I last used to try and get the name.

Example of model

import os
import arcpy

layer = arcpy.GetParameter(0)

print(os.path.basename(layer))
  • arcpy.Describe(lyr).name – BERA May 21 at 12:13
2

You are trying to treat a spatial dataset as if it is a normal file so you are accessing properties that are not appropriate (i.e. os.path.basename). I would use the Calculate value tool but you could easily adapt your existing script if you wish.

Model

The Calculate value tool is set up as:

Tool

You would change the parameter highlighted in red to what every you are using, don't ignore the quotes around it.

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.