namespace collisions with ET Geowizards tools

121 views
Skip to first unread message

Ryan

unread,
Jan 15, 2013, 12:45:20 PM1/15/13
to geop...@googlegroups.com
Hi all,
My apologies for a seemingly basic problem.  I've spent quite some time searching for a solution, but can't seem to understand how to avoid a namespace collision on the ETGeowizards tools in the below script.  What I can't seem to find is how to assign an alias to a third party tool.  I don't see that option in ArcCatalog.  If I was importing from a module I understand I can write 'import blah as blahblah', but what is the syntax for a tool in the ETGeowizards toolbox?  Moreover, is that my problem??
I'm using three ETG tools: clean pseudo nodes, clean dangling nodes, and build polygons, all found in the same toolbox.  Cleaning the pseudo nodes works, but then the script fails when starting to clean the dangling nodes.

Thanks in advance for any assistance, and feel free to critique my hackish code!

import arcpy
import os.path
from arcpy import env
arcpy.ImportToolbox("C:\\Program Files\\ET SpatialTechniques\\ET GeoWizards 10.0 for ArcGIS 10\\ET GeoWizards.tbx")
arcpy.gp.toolbox = "C:\\Program Files\\ET SpatialTechniques\\ET GeoWizards 10.0 for ArcGIS 10\\ET GeoWizards.tbx"
arcpy.env.overwriteOutput = True

#Clean pseudo_nodes
env.workspace = ("C:\\clipped")
infile = arcpy.ListFeatureClasses()

for i in infile:
    try:
    outdir1 = ("C:\\clipped\\pseudo")
    outfile = (i[0:-4]+"_pseudo")
    out_pseudo = os.path.join(outdir1,outfile)
        #print out_pseudo
    arcpy.gp.ET_GPCleanPseudo(i,out_pseudo,"CONTOUR")#
    except:
        print "ERROR cleaning pseudo nodes for file"+" "+i
        print arcpy.GetMessages()

#Clean dangling nodes
env.workspace = ("C:\\clipped\\pseudo")
cleaned_pseudo = arcpy.ListFeatureClasses()

for p in cleaned_pseudo:
    outdir2 = ("C:\\clipped\\dangle")
    outfile = (p[0:-4]+"_dangles")
    out_dangle = os.path.join(outdir2,outfile)
    arcpy.gp.ET_GPCleanDanglingNodes(p,out_dangle,"100","true","0.1347292352")#

#Build polygons
env.workspace = ("C:\\clipped\\dangle")
cleaned_dangles = arcpy.ListFeatureClasses()
for d in cleaned_dangles:
    outdir3 = ("C:\\clipped\\polys")
    outfile = (d[0:-4]+"_polys")
    out_outpoly = os.path.join(outdir3,outfile)              
    arcpy.gp.ET_GPBuildPolygons(d,d[0:-4]+"_poly","true", "0.132412515869")#
   

Fran Tarkington

unread,
Jan 15, 2013, 1:38:57 PM1/15/13
to geop...@googlegroups.com
Hey Ryan

Good question. Toolboxes can get confusing especially when you are using 3rd party or custom toolboxes.  I think you might be able to create a kind of namespace for your toolbox when you import it using the syntax below:

The pathing stuff was changed just to make it a little easier to read in the email, but doesn't make any difference.  The part to pay attention to is how the ImportToolbox is called.

import arcpy
import os.path
from arcpy import env

path2Toolbox = r"C:\Program Files\ET SpatialTechniques\ET GeoWizards 10.0 for ArcGIS 10\ET GeoWizards.tbx"

arcpy.ImportToolbox(path2Toolbox, "ettools"
arcpy.env.overwriteOutput = True

Now when you want to use a tool in the ET GeoWizards toolbox you will do so using the "ettools" suffix.  Example:

 ...
 arcpy.gp.ET_GPBuildPolygons_ettools(d,d[0:-4]+"_poly","true", "0.132412515869")

As to whether this is going to solve your problem, I'm not sure, but its one way to be sure you are referring to a tool in a toolbox where there may be naming conflicts.

My suspicion is though, is that the problem you are experiencing is more likely to do with either the tool itself or invalid arguments that are being send to it.

Hope this helps 

Cheers

Kevin




   

--
You received this message because you are subscribed to the Google Groups "Python - ARCGIS geoprocessing" group.
To view this discussion on the web visit https://groups.google.com/d/msg/geopython/-/17R5Zhp83n0J.
To post to this group, send email to geop...@googlegroups.com.
To unsubscribe from this group, send email to geopython+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/geopython?hl=en.

Ryan

unread,
Jan 15, 2013, 5:38:35 PM1/15/13
to geop...@googlegroups.com
Yes!  Thanks Kevin, that is the direction I needed.  However, admittedly, that wasn't the issue I was having... as you correctly pointed out it was another problem: a typo.  Yeesh.  Anyway, as usual with my rudimentary coding skills the answer is obvious once it's in front of me...  and I often find the crux of problem solving to be knowing what search terms to use on google.

Regards,

Ryan.
Reply all
Reply to author
Forward
0 new messages