|
POST
|
You need to specify they are shapefiles. inCover="kreisumring.shp" unionCover="gemeinden.shp" Edit: Ah Jake beats me to it.
... View more
03-26-2012
10:20 AM
|
0
|
0
|
1537
|
|
POST
|
It did run on a mix of 9.3.1 and 10 mxds. Converting them all to 10 in the process. It was only run on a v10 SDE instance though, as that was what we migrated to in our upgrade. All the broken links were to a 9.3.1 SDE. I don't have any 9.3.1 SDE instances left to test this on unfortunately, that may be your problem, though I don't know why that would be an issue.
... View more
03-26-2012
10:13 AM
|
0
|
0
|
2575
|
|
POST
|
Rather inelegant, but should accomplish what you want. try:
mxd = arcpy.mapping.MapDocument("current")
except:
print "in arccatalog!"
... View more
03-22-2012
12:24 PM
|
0
|
0
|
855
|
|
POST
|
Here's the script I used. Are you freezing on the same mxd every time? How many are you converting?
... View more
03-22-2012
06:48 AM
|
0
|
0
|
2575
|
|
POST
|
I have actually run into that issue, but it was more to do with encountering a "corrupt" MXD (I put corrupt in quotes since MXD Doctor found no corrupted items, but once I ran a fix with MXD Doctor it worked fine, so I would call that corrupted). I am not sure what was wrong with it since it opened with ArcMap fine, just with broken links. Running through MXD Doctor showed a bunch of strange modules that were removed when I ran a fix and it processed fine after that. I've mostly seen this behaviour from some v10 .mxd files that were converted from prior version .mxt files, but that may be anecdotal. Not sure if this would be related to your situation or not. When I batched through I fixed about 500 mxds that ran fine once the "corrupted" ones were fixed or removed.
... View more
03-22-2012
05:29 AM
|
0
|
0
|
2575
|
|
POST
|
I have several mxds with broken data sources to SDE after a database move. I am running a script to update the broken data sources and keep getting an error on broken links to table views. All other layers update correctly. Here is the error I get Runtime error <type 'exceptions.ValueError'>: StandaloneTableObject: Unexpected error Here's the relevant code where I am getting the error. brokenlist = arcpy.mapping.ListBrokenDataSources(mxd)
for lyr in brokenlist:
if ".sde" in lyr.dataSource:
try:
lyr.replaceDataSource(new_datasource, "SDE_WORKSPACE", lyr.name) Has anyone encountered this or know a work around? Edit: I've tried it with and without the lyr.name specified.
... View more
03-21-2012
11:13 AM
|
0
|
26
|
9922
|
|
POST
|
Delete the last lyr definition query in your script after the pdf export.
... View more
03-21-2012
10:20 AM
|
0
|
0
|
4031
|
|
POST
|
Try moving your export back one, so it is under the pageNum loop instead of the layer loop. You may want the activeview refresh before the export as well. for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
mxd.dataDrivenPages.currentPageID = pageNum
pageName = mxd.dataDrivenPages.pageRow.STATE_NAME
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.name == maskLayer:
lyr.definitionQuery = '"STATE_NAME" <> %s' % pageName
arcpy.RefreshActiveView()
arcpy.mapping.ExportToPDF(mxd, os.path.dirname(outputFolder)+ os.sep + pageName + ".pdf")
lyr.definitionQuery = ""
... View more
03-21-2012
09:24 AM
|
0
|
0
|
4031
|
|
POST
|
Your main problem is most likely your query. Try this. '"STATE_NAME" <> %s' % pageName Also, that is the wrong format for the overwrite ouput. Use this. arcpy.env.overwriteOutput = True
... View more
03-21-2012
08:07 AM
|
0
|
0
|
4031
|
|
POST
|
You can select all the attributes in a layer using. And if you want to do it a bunch of times use the new selection option. arcpy.SelectLayerByAttribute_management(layer, "NEW_SELECTION")
... View more
03-21-2012
06:31 AM
|
0
|
0
|
1235
|
|
POST
|
There's no problems I can find in the code. The problem may be with your layers or spatial reference.
... View more
03-21-2012
05:59 AM
|
0
|
0
|
1235
|
|
POST
|
Your loops and indentation are important in this case, read this. http://forums.arcgis.com/threads/48475-Please-read-How-to-post-Python-code
... View more
03-21-2012
05:54 AM
|
0
|
0
|
4031
|
|
POST
|
You're script has some indentation/tabify issues as well, at least when I copied it over it did. I cleaned it up a bit and worked fine for me. Also switched your layer name check to this, Wasn't working how it was set up before since the PDFs would be exported with the same name every time. if "flow" in lyr.name.lower(): #Import the arcpy package
import arcpy
#Assign the Western States Mapping Document to variable mxd
mxd = arcpy.mapping.MapDocument("CURRENT")
#Create a data driven pages object using "mxd" and assign it to variable "ddp"
#ddp = mxd.dataDrivenPages
#Create a list of all text elements in the map layout
textlist = arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT")
#Cycle through the text elements
for txt in textlist:
#When you find one whose text says "MAP SUBTITLE"...
if txt.text == r"MAP SUBTITLE":
#....Assign it to variable "subtitle"
subtitle = txt
#Create a list of the layers in the map document
layerlist = arcpy.mapping.ListLayers(mxd, "*flow*")
df = arcpy.mapping.ListDataFrames(mxd)[0]
#Cycle through each layer
for lyr in layerlist:
# if the long layer name does not equal the short layer name
if lyr.longName != lyr.name:
#Find Layer with name == "flow"
if "flow" in lyr.name.lower():
#Pan to Extent of Flow Layer
df.extent = lyr.getExtent()
#df.scale = df.scale * 1.15
arcpy.RefreshActiveView()
#If the layer is NOT visible...
if lyr.visible == False:
#...Turn the layer on
lyr.visible = True
#Change the Subtitle text element to match the layer's name
subtitle.text = lyr.name
#Create a string showing the path of the pdf that will be written out
pdfpath = "C:/test/pdf/" + lyr.name + r" mapbook.pdf"
#Print that we are exporting a mapbook
print "Exporting " + pdfpath + "....."
#Export the mapbook to pdf
arcpy.mapping.ExportToPDF(mxd, pdfpath)
#Turn the layer off again
lyr.visible = False
#Delete variables to clean up memory usage
del mxd
print "Done!"
... View more
03-20-2012
11:27 AM
|
0
|
0
|
2821
|
|
POST
|
In the last code you posted you have a typo I believe. df.extent = lyrs.getExtent() Should be df.extent = lyr.getExtent() Also, you don't need to make two layer lists. Replace your main one with the second one.
... View more
03-20-2012
10:54 AM
|
0
|
0
|
2821
|
|
POST
|
If you are reading values, the search cursor with a where clause is faster. It also depends on what you are extracting and the size of your dataset, the gains may be minimal.
... View more
03-20-2012
10:05 AM
|
0
|
0
|
505
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-17-2011 10:36 AM | |
| 1 | 08-16-2012 10:48 AM | |
| 1 | 10-31-2012 08:39 AM | |
| 1 | 07-16-2012 01:52 PM | |
| 1 | 03-15-2012 10:57 AM |
| Online Status |
Offline
|
| Date Last Visited |
08-22-2024
11:12 PM
|