|
POST
|
This is a 10.1 sample. It used the new cloning functions that allow for creating dynamic tables. A 10.0 sample that uses a static graphic table may be applicable for your work. See: http://www.arcgis.com/home/item.html?id=af4fe32a93554eadbd3be3b0e55326be Jeff
... View more
09-07-2012
01:53 PM
|
0
|
0
|
2028
|
|
POST
|
I tried to reproduce your issue by simplifying your code. It works. I tested on 10.1 final. I added two shapefiles to a new MXD. I renamed one of them so it would appear broken in the MXD. I created a new, empty file GDB. Finally I ran the following, simplified code:
import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Temp\Shapefiles.mxd")# Create a list of SHP in mxd
list = []
df_list = arcpy.mapping.ListDataFrames(mxd)
for df in df_list:
for fc in arcpy.mapping.ListLayers(mxd, "", df):
if (fc.supports("DATASOURCE")) and (fc.dataSource.endswith(".shp")):
list.append(fc)
print list
# Check for broken datasource
for fc in list:
if arcpy.mapping.ListBrokenDataSources(fc):
list.remove(fc)
print list
# Move fc to gdb
ws = r"C:\Temp\Temp.gdb"
for fc in list:
dsc = arcpy.Describe(fc)
arcpy.FeatureClassToFeatureClass_conversion(fc, ws, fc.name)
fc.replaceDataSource (ws, "FILEGDB_WORKSPACE", fc.name)
# Create a new MXD
mxd.saveACopy(r"C:\Temp\Shapefiles2.mxd")
One possible issue is that you are running the code multiple times and the FCs may already exist in the output GDB. You need to remove those manually ahead of time or check to see if they exist and remove them with code before the FeatureClassToFeatureClass function is called. Jeff
... View more
09-07-2012
08:28 AM
|
0
|
0
|
2146
|
|
POST
|
This was cross posted. See response on Map Automation forum: http://forums.arcgis.com/threads/66365-how-to-dynamically-update-a-data-driven-page-excel-table Jeff
... View more
09-07-2012
07:55 AM
|
0
|
0
|
536
|
|
POST
|
Rather than working with the scale text, have you considered working with the data frame scale? Scale text is a string and it is formated differently than the actual data frame scale. It possible to work with scale text but its far more work.
df = arcpy.mapping.ListDataFrames(mxd)[0]
if df.scale < 1350:
#do something
Jeff
... View more
09-07-2012
07:52 AM
|
0
|
0
|
970
|
|
POST
|
This is not built into DDP. In order to generate truely dynamic tables from one page to the next you will need to incorporate arcpy.mapping (a scripting API). There is a sample that demonstrates how to create dynamic tables with arcpy.mapping. http://www.arcgis.com/home/item.html?id=3a525b986b774a3f9cbbd8daf2435852 Jeff
... View more
09-07-2012
06:26 AM
|
0
|
0
|
2028
|
|
POST
|
You may want to give arcpy.mapping.UpdateLayer() a try. http://resources.arcgis.com/en/help/main/10.1/#/UpdateLayer/00s30000003p000000/ This will only work well for you if you have the same layer multiple times in the same MXD or many MXDs. The reason being is that you must first create a layer file with ALL the correct layer properties, including your field aliases. So edit one of them and save it to a layer file. Then you write a script to find all the layers and update them using your authored layer file. Because you want to update ALL properties, set symbology_only=False. When set to false, ALL properties, including the data source will get overwritten. I hope this helps, Jeff
... View more
09-06-2012
06:50 AM
|
0
|
0
|
3891
|
|
POST
|
I did not get the file. I checked my junk folder, etc. Please check the email: [email protected] Thanks, Jeff
... View more
09-06-2012
06:41 AM
|
0
|
0
|
1743
|
|
POST
|
Can you send a map package along with scripts to [email protected] Thanks, Jeff
... View more
09-05-2012
06:29 AM
|
0
|
0
|
1743
|
|
POST
|
I can not reproduce this problem. Our internal tests include MXDs with many DFs. I'm having a difficult time reading your sample code - I see several possible issues with it. Try replacing your data sources with a simple script that does not include functions (not that that is the problem). See the samples in the following topic: http://resources.arcgis.com/en/help/main/10.1/#/Updating_and_fixing_data_sources_with_arcpy_mapping/00s30000004p000000/ Jeff
... View more
09-04-2012
09:12 AM
|
0
|
0
|
1341
|
|
POST
|
A layer in the TOC is a layer regardless of the source. arcpy.mapping.RemoveLayer() should simply work.
mxd = arcpy.mapping.MapDocument("current") #or provide full path to MXD
df = arcpy.mapping.ListDataFrames(mxd, "df name") #replace with actual df name
lyr = arcpy.mapping.ListLayers(mxd, "MyShapeFileLayer")[0] #replace with acutal layer name in TOC
arcpy.mapping.RemoveLayer(df, lyr)
mxd.save()
Jeff
... View more
09-04-2012
08:37 AM
|
0
|
0
|
668
|
|
POST
|
You can change the definition queries via the arcpy.mapping Layer class using the .definitionQuery property. Check out the help: http://resources.arcgis.com/en/help/main/10.1/#/Layer/00s300000008000000/ Jeff
... View more
09-04-2012
08:32 AM
|
0
|
0
|
2295
|
|
POST
|
First you need to join the two data sources. Once joined, you can use a script that is simlar to the one in the help: http://resources.arcgis.com/en/help/main/10.1/#/LabelClass/00s30000002t000000/
mxd = arcpy.mapping.MapDocument("current")
lyr = arcpy.mapping.ListLayers(mxd, "Lines_Clip")[0]
for lblClass in lyr.labelClasses:
lblClass.expression = "[table.ParcelID]" #NOTE - SQL syntax could be different depending on data source
Jeff
... View more
09-04-2012
06:56 AM
|
0
|
0
|
728
|
|
POST
|
You can build the polygons from the bookmark extents using the Polygon class. Check out the following help topic/sample: http://resources.arcgis.com/en/help/main/10.1/#/Polygon/018z00000061000000/ Also, check out the 4th example in the arcpy.mapping DataFrame class help. This also creates a polygon feature. http://resources.arcgis.com/en/help/main/10.1/#/DataFrame/00s300000003000000/ Jeff
... View more
09-04-2012
06:32 AM
|
0
|
0
|
859
|
|
POST
|
The easiest thing to correct is the fact that you are not selecting anything so I'll bet all your output files were identical. I added the arcpy.SelectLayerByAttribute function. But then you should also clear the selection so you don't see the selected feature in the output, etc. import arcpy from arcpy import env from arcpy import mapping env.workspace = r"C:\temp" ###modified this too because I put the shapefile and MXD in the same folder called temp mxd = mapping.MapDocument(r"C:\Temp\Sample.mxd") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] for lyr in arcpy.mapping.ListLayers(mxd): lyr.visible = True fc = r"C:\Temp\Grid.shp" count = str(arcpy.GetCount_management(fc)) x = 0 while x < int(count) + 1: rows = arcpy.SearchCursor(fc, "FID = " + str(x)) arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", "FID = " + str(x)) ######Added this line for row in rows: df.zoomToSelectedFeatures() df.extent = lyr.getSelectedExtent() arcpy.RefreshActiveView() mapping.ExportToJPEG(mxd, r"C:\Temp\Map_" + str(x) + ".jpg", df, df_export_width=3004, df_export_height=2125, world_file=True) print('Exported image',x, 'of', count) x += 1 print("MXD to JPEGs Export successful") print("Thank you!") I personally whould have tried a different approach (without the while loop). Here is a very simple and direct solution: import arcpy mxd = arcpy.mapping.MapDocument(r"C:\Temp\Sample.mxd") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] lyr = arcpy.mapping.ListLayers(mxd, "grid")[0] ##shapefile layer name called grid rows = arcpy.SearchCursor(lyr) x=1 for row in rows: df.extent = row.Shape.extent arcpy.mapping.ExportToJPEG(mxd, r"C:\Temp\Map_" + str(x) + ".jpg", df, df_export_width=3004, df_export_height=2125, world_file=True) print x x+=1 I hope this helps, Jeff
... View more
08-24-2012
02:58 PM
|
0
|
0
|
1532
|
|
POST
|
Yes, arcpy.mapping.ListBookMarks was added to the API at 10.1. Jeff
... View more
08-24-2012
02:11 PM
|
0
|
0
|
1386
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-05-2025 11:20 AM | |
| 3 | 06-05-2025 09:21 AM | |
| 1 | 05-14-2025 01:19 PM | |
| 2 | 04-24-2025 07:54 AM | |
| 1 | 03-15-2025 07:19 PM |
| Online Status |
Offline
|
| Date Last Visited |
06-23-2026
10:29 AM
|