POST
|
Hi, I've getting an error with the saveACopy function of an arcpy MapDocument, it will not let me saveACopy of a document I created using saveACopy then later renamed back to the original documents name. This is my workflow, looping through a folder full of MXDs: Open original document Do some work on it Save a copy with new name Close all documents copy the original document to an archive folder (only copying those documents that had work done to them successfully) delete the original document (in the original folder) rename the saved copy to the original documents name (in the original folder) This works fine the first time it is run on a folder, if it is run a second time on the same folder (which now has some new documents), it will fail to saveACopy for all documents that were modified the first time around. This sample function illustrates the problem: import arcpy, os, gc
def Test():
# Test mode
justSaveAs = True
# Test MXD
originalDoc = r"C:\Users\USERNAME\Documents\ArcGIS\TestData\Test.mxd"
# Make a new MXD Name...
baseFldr = os.path.dirname(originalDoc)
baseName = os.path.basename(originalDoc)
newDoc = os.path.join(baseFldr,"temp123_" + baseName)
# Open the original Document, and save a copy
mxd = arcpy.mapping.MapDocument(originalDoc)
mxd.saveACopy(newDoc)
# Close the document
del mxd
gc.collect()
# Delete the original and rename the new file the same as the original
os.remove(originalDoc)
os.rename(newDoc,originalDoc)
if justSaveAs:
# Reopen the document and try and save as again -- FAILS
mxd = arcpy.mapping.MapDocument(originalDoc)
mxd.saveACopy(newDoc)
else:
# Reopen the document, save, then save as -- WORKS!?
mxd = arcpy.mapping.MapDocument(originalDoc)
mxd.save()
mxd.saveACopy(newDoc) It does work ok if you open the new version of a document and do a regular save before atempting to saveACopy. Also works by opening the new version of the document before renaming them and do saveACopy back to the original name. However both of these solutions require reopening the document which can take some time for large maps, and there is no way to tell before hand if the document will suffer from the saveACopy issue. This issue only affects arcpy, opening the documents in ArcMap and doing save/save as/save a copy works fine for all MXDs. Any ideas on how to fix this?
... View more
05-03-2013
07:18 AM
|
0
|
1
|
748
|
POST
|
Hi, I'm having an issue where if I use a script or model which outputs a multi-value parameter in another model I can't use that output for anything! Simple example, I have a script that changes layout text in a map and returns that map as a single map document, and I have created a model that does this for multiple maps (using multi-value iterator and collect values tools) and returns a multi-value map document parameter. When I try and connect these up in another model to a script that batch prints maps (taking a multi-value map document as an input parameter), the script that outputs a single map document works, but the multi-value output from the model doesn't. [ATTACH=CONFIG]16792[/ATTACH] I see this same problem with all the scripts and models I have that output multi-value parameters, have I missed something when setting up my outputs or is this an issue with model builder? I've seen this thread http://forums.arcgis.com/threads/28771-Python-list-to-MultiValue-output-parameter and I know that my output is in the correct format, and the parameters are correctly set up in the scripts and models. Thanks, Andy
... View more
08-09-2012
03:14 AM
|
0
|
0
|
435
|
POST
|
Found an answer: http://forums.arcgis.com/threads/35682-Create-Connection-Folder-in-ArcCatalog-through-ArcMap-VB.NET?p=152447&viewfull=1#post152447 Added 2 lines of code after removing folder connections: ESRI.ArcGIS.Catalog.IGxCatalog catalog = new ESRI.ArcGIS.Catalog.GxCatalogClass(); catalog.Location = "M:\\"; catalog.DisconnectFolder("M:\\"); ESRI.ArcGIS.Catalog.IGxFile gxFile = (ESRI.ArcGIS.Catalog.IGxFile)catalog; gxFile.Save(); Folder connections now are removed permanently.
... View more
02-03-2012
04:46 AM
|
0
|
0
|
223
|
POST
|
Hi, This should be quite simple, but how can I remove folder connections from IGxCatalog? I've tried: ESRI.ArcGIS.Catalog.IGxCatalog catalog = new ESRI.ArcGIS.Catalog.GxCatalogClass(); catalog.Location = "M:\\"; catalog.DisconnectFolder("M:\\"); but the connection to M:\ remains after running the code.
... View more
02-03-2012
01:20 AM
|
0
|
1
|
837
|
POST
|
While the code above still fails to work if the tags are missing, I have managed to resolve why the tags are missing! The upgrade metadata tool at service pack 3 is creating incomplete metadata, going back to service pack 2 and using the upgrade metadata tool creates all the tags we need correctly.
... View more
11-10-2011
11:38 PM
|
0
|
0
|
148
|
POST
|
Yes, I have service pack 3 installed. This issue only affects tags where there is a "partner" code value, which in the tags we are intrested in includes Originator, Publisher, and points of contact.
... View more
11-07-2011
12:42 AM
|
0
|
0
|
148
|
POST
|
Hi, I need to update some ArcGIS 10 metadata in files that have had their metadata upgraded from ArcGIS 9 FGDC metadata. Most things seem to work fine, but if I try the code bellow it will only work if the tags exist already: pXMLProps.SetPropertyX( _
"dataIdInfo/resConst/LegConsts/othConsts[../accessConsts/RestrictCd/@value='008']", _
strAccess, esriXPTText, esriXSPAAddOrReplace, False) There are a few other tags that use similar Xpaths and they are broken too, but all the tags with a straight forward tag work fine even when they aren't already present. Any advice on how to resolve or work around this issue? Thanks, Andy
... View more
11-04-2011
08:11 AM
|
0
|
3
|
595
|
POST
|
Hi, I am having some trouble with a simple Python script, and cannot figure out why. Hopefully I can explain this... # Script arguments
TempMXD = arcpy.GetParameterAsText(0) # MXD Document (used as template)
Layers = arcpy.GetParameterAsText(1) # Multi-Value - accepts LYR files
# Work through all layers
try:
AllLyrs = Layers.split(";")
for Layer in AllLyrs:
arcpy.AddMessage("\nProcessing " + Layer)
print Layer
# Remove quotes from multi-value list
if Layer[0] == "'":
Layer = Layer[1:]
if Layer[-1] == "'":
Layer = Layer[:-1]
print Layer
# Process: Create Crowd MXD
arcpy.gp.LCSCreateCrowdMXD(TempMXD, Layer)
del Layer
print len(AllLyrs)
del AllLyrs
except Exception, e:
import traceback
map(arcpy.AddError, traceback.format_exc().split("\n"))
arcpy.AddError(str(e)) The above code works in pyScripter if I feed it some values for the input parameters. It will not work in ArcCatalog, it gives a "IOError: [Errno 9] Bad file descriptor" error after 5 or 6 layers. If I use the "try...except" soultion recomended here (http://support.esri.com/en/knowledgebase/techarticles/detail/35380) it will work fine however. If I remove the print statements, any of them, it will not work at all (in ArcCatalog or pyScripter), giving a "TypeError: object of type 'dict' has no len()" when reaching the "for Layer in AllLyrs" line. In case you're wondering what the other tool called is, it is basically the "replace layer in mxd" example (http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=A910AB18-1422-2418-3418-3885D388EF60), with some fixed values for the layer to replace. And that script works fine when run on its own using the same data and MXDs used in this script. As I mentioned it works with the work around suggested for 9.3.1, but I can't see a reason for it to not work without the print statements???
... View more
08-01-2011
06:23 AM
|
0
|
2
|
2947
|
POST
|
Hi, Is there an easy way to add a circle of known radius to the graphics layer with out using a geometry service task? I'd like to show a ring 400m from the GPS location, which shouldn't be too hard as the spatial reference is in metres already. Andy
... View more
10-07-2010
08:08 AM
|
0
|
1
|
691
|
POST
|
Sorry, have answered my own question! I should have initialised the FindTask like this: self.findTask = [[AGSFindTask alloc] initWithURL:self.dynamicLayersURL]; Hope this helps Bleum.
... View more
10-06-2010
08:31 AM
|
0
|
0
|
239
|
POST
|
I'm also having a problem with the findTaskDelegate not being triggered, I've got the view controller set to be the delegate. Setting up the findTask:
[[self.findTask alloc] initWithURL:self.dynamicLayersURL];
self.findTask.delegate = self;
Executing it:
- (void)searchBarSearchButtonClicked:(UISearchBar *)theSearchBar
{
// Get find parameters
AGSFindParameters *findParam = [[AGSFindParameters alloc] init];
findParam.contains = YES;
findParam.layerIds = findLyrIds;
findParam.returnGeometry = NO;
findParam.searchFields = findFields;
findParam.searchText = theSearchBar.text;
// Execute the find task
[self.findTask executeWithParameters:findParam];
} It never sets off didExecuteWithFindResults or didFailWithError, Any ideas?
... View more
10-06-2010
08:26 AM
|
0
|
0
|
239
|
POST
|
Thanks for pointing that out, its useful to know, but I need to find a solution that works when stationary too.
... View more
10-06-2010
08:09 AM
|
0
|
0
|
300
|
POST
|
Thanks, I will look into it. I suspect that it may result in too many calls to the server, especially when lots of people are using it at the same time.
... View more
10-05-2010
02:06 AM
|
0
|
0
|
297
|
POST
|
Hi, Is there a way to show the heading on the GPS location without using Core Location and my own graphic? We are not working in WGS84 so need to keep the transformation that is applied with AGSGPS. I have been thinking of using AGSGPS for the location and then getting the heading from core location to add my own graphic but I'm not sure if thats possible? The ideal solution is to rotate the map so the persons heading is always at the top of the screen, but I don't think that possible at the moment?
... View more
10-05-2010
01:46 AM
|
0
|
3
|
3240
|
POST
|
Thanks, that work perfectly! I'm slowly getting my head around the iPhone SDK/Objective C, but its very different to C#!
... View more
08-19-2010
03:58 AM
|
0
|
0
|
690
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|