Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm running the following tool in ArcGIS 10. I have an ArcPy Script like this:

import arcpy
from arcpy import env
env.workspace=r"C:/sde/lcimrl.sde"
fc="SDE.ATTACHMENTS\SDE.attachment_points"
fcRows = arcpy.SearchCursor(fc, "OBJECTID = 11365")
for row in fcRows: 
   print "I found one"

The feature with OBJECTID 11365 is just created.

It can find the feature if I run it as standalone script. But when I run it in the ArcMap's interactive python window or import it into a ArcTool toolbox and then run it, it cannot find the feature.

I have to force the refresh of the SDE connection in the ArcCatalog, and then I can get the point. Or I have to wait for a while, like several hours, then it can find the point.

I tried arcpy.ClearWorkspaceCache_management() and arcpy.refreshTOC(). They do not help.

Any help is appreciated.

share|improve this question
    
i get several errors using the interactive python shell in Arcmap, my advice is to use PyScripter. –  geogeek Dec 13 '12 at 14:05
    
I have to publish it as a geoprocessing service. So I need to test it in the toolbox first, but I got this issue. I use the interactive python window only to confirm the issue. –  Alex Dec 13 '12 at 17:02
    
You are using raw notation in this section r"C:/sde/lcimrl.sde" but that normally means that you need backslashes. perhaps remove the r from the line or replace / with \ and see if that is the issue. –  Dan Patterson Dec 13 '12 at 17:25
    
tried to remove the r, no help. –  Alex Dec 13 '12 at 18:25
    
The r would not be the problem. It automatically escapes the forward slashes and is a standard way to make paths safe on Windows. Clutching at straws here but did you save/commit your new feature before searching for it? If not, it wont 'exist'. –  MappaGnosis Jan 9 '13 at 8:43
show 1 more comment

1 Answer 1

up vote 2 down vote accepted

If I read this right, it sounds like you are a bit familiar with arcpy refresh issues. I believe you will be able to get by this if you use

arcpy.RefreshCatalog()

arcpy.RefreshCatalog documentation

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.