MakeTableView_management frustrations

2467
2
10-31-2012 08:26 PM
DaveBye
New Contributor
Hi,

ArcGIS 10.0, WinXP

I have a similar issue to that posted in

http://forums.arcgis.com/threads/59172-MakeTableView_management-causes-an-exception-when-outside-of-...

however, though I can get the table added successfully using the following lines in the python immediate window

>>> x = 'P:\\Work\\CMA_LMD\\Users\\dbye\\Data\\2012\\scratch.gdb'
>>> arcpy.env.workspace = x
>>> arcpy.env.workspace
u'P:\\Work\\CMA_LMD\\Users\\dbye\\Data\\2012\\scratch.gdb'
>>> arcpy.MakeTableView_management('bf_201211011009_workspaces', 'test')
<Result 'test'>

the following lines in a script:

arcpy.AddMessage("AddResults ")
x = u'P:\\Work\\CMA_LMD\\Users\\dbye\\Data\\2012\\scratch.gdb'
arcpy.env.workspace = x
arcpy.AddMessage(arcpy.env.workspace)
arcpy.MakeTableView_management('bf_201211011009_workspaces', 'test')

don't work! There is no exception thrown, the script outputs to the gp results window:

...
AddResults
P:\Work\CMA_LMD\Users\dbye\Data\2012\scratch.gdb
Completed script ScanWorkspace2GDB...
Succeeded at Thu Nov 01 15:06:08 2012 (Elapsed Time: 19.00 seconds)

But no table is added to the map document...

I hope I have stared at this way to long and overlooking something simple. What looks like identical code executes perfectly in the python window, but won't work in a script. Note also that I have also set the scratchWorkspace equivalent both in code and environment just in case that's a factor but to no avail.

Any ideas much appreciated. Cheers
Tags (2)
0 Kudos
2 Replies
MathewCoyle
Frequent Contributor
In your Geoprocessing Options, do you have "overwrite the outputs of geoprocessing operations" and "add results of geoprocessing operations to the display" checked?

I also find it odd it takes 19 seconds to make a table view.

Edit: You may have to make a permanent table to see it in your mxd after the tool runs.
0 Kudos
DaveBye
New Contributor
Hi, thanks very much for your reply.

Yes the overwrite and add results options are both set true. I have just re-installed ArcGis Desktop. No fix.

Regarding the time, there was a little bit of code running examining directories, thus the 19 seconds. However this made me
check it up, and the lines of code that run from the python window, and SUCCEED return the following message:

Start Time: Tue Nov 06 09:54:00 2012
Succeeded at Tue Nov 06 09:54:10 2012 (Elapsed Time: 10.00 seconds)

The lines of code, exact, nothing extra running from script, doesn't add the table but reports:

Executing: tester
Start Time: Tue Nov 06 09:55:26 2012
Running script tester...
AddResults
P:\Work\CMA_LMD\Users\dbye\Data\2012\scratch.gdb
Completed script tester...
Succeeded at Tue Nov 06 09:55:27 2012 (Elapsed Time: 1.00 seconds)

Now the other noticeable thing is that the immediate window launches a 'make table view' tool, which shows a normal tool
status message in the status bar, which finally pops up with success. If the script is run without the 'always run in foreground'
option set then the standard 'script' status/result appears but still fails! So I wonder if somehow the actual 'make table view' tool
is actually being launched, or whether the script messages are just hiding the tool's message?

I have attached a small zip with a single table gdb and the code in script, should anyone be able to help further with this.

Cheers,
Dave
0 Kudos