access feature class properties through ValueTable?

362
1
01-14-2013 01:25 PM
AdamCox1
Occasional Contributor II
Hello,

I'm working on a script that basically does one simple thing, append a bunch of feature classes in one geodatabase to corresponding fc's in another geodatabase (there's more to it, but there's no problem with that path of the script).  I'm creating a log file to record the results, and there's something I want to do, but I just don't think it'll work.

As parameters for the tool, I have only the target geodatabase, and then a multivalue input for all of the feature classes.  In the script, the latter parameter comes in as a ValueTable, and I'm able to do what I need by accessing the feature classes with a while loop. 

However, I'm hoping to be able to take the first feature class, and work backward to automatically locate my newly created logfile in the folder that holds the original geodatabase.  I struggled with this for a while, and found that the problem is that the values in the ValueTable to do not have paths.

I've looked for a way of finding the containing folder/workspace of a feature class, but have come up short.

Any ideas?  Of course I can add a parameter that can just be filled in with a folder path, but I'd prefer to automate this.

Thanks,
Adam
Tags (2)
0 Kudos
1 Reply
AdamCox1
Occasional Contributor II
Just thought I'd update this because I've long since fixed this issue.  In 10.0, multiple input parameters create ValueTables, though I've recently upgraded to 10.1 and found that lists are created in that version.  So this only applies to 10.0.

To access the feature classes in the ValueTable, I use the following code:
import arcpy

#the following workspace parameter holds the path to the geodatabase
gdb_path = GetParameterAsText(0)

#with the toolvalidator script, the following multivalue string parameter is
#automatically populated with the names of each feature class in the above
#geodatabase. that way the user can select specific feature classes.
#use GetParameter to acquire it as a ValueTable
fc_list = GetParameter(1)

x = 0
while x < fc_list.rowCount:
    fc_name = fc_list.getTrueValue(x, 0)
    fc = gdb_path + os.sep + fc_name
    #do something
    x+=1
0 Kudos