POST
|
I'm going from a .gdb to an SDE. - I'm running ArcInfo 10 SP3 on my client; and - ArcSDE 9.3 (not sure of the service pack) on the server.
... View more
12-15-2011
10:48 AM
|
0
|
0
|
452
|
POST
|
Hi Chris, I've crafted this script to skip MXDs that have no broken links. Since the script only works through the first iteration I am forced to run the script multiple times until all my MXDs have their data sources fixed. Each time I run this script, the previously fixed MXD is skipped. So, the issues seems to be with the "replaceDataSources" line only. It's as though this function is locked in the first iteration.
... View more
12-13-2011
12:02 PM
|
0
|
0
|
452
|
POST
|
The error I am getting is: brknItem.replaceDataSource(workspace, "SDE_WORKSPACE", item)
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\utils.py", line 181, in fn_
return fn(*args, **kw)
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\_mapping.py", line 585, in replaceDataSource
return convertArcObjectToPythonObject(self._arc_object.replaceDataSource(*gp_fixargs((workspace_path, workspace_type, dataset_name, validate), True)))
ValueError: Layer: Unexpected error
... View more
12-13-2011
04:56 AM
|
0
|
0
|
452
|
POST
|
I would like to use this code, but it only works through the first iteration. Can someone find my error? My error handlers catch errors only in this code block: try:
brknItem.replaceDataSource(workspace, "SDE_WORKSPACE", item)
print "\t item successfully replaced"
except:
print "\t error occured replacing layer" Code is pasted below: # Import arcpy module
import arcpy, os
dir = "path to mxd files"
workspace = "path to new datasource"
for file in os.listdir(dir):
if file.startswith("Sector"):
file = os.path.join(dir, file)
print "\n\n" + file
mxd = arcpy.mapping.MapDocument(file)
brknList = []
brknList = arcpy.mapping.ListBrokenDataSources(mxd)
if len(brknList) > 0:
print "\nlist of broken data sources: "
for lyr in brknList:
print "\t" + lyr.datasetName
print "\nreplacing layers"
for brknItem in brknList:
if brknItem.datasetName != "EPOISicCodeTABLE":
arcpy.AddMessage("\t" + brknItem.datasetName)
print "\t" + brknItem.datasetName
item = brknItem.datasetName
try:
brknItem.replaceDataSource(workspace, "SDE_WORKSPACE", item)
print "\t item successfully replaced"
except:
print "\t error occured replacing layer"
print arcpy.GetMessages(2)
try:
mxd.save()
except:
print "\t an error occured w/ saving %s" % file
print "done"
del mxd
... View more
12-12-2011
11:30 AM
|
0
|
0
|
452
|
POST
|
Thanks for your response. After some searching I managed to find an example of a tool that will do exactly what I'm looking for. For anyone else looking to do the same, here is the link: Generating a choice list from a field
... View more
09-19-2011
08:00 AM
|
0
|
0
|
187
|
POST
|
Is there a data type that allows me to list row data from a specific field right within a script's UI? I'm trying to enhance my script tool by allowing users to choose a row from a feature class right within the Script's UI. Currently the script requests X Y coordinates in a text box. Ideally, rows from a user-specified feature class should be updated dynamically and listed in a drop down menu (similar to what you can do with listing fields from a feature class within a script's UI). Any idea's or suggestions? Thanks Sebastian
... View more
09-16-2011
08:22 AM
|
0
|
2
|
403
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|