POST
|
You will need a map file somewhere on disk, but you can save copies of it. What you would do is open an MXD with arcpy.mapping.MapDocument, then a layer file with arcpy.mapping.Layer, use layer.replaceDataSource to make it point to the shapefile, then use arcpy.mapping.AddLayer to add the layer which now points to the shapefile to the map document. You would continue until you've added all your layers and then call saveACopy on the MapDocument object to produce your new MXD with all your data sources.
... View more
03-10-2011
08:05 AM
|
0
|
0
|
328
|
POST
|
u means it is a Unicode object, as opposed to a regular (locale-specific) C-style string. Doing this: print [f.name for f in silverware] is trying to get the name property off the string, which does not exist, hence the error.
... View more
03-08-2011
10:32 AM
|
0
|
0
|
349
|
POST
|
Let me know how this works for you:
import arcpy
import glob
import os
# Provide folder path to loop through (first level only)
folderPath = r"C:\TEMP\test"
for filename in glob.glob(os.path.join(folderPath, "*.mxd")):
print "Editing", filename
mxd = arcpy.mapping.MapDocument(filename)
if not mxd.description:
mxd.description = "Default description"
mxd.save()
del mxd
... View more
03-08-2011
10:06 AM
|
0
|
0
|
592
|
POST
|
Try this in the Python window: print ", ".join(el.name for el in arcpy.mapping.ListLayoutElements(activeMXD))
this will list the names of every layout element in the document. It may be the case that the name is wrong in the script or it is not found because it is in a group element. If you are using the raw flag on a string, you don't need to escape backslashes. Use one of: mxd = arcpy.mapping.MapDocument("H:\\My Files\\Test\\Project.mxd") or mxd = arcpy.mapping.MapDocument(r"H:\My Files\Test\Project.mxd") Again, ensure the element is being found: import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Test\Map.mxd")
#search for �??Title Block�?� and if found move to desired location
for elm in arcpy.mapping.ListLayoutElements(mxd, "GRAPHIC_ELEMENT"):
if elm.name == "My Map":
print "FOUND IT!"
elm.elementPositionX = 4.75
elm.elementPositionY = 10.5
... View more
03-08-2011
08:47 AM
|
0
|
0
|
505
|
POST
|
No, you can use ArcObjects at any license level. All you will require is Visual Studio or Visual Studio Express.
... View more
03-08-2011
06:15 AM
|
0
|
0
|
1210
|
POST
|
You don't need to use the InsertCursor in Python -- you can do it in ArcObjects in your DLL. Please note the C++ code on this help page for opening a cursor from C++.
... View more
03-07-2011
11:59 AM
|
0
|
0
|
1210
|
POST
|
You cannot activate DDP from Python, you can only use DDP-enabled maps.For anything dynamic you might want to think about using an MXD set up for Data Driven Pages already, then use Layer.replaceDataSource to swap out the data for your new feature class. The only issue here is your field names will still need to all be the same.
... View more
03-05-2011
02:03 PM
|
0
|
0
|
235
|
POST
|
When you iterate over a file, each line gives you the final return at the end, you'll need to do something like this: if str(mth) in inlines.rstrip()[-2:] Otherwise line[-2:] is equal to "\r\n" and not your number (which is at [-4:-2])
... View more
03-05-2011
01:59 PM
|
0
|
0
|
1967
|
POST
|
If you're working within ArcMap, the MakeFeatureLayer and MakeRasterLayer tools should do what you want.
... View more
03-04-2011
01:01 PM
|
0
|
0
|
795
|
POST
|
You don't need to clear it out each time the way you are, each instance of Array is a stand-alone object: for df in frames:
#Creates a polygon object
poly = arcpy.Polygon(arcpy.Array([df.extent.lowerLeft, df.extent.lowerRight, df.extent.upperRight, df.extent.upperLeft]),
df.spatialReference)
featureList.append(poly)
# All done
... View more
03-02-2011
12:19 PM
|
0
|
0
|
656
|
POST
|
You will need to figure out another solution (using pip/virtualenv to build a local installation of Python and/or bundling all your extra libraries in a separate folder and adding it to sys.path hint: modulefinder). If your py2exe bundle includes arcpy and/or arcgisscripting you can exclude them in the blacklist in your setup.py -- that should not only fix the majority of the problem but get you around potential license violations of redistributing Esri binaries.
... View more
02-25-2011
02:23 PM
|
0
|
0
|
1093
|
Title | Kudos | Posted |
---|---|---|
1 | 09-26-2012 02:46 AM | |
2 | 01-06-2011 08:22 AM | |
1 | 03-25-2014 12:18 PM | |
1 | 08-12-2014 09:36 AM | |
1 | 03-31-2010 08:56 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:22 AM
|