POST
|
Hi Christian, as far as I understood the "CURRENT" option is basically meant to be used from within the python-Window. Try to parse the full mxd-Path as an argument into your script and make the document line get that mxd = arcpy.mapping.MapDocument(r"C:\temp\xxtest.mxd")
Havent tried but its worth a try! Regards Guenter Thank you for this suggestion. However, I've used "CURRENT" successfully in a number of other script tools. Plus, I get the same result when I use the full mxd path. I think this has to be a bug in the software.
... View more
07-22-2010
10:00 AM
|
0
|
0
|
413
|
POST
|
Turns out this is a known bug. [#NIM052741 Feature layer fails to persist in ArcMap table of contents when added through the AddLayer function in script tool] It was logged in final beta but a fix wasn't made for the final release. Too bad, this is a pretty important method for map automation.
... View more
07-22-2010
09:57 AM
|
0
|
0
|
399
|
POST
|
I am trying to write a script tool that will loop through all the disconnected layers in a map document and repoint them using the Layer.replaceDataSource function. When I run the following 3 lines of code: mxd = arcpy.mapping.MapDocument("CURRENT") lyr = arcpy.mapping.ListBrokenDataSources(mxd)[0] lyr.replaceDataSource(r"Database Connections\GISUSER on dep-eia1dbsop01.sde","SDE_WORKSPACE",r"Sample_Location",True) from the Python Window within ArcGIS Desktop it works fine. But when I put them in a .py file and try to run the script from ArcToolbox it seems to reconnect the file but then removes it from the map document.
... View more
07-20-2010
04:10 AM
|
0
|
10
|
4435
|
POST
|
When I run the following code: mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] addLayer = arcpy.mapping.Layer(r'G:\data_layers\political\Towns_Maine_polys.lyr') arcpy.mapping.AddLayer(df, addLayer, "AUTO_ARRANGE") from the Python Window in ArcMap it works fine. But when I put it in a script tool and run it from ArcToolbox I see the layer get added to the data frame but then it immediately disappears. I've tried using InsertLayer but get the same result. Any idea what is happening?
... View more
07-15-2010
09:37 AM
|
0
|
11
|
3593
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|