The case I have found does not use an input featureclass. I am creating a featureclass from an interactive featureset. It seems that the 'relative' option on the tool properties does not handle unexpected root paths. Maybe the template needed for this datatype is not being parsed properly. I try to make all my own 'home' calculations by parsing the location of the script using python functions.home2 = os.path.dirname(os.path.dirname(sys.argv[0])).replace("\\","/")
domain = os.path.basename(home)
arcpy.AddWarning(domain)
basews = home+"/base.gdb"
scratchws = home+"/scratch.gdb"
Using a layer source only applies if you are running tools interactively and in process in ArcMap. I want to also run tools for debugging, and in ArcCatalog.try:
lay = arcpy.mapping.ListLayers(mxd,"Domain")[0]
if lay.supports("DATASOURCE"):
source = lay.dataSource
home = os.path.dirname(os.path.dirname(source)).replace("\\","/")
except :
if source:
home = os.path.dirname(os.path.dirname(source)).replace("\\","/")
else:
arcpy.AddError("Domain layer missing in MXD, cannot find Domain location")
sys.exit()
This lack of robustness for paths is a serious impediment to distribution of reliable tools and models.I know that it is very hard for Esri to support relative paths when Microsoft only provides grudging support to be POSIX compliant.It is a problem with COM or .NET or Python? It would be helpful to know to avoid and build reliable workarounds.