POST
|
This solved the issue I've been having, as well. Is it possible to tweak the code here to browse by file author? Say, something like... <query>searchText=source%3Aauthorname</query>
... View more
09-29-2011
01:53 PM
|
0
|
0
|
567
|
POST
|
Yeah, I just went with a quick and dirty print path after the save step. Works wells enough for me.
... View more
04-11-2011
01:40 PM
|
0
|
0
|
577
|
POST
|
Success! Thanks, Mathew. I ended up plugging your code into the os.walk command from my previously failed code so it would go through recursive directories. The only issue now is I need to find out how to put a progress bar into the code so I don't just stare at "Starting..." for the length of the process. 😉 Final code: import arcpy, os
print "Starting"
arcpy.OverWriteOutput = 1
start = r"X:\ArcGIS"
old_db = r"X:\ArcGIS\Old\Old_GDB.gdb"
old_lyr = r"X:\ArcGIS\Old\Old_GDB.gdb\Old_Units"
new_lyr = "SDE.DBO.New_Units"
new_db = ("Database Connections\server.sde")
for root, dirs, files in os.walk(start):
for file in files:
if file.endswith(".mxd"):
path = os.path.abspath(os.path.join(root, file))
mxd = arcpy.mapping.MapDocument(path)
lyrs = arcpy.mapping.ListLayers(mxd)
for i in lyrs:
if i.supports("DATASOURCE") and i.supports("DATASETNAME") and i.dataSource == old_lyr:
i.replaceDataSource(new_db, "SDE_WORKSPACE", new_lyr, False)
mxd.save()
del mxd
del lyrs
print "Done"
... View more
04-11-2011
12:06 PM
|
0
|
0
|
577
|
POST
|
Jake, Will this work even though I have a new feature name? EDIT: Tried this both with feature names and without. Unknown error on each. Traceback (most recent call last):
File "X:\Python_Code\SubDir_Search_and_Replace_w_SDE.py", line 11, in <module>
r"Database Connections\server.sde\SDE.DBO.New_Units", "SDE_WORKSPACE")
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\utils.py", line 181, in fn_
return fn(*args, **kw)
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\_mapping.py", line 754, in replaceWorkspaces
return convertArcObjectToPythonObject(self._arc_object.replaceWorkspaces(*gp_fixargs((old_workspace_path, old_workspace_type, new_workspace_path, new_workspace_type, validate), True)))
ValueError: MapDocObject: Unexpected error
... View more
04-08-2011
09:42 AM
|
0
|
0
|
577
|
POST
|
After sleeping on it, it would be better to have all of the dates in one shapefile, after all. I didn't realize the Directional Distribution tool can run seperate incarnations based on a single field. So if there were a way to put all of the individual dates into one shapefile, that would be ideal. Sorry for the run-around.
... View more
04-08-2011
09:25 AM
|
0
|
0
|
581
|
POST
|
This script works great when dealing with SHPs and GDBs, but crashes Python when I try to run it for SDE data. What am I doing incorrectly? import arcpy, os
## Input folder containing MXDs you want to change here.
## This should be the root folder.
start = "X:\ArcGIS"
## The os.walk command tells the script to go through
## all subdirectories in the 'start' folder.
for root, dirs, files in os.walk(start):
for file in files:
## This command looks for MXD files and ignores all others.
if file.endswith(".mxd"):
path = os.path.abspath(os.path.join(root, file))
mxd = arcpy.mapping.MapDocument(path)
## The string you want to find, the new string you want to replace it with.
mxd.findAndReplaceWorkspacePaths(r"X:\ArcGIS\OLD.gdb\Old_Units", r"Database Connections\server.sde\SDE.DBO.New_Units")
mxd.save()
del mxd
Everything works fine until I put the SDE connection in.
... View more
04-08-2011
08:45 AM
|
0
|
10
|
1278
|
POST
|
Excellent. Worked like a charm. Thanks much! Dumb question: How do I alter this to use today's date as end? Like so?: # Fun stuff
start = datetime.datetime.strptime(start,"%m/%d/%Y")
end = time.strftime(end,"%m/%d/%Y")
... View more
04-07-2011
03:14 PM
|
0
|
0
|
581
|
POST
|
For this step in the process, yes. For a final product, not necessarily. After I run the Directional Distribution for each date's SHP, I plan on appending the results into a single directional distribution SHP with a date field. So maybe the best way of explaining it would be that I'm looking to run Directional Distribution for each date within a date range. One source point shapefile with start and end dates, one result polygon shapefile with a date field.
... View more
04-07-2011
01:51 PM
|
0
|
0
|
581
|
POST
|
Is there a way to programmatically go through a range of dates, select features that were present on each date, and create a shapefile with each date's features? I have a single shapefile with a [START_DATE] and an [END_DATE] field, both formatted as Date fields. I'm looking for a way to go through a series of dates (say, January 1 through today) and create a series of daily snapshots that will show which features were present on those dates. The kicker is that I need this to be done in a geoprocessing environment because I'd then like to turn around and create Directional Distribution polygons for each date (otherwise I could just turn on the Time Slider and be satisfied with the original SHP). I'm trying to do this in Modelbuilder, but the available Iterators don't seem to include date range functionality. Ideas?
... View more
04-07-2011
12:11 PM
|
0
|
6
|
2086
|
POST
|
Thinking a little further (and I haven't tried this) - you might be able to do an advanced field calculation and within that have the python calls to restart the services via the agssom. Not sure if that would work, but it would be an interesting idea. (maybe I'm just over complicating it now). Hope this helps some I inserted this in my Modelbuilder via Calculated Value and it worked. Now to pull the whole thing together...
... View more
02-04-2011
09:45 AM
|
0
|
0
|
605
|
POST
|
Having an issue getting the batch to run in Python. import os
os.system(r"X:\ArcGIS\Tools\Stop_All_ArcServer_Services.bat") The result is a syntax error. If it helps, the line inside that .bat is X:\ArcGIS\Tools\AGSSOM\AGSSOM.exe [ServerName] -x *all* I can bring this .py file into Modelbuilder, but it won't run. I assume this will be fixed when the syntax error is fixed. [EDIT: It also comes back with syntax error when I substitute the .exe straight up without the .bat]
... View more
02-04-2011
08:57 AM
|
0
|
0
|
605
|
POST
|
Kevin, Thanks for the reply. I'm able to get the batch file to work without any troubles. Am I to assume in your example that MapService1 is where I would enter my service names? If so, could I state *all* to catch all services? Also, to get the arcpy.UpdaterStuff, couldn't I simply create the workflow in Modelbuilder, export as a Python script, and copy-paste the Python code? Or, heck, even just reference the .py output file and nest it in between the batch file calls?
... View more
02-04-2011
06:58 AM
|
0
|
0
|
605
|
POST
|
Is there a way to programmatically export a shapefile or feature class from Modelbuilder that has the current date in its filename?
... View more
02-04-2011
05:46 AM
|
6
|
17
|
23138
|
POST
|
How do I start and stop ArcServer services in a Modelbuilder environment? I'd like to create a tool that stops map services, updates their respective geodatabases, and then restarts the map services. If there's an easier way to do this outside of Modelbuilder, I'm open to that as well.
... View more
02-03-2011
11:42 AM
|
0
|
7
|
3711
|
POST
|
I have a Z-polyline and a list of distances along that line that I need to place points. Is there a tool similar to Construct Points that will consider the Z distance in its calculations? When I try manually with Construct Points, it only considers XY distance and thus the results aren't accurate. Also, is there a way to automate the process so that I can delineate the table field that contains point distances from the beginning line vertex and have the results be the series of points along that line? I'm looking at around 120 points to create so it'd be nice to solve that issue as well.
... View more
11-15-2010
12:25 PM
|
0
|
0
|
2508
|
Title | Kudos | Posted |
---|---|---|
6 | 02-04-2011 05:46 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|