I have an arcpy/python script using ArcGIS10 and using a custom toolbox and model. The toolbox has an alias of defaultTopo and my model within the toolbox is called AddRuleToTopologyModel. This model was created because there is a known bug when calling the AddRuleToTopology_management tool for the Must Be Covered by Feature Class of (Area-Area) rule from python and the work around is to use this model. I'm simply updating my script from 9.3 to 10.0.
The code goes like this:
# Defining location of toolbox which is in the same location as the script
toolboxLocation = sys.argv[0][:sys.argv[0].rfind('\\')]
# Importing custom toolbox
arcpy.ImportToolbox(toolboxLocation+"\ApplyDefaultTopology.tbx")
# Calling custom model for polygon feature class - not all the variables are posted here
arcpy.AddRuleToTopologyModel_defaultTopo(featureDataset+"\\"+topologyName,'Must Be Covered By Feature Class Of (Area-Area)',featureClass,featureDataset+"\\"+boundaryFC)
Now if i run the script from Eclipse it does not pick up my featureDataset location I use as argv1 in the script throwing the error I have in place.
If I try and run the script from ArcCatalog I get the following error:
<type 'exceptions.AttributeError'>: 'module' object has no attribute 'exists'
Eclipse also tells me that arcpy.AddRuleToTopologyModel_defaultTopo() is an undefined variable when trying to only use arcpy.
The strange thing is if i use gp.arcgisscripting(9.3) with gp.AddToolbox() to replace arcpy.ImportToolbox() the script runs fine from Eclipse and ArcCatalog because arcpy still supports the 9.3 geoprocessing object. I've been asked to remove all references to the arcgisscripting module and make the new script pure arcpy to function on our new servers.
Thoughts?
Thanks in advance.
arcpy.ImportToolbox(toolboxLocation+"\\ApplyDefaultTopology.tbx")– Fezter Dec 7 '12 at 1:03'\'is included inside the double quotes. I did tryarcpy.ImportToolbox(toolboxLocation+"\\"+"ApplyDefaultTopology.tbx")and it did not work either. If i usegp.AddToolbox(toolboxLocation+"\ApplyDefaultTopology.tbx")it works fine. Very strange. – danagerous Dec 7 '12 at 4:04