|
POST
|
If you send me a map package of an isolated area along with your script, I take a look at it. Send to [email protected]. Jeff
... View more
01-06-2012
05:16 AM
|
0
|
0
|
1424
|
|
POST
|
Have you looked at the methodology outlined in the "arcpy.mapping MapBook with Index Pages" sample on the resource center? There is a very complete README doc. http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=FBE3D235-1422-2418-8820-E071ED243854 Jeff
... View more
01-06-2012
05:13 AM
|
0
|
0
|
1183
|
|
POST
|
Have you looked at the methodology outlined in the "arcpy.mapping MapBook with Index Pages" sample on the resource center? There is a very complete README doc. http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=FBE3D235-1422-2418-8820-E071ED243854 Jeff
... View more
01-06-2012
05:06 AM
|
0
|
0
|
1024
|
|
POST
|
I tested the following code using your MXD. I tried loading the code into the Python window and running it as a script tool from within ArcMap and it works just fine. mxd = arcpy.mapping.MapDocument("CURRENT")
legend = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT")[0]
legend.adjustColumnCount(2)
mxd.saveACopy(r"C:\Temp\AdjustColumns.mxd") I also ran this as a stand-alone script using the full MXD path and that worked too. All resulting MXDs opened as expected. import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Temp\correctly_saved.mxd")
legend = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT")[0]
legend.adjustColumnCount(2)
mxd.saveACopy(r"C:\Temp\AdjustColumns.mxd") Can you try the tests above? If you can't repro with these simple scipts, then the issue is somewhere else in your code. Jeff
... View more
01-05-2012
12:01 PM
|
0
|
0
|
1424
|
|
POST
|
These properties are read/write. 10.1 is available now in beta. 10.1 final is scheduled to be available sometime in Q2. Jeff
... View more
01-05-2012
05:54 AM
|
0
|
0
|
1107
|
|
POST
|
This is a know issue (NIM070882) and will be addressed in SP4. In the meantime, run your script as a stand-alone script (i.e., not using CURRENT) and it should work fine. Jeff
... View more
01-03-2012
05:38 AM
|
0
|
0
|
1594
|
|
POST
|
If the dataset name is different you must use lyr.replaceDataSource() A dataSource = workspace_path + dataset_name The syntax is lyr.replaceDataSource(workspace_path, workspace_type, dataset_name, {validate}) You are setting the workspace_path=the entire dataSource. No, break it up and specify the workspacePath and datasetName as two separate parameters. So your code should be something like: layer.replaceDataSource(row[1], "CAD_WORKSPACE", row[0])
Jeff
... View more
12-30-2011
06:12 AM
|
0
|
0
|
2311
|
|
POST
|
I think I was able to get this to work by modifying how the df.spatialReference was being set. See the modified code below. 4 new lines are commented as "NEW LINE".
import arcpy
arcpy.AddMessage("Begin Processing:")
country_selected = arcpy.sys.argv[1] #country name as String
arcpy.AddMessage(country_selected + "...")
arcpy.env.workspace = r"C:\temp"
mxd = arcpy.mapping.MapDocument("CURRENT")
arcpy.AddMessage("=============")
volc_list = []
SR_list = []
for df in arcpy.mapping.ListDataFrames(mxd):
arcpy.AddMessage("DataFrame Found: " + df.name)
if df.name == "Location_Map":
mxd.activeView = df.name
arcpy.AddMessage("Layers DataFrame was found: " + df.name)
for lyr in arcpy.mapping.ListLayers(mxd,"",df):
if lyr.name == "Provinces":
arcpy.AddMessage("The layer found: " + lyr.name)
expression = ""'"NAME"'" = '"+country_selected+"'"
arcpy.AddMessage(expression)
arcpy.SelectLayerByAttribute_management(lyr,"NEW_SELECTION",expression)
countryextent = lyr.getSelectedExtent()
minX = countryextent.XMin
minY = countryextent.YMin
maxX = countryextent.XMax
maxY = countryextent.YMax
difX = (maxX - minX) / 2
difY = (maxY - minY) / 2
cenX = minX + difX
cenY = minY + difY
arcpy.AddMessage("Center X: " + str(cenX))
arcpy.AddMessage("Center Y: " + str(cenY))
#spref = df.spatialReference.exportToString()
SR = df.spatialReference #NEW LINE
spref = SR.exportToString() #NEW LINE
arcpy.AddMessage(spref)
SR_list = spref.split(",")
SR_list[16] = str(cenX) + "]" # long of center
SR_list[18] = str(cenY) + "]" # lat of center
SR_outstring = ",".join(SR_list)
arcpy.AddMessage("==================================")
arcpy.AddMessage(SR_outstring)
#df.spatialReference.loadFromString(SR_outstring)
SR.loadFromString(SR_outstring) #NEW LINE
df.spatialReference = SR #NEW LINE
arcpy.RefreshActiveView()
... View more
12-30-2011
05:46 AM
|
0
|
0
|
822
|
|
POST
|
I tested several scenarios using DXF and DWG. I reproduced the error once until I realized the mistake. 1) CAD layers are often group layers but you can't change a data source on a group layer. 2) Make sure you get the name correct. The default layer name is not the same as the feature class name. For example, the layer name may be "buildings.dxf Point". You must use "Point" as the dataset_name value, not the whole string. Here are the tests that I did:
import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Temp\CAD.mxd")
'''CAD files are being remapped from a folder called Drive_A to a
folder called Drive_B. Also, in the MXD, I renamed the layers to
represent only the feature class name in the CAD file.'''
#Test #1
mxd.findAndReplaceWorkspacePaths("Drive_A", "Drive_B")
mxd.saveACopy(r"C:\Temp\CAD_Test1.mxd")
del mxd
#Test #2
mxd = arcpy.mapping.MapDocument(r"C:\Temp\CAD.mxd")
for lyr in arcpy.mapping.ListLayers(mxd):
lyr.findAndReplaceWorkspacePath("Drive_A", "Drive_B")
mxd.saveACopy(r"C:\Temp\CAD_Test2.mxd")
del mxd
#Test #3
mxd = arcpy.mapping.MapDocument(r"C:\Temp\CAD.mxd")
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.isGroupLayer == False:
lyr.replaceDataSource(r"C:\Active\ArcPY\ScrumWorks\Data\Drive_B",
"CAD_WORKSPACE", lyr.name)
mxd.saveACopy(r"C:\Temp\CAD_Test3.mxd")
... View more
12-29-2011
12:11 PM
|
0
|
0
|
2311
|
|
POST
|
Have you tried the DDP.exportToPDF function? It has a parameter called mulitple_files. I think you would want to set the value to "PDF_MULTIPLE_FILES_PAGE_NAME". Jeff
... View more
12-29-2011
06:52 AM
|
0
|
0
|
2047
|
|
POST
|
I'll do some testing with CAD files. In the meantime, have you tried MXD.findAndReplaceWorkspacePaths? Jeff
... View more
12-29-2011
06:18 AM
|
0
|
0
|
2311
|
|
POST
|
Try this: This issue appears to be with the video player. Usually, when the video gets played once it repeats the play and starts from the beginning. So, the suggestion here would be to change the video player �??play�?? settings and turn off the �??repeat after playing once�?� option. This setting could be different for different players. For example, in Windows media Player it is called �??Turn repeat on/off�?�. Jeff
... View more
12-22-2011
12:05 PM
|
0
|
0
|
657
|
|
POST
|
No there is not. You would need to author the layer file with all the layer properties and then use it with UpdateLayer. This doesn't make sense if you only want to update one or two layers but if you want to update the same layer multiple times in multiple MXDs it may be worthwhile. Jeff
... View more
12-21-2011
06:16 AM
|
0
|
0
|
1766
|
|
POST
|
Arcpy.mapping does NOT have access to graphics in Data View. I've done something similar to this in the past. It was a work around but it worked. If you know the map coordinates of the corners of your data frame and you know the page coordinates of the corners of your data frame then you can move existing page elements so they align with the appropriate spot on the data frame. For example, if your X coordinate is 20 percent across the data frame map unit X range, then you set the X page unit of the graphic element to be 20 percent across the data frame element in page units. The following sample on the Resource Center uses similar logic: http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=FFBB051B-1422-2418-88A0-9DD853478BA3 Jeff
... View more
12-20-2011
06:27 AM
|
0
|
0
|
2562
|
|
POST
|
Here is an example from the arcpy.mapping Sample Script Tools download from the Resource Center: http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=A910AB18-1422-2418-3418-3885D388EF60 The script replaces layer data sources from a personal GDB to a fGDB. It also updates the layer defintion query so the SQL syntax is correct.
#Read parameters from dialog
inputGDB = arcpy.GetParameterAsText(0) #Input personal GDB
outputGDB = arcpy.GetParameterAsText(1) #Output file GDB
inputMXD = arcpy.GetParameterAsText(2) # Input MXD
outputMXD = arcpy.GetParameterAsText(3) #Output MXD
updateSQL = arcpy.GetParameter(4) #Update SQL query
#Update pGDB TO fGDB
mxd = arcpy.mapping.MapDocument(inputMXD)
mxd.replaceWorkspaces(inputGDB, "ACCESS_WORKSPACE", outputGDB, "FILEGDB_WORKSPACE")
#Update query definitions
if updateSQL:
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.supports("definitionQuery"):
lyr.definitionQuery = lyr.definitionQuery.replace("[","\"")
lyr.definitionQuery = lyr.definitionQuery.replace("]","\"")
if lyr.supports("labelClasses"):
for lblClass in lyr.labelClasses:
lblClass.SQLQuery = lblClass.SQLQuery.replace("[", "\"")
lblClass.SQLQuery = lblClass.SQLQuery.replace("]", "\"")
#Save and open resulting MXD
mxd.saveACopy(outputMXD)
os.startfile(outputMXD)
You can download the sample and test it on the data it comes with. Jeff
... View more
12-20-2011
06:15 AM
|
0
|
0
|
607
|
| 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 |
a month ago
|