POST
|
Hi Jeff, When used correctly there is no problem (full path as in your example). The bug is that there exists limited functionality when using relative paths. An error should be thrown by arcpy.mapping.MapDocument immediately upon receiving a relative path and not later due to operations using the map document object constructed using a relative path. Regards, Cyrille
... View more
06-28-2012
12:00 PM
|
0
|
0
|
93
|
POST
|
Hey, In your earlier example (yesterday) you said the following functioned: FYI I just tested and this works. import os
import arcpy
os.chdir("C:/GIS/test")
arcpy.env.workspace = "C:/GIS/Test"
mxd = arcpy.mapping.MapDocument("point_2_line.mxd")
mxd.saveACopy("ortho_test_rename/testing3.mxd") So arcpy.mapping.MapDocument does NOT always return an error when using relative path names for you. Also notice that you used chdir without problems. Your later example (from today) fails: import os
import arcpy
arcpy.env.workspace = r"C:\GIS"
mxd = arcpy.mapping.MapDocument(r"Test\point_2_line.mxd")
mxd.saveACopy(r"Test\testing4.mxd") Clearly some relative paths work while those that access sub folders do not. This is inconsistent. Hence why I am saying it is a bug. This has nothing to do with chdir for me as shown in EXAMPLE 4. chdir worked fine for yourself in yesterday's example as well. I think we have discussed and analyzed this sufficiently to say that arcpy.mapping.MapDocument behaves erratically. I'd also recommend removing the trailing slashes at the end of your directory strings. Why do you recommend removing the trailing slashes? Does it cause unexpected bahaviour? Cheers, Cyrille
... View more
06-21-2012
06:23 AM
|
0
|
0
|
714
|
POST
|
Your chdir is what is doing it. That doesn't seem to be the case. The example below (similar to EXAMPLE 3 from my previous post) still fails. You are setting the relative path via python not the arcpy module. I set both the arcpy and python paths. I'd also recommend removing the trailing slashes at the end of your directory strings. I will do that for the example below. Could you let me know why this is beneficial? FYI I just tested and this works. Yes as I have shown in EXAMPLE 2 (previous post above) this works. Example 3 does not. Here is EXAMPLE 4 which is not using chdir. import os
import arcpy
arcpy.env.workspace = "C:/arcgis"
mxd = arcpy.mapping.MapDocument("maps/template2.mxd")
mxd.saveACopy("maps/testing7.mxd") The inconsistent nature of arcpy.mapping.MapDocument when using relative paths is a bug. arcpy.mapping.MapDocument should immediately return an error when a relative path is used. Happy Thursday, Cyrille
... View more
06-21-2012
12:09 AM
|
0
|
0
|
714
|
POST
|
So I have narrowed down cause of the failure to when the source file is in directory below the current work space. Here is some code that shows the successful and failing use cases:
''' c:/arcgis/ contents:
template.mxd
maps/template2.mxd
'''
import arcpy, os
os.chdir("c:/arcgis/")
arcpy.env.workspace = "c:/arcgis/"
# EXAMPLE 1
#use full path
mxd = arcpy.mapping.MapDocument('c:/arcgis/maps/template2.mxd')
mxd.saveACopy('template2_full_path_copy.mxd')
#SUCCESSFULL
#Need to reset env path
os.chdir("c:/arcgis/")
arcpy.env.workspace = "c:/arcgis/"
# EXAMPLE 2
#use relative path but local source
mxd = arcpy.mapping.MapDocument('template.mxd')
mxd.saveACopy('template_relative_copy.mxd')
#SUCCESSFULL
# EXAMPLE 3
# Using a relative path, not local directory source
mxd = arcpy.mapping.MapDocument('maps/template2.mxd')
mxd.saveACopy('template2_copy_fails.mxd')
#FAILS -> "AttributeError: MapDocObject: Unable to save. Check to make sure you have write access to the specified file and that there is enough space on the storage device to hold your document."
The bug, according to the documentation, is visible in example 2 - this should not work. The call arcpy.mapping.MapDocument('template.mxd') should return an error and mxd.saveACopy('template_relative_copy.mxd') should not work. This is inconsistent with the behaviour observed in example 3. Regards, Cyrille
... View more
06-20-2012
12:18 AM
|
0
|
0
|
714
|
POST
|
That being said, in this instance I cannot replicate this behaviour you are seeing. I have tried in an ArcGIS session and through IDLE. I get an error at mxd object creation with an invalid MXD filename error. What Service Pack are you using? I was working from windows command line (executing a python file) and using ArcGIS 10.0 SP4. I am home now (in Europe) but will try to see if results vary with the python window or IDLE on Monday. It's interesting to see both of you (mzcoyle & ttruong) having the expected behaviour. Cheers, Cyrille
... View more
06-18-2012
10:04 AM
|
0
|
0
|
714
|
POST
|
The MapDocument Syntax clearly states that the first input is: "A string that includes the full path and file name of an existing map document (.mxd) or a string that contains the keyword CURRENT" The bug is that arcpy.mapping.MapDocument() happily accepts a partial/relative path yet only provides limited functionality. The arcpy.mapping.MapDocument object will fail depending on the method called. The errors messages of the methods do not refer to the cause. A simple example import arcpy arcpy.env.workspace = "c:/arcgis/" # Using a relative path mxd = arcpy.mapping.MapDocument('maps/template.mxd') #works mxd.save() #fails -> "AttributeError: MapDocObject: Unable to save. Check to make sure you have write access to the specified file and that there is enough space on the storage device to hold your document." mxd.saveACopy('template_copy.mxd') When providing a full path to the MapDocument class no error is encountered when calling the saveACopy() method. The existing saveACopy() error is red herring. Upon receiving a relative path the MapDocument class should return an error. Regards, Cyrille
... View more
06-18-2012
03:45 AM
|
0
|
11
|
3658
|
POST
|
I agree with Graeme that this inconsistent behaviour should be categorized more as a geodatabase bug than something that is not supported. I have used the Copy Features method for my work but was looking for a more efficient manner. Thanks for clearing up the issue. Regards, Cyrille
... View more
05-20-2012
11:16 PM
|
0
|
0
|
317
|
POST
|
#import, environment etc.. is omitted for brevity prjString = "PROJCS['World_Mercator',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Mercator'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',0.0],PARAMETER['Standard_Parallel_1',0.0],UNIT['Meter',1.0]];-20037700 -30198300 10000;-100000 10000;-100000 10000;0.001;0.001;0.001;IsHighPrecision" #Create a layer based only on rows with 'src' attribute equal to 'YVR' arcpy.MakeFeatureLayer_management("FlightPaths", "YVR_layer", "\"src\" = 'YVR'") #Project the layer data arcpy.Project_management("YVR_layer", "YVR_Proj", prjString) The problem I'm encountering is that Project is selecting the full source data set rather than the layer selection. The arcpy.MakeFeatureLayer_management operation has created the layer 'YVR_layer' from 'FlightPaths' successfully and selected the desired rows. When I pass 'YVR_layer' to arcpy.Project_management it projects all the rows from 'FlightPaths' rather than those from 'FlightPaths' as selected. Any idea why this may be happening. Data is included below.
... View more
05-18-2012
06:49 AM
|
0
|
3
|
1742
|
POST
|
There is an error in the documentation for Save To Layer File (Data Management): The stand-alone Python script has the following offending code: where_clause = '"NAME" = 'LA MESA'' This is a syntax error. The correct syntax is: where_clause = '"NAME" = \'LA MESA\'' As defined in the 'where_clause' documentation in Make Feature Layer.
... View more
05-14-2012
03:18 AM
|
0
|
1
|
719
|
POST
|
After changing my registry, rebooting, installing Microsoft Visual C++ 2008 Redistributable Package (x86) followed by a Windows System update it is finally starting to actually copy files. See my earlier message for the steps (links) I followed. Good luck, Cyrille
... View more
11-08-2010
06:50 AM
|
0
|
0
|
465
|
POST
|
I have the same issue. During ArcGIS Desktop installation I get Error 2908 followed by Error 1935. "An error occurred during the installation of assembly 'ESRI.arcGIS.LocationUI'". The last part, '.LocationUI', is different each time. I also get '.CartoXUI', '.ArcMap'. Here are some screen captures. Cyrille Edit: I have tried doing the following to no effect: http://forums.arcgis.com/threads/16573-Installation-error-1935?highlight=1935 http://resources.arcgis.com/content/kbase?fa=articleShow&d=37477 http://forums.arcgis.com/threads/163-Beta-10-Install-on-Windows-7?highlight=1935 http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1bf
... View more
11-08-2010
05:40 AM
|
0
|
0
|
465
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|