def onSelChange(self, selection): ptoolbox = arcpy.ImportToolbox("D:/ArcGISData/SARS/Python_10April2013/Toolbox.pyt")
Solved! Go to Solution.
Nowhere in the documentation for ImportToolbox does it say to use arcpy.alias.toolname(). It says to use arcpy.toolname_alias(). Your syntax works, the syntax in the documentation does not, which is what led me here. Thanks for the tip, however you discovered it.
That explains it. I had to make the alias and the name identical to get it to work. Next time, I'll try it backwards from the documentation.
R_
I'd like to add that the toolbox name cannot contain spaces, so far as I can tell.
It works fine with spaces, if you're running into issues, post a code snippet and we can take a look. Here's an example of an import which works fine on my end:
arcpy.ImportToolbox(r'z:\pyt with spaces\more spaces.pyt')
# <module 'touche'>
For me, it was a non-python toolbox that caused the spacing issue. (I think. Now I'm second-guessing what I did to fix it).
OK, if you see the same behavior again, post it to GeoNet and we can see what's going on.
Cheers, Shaun