POST
|
So I finished a large model in model builder, and when I tried to run the model, arcgis crashed. After rebooting arc, the model now has a red x next to it, and when I open it up in model builder, I can't edit anything. It will neither run nor validate. Furthermore, when I open up the model for the first time, the model builder page is blank. Only after hitting "undo" multiple times, does the model re-appear. any help?
... View more
08-02-2013
05:45 AM
|
0
|
1
|
281
|
POST
|
Still no luck. Interestingly, the RemoveLayer command won't work once the layer is added either. There seems to be something wrong with the way I am adding the layer to the mxd I finally got it to work, but in a really round-about way. # Import arcpy module
import arcpy
# Set Geoprocessing environments
arcpy.env.workspace = "**************"
##overwrites output
arcpy.env.overwriteOutput = True
#mapDocument
mxd = arcpy.mapping.MapDocument(r"***********************.mxd")
#setting layer variable
nl = arcpy.mapping.Layer(r"*****************************.lyr")
##setting dataset variable
df = arcpy.mapping.ListDataFrames(mxd)[0]
#select layer
arcpy.SelectLayerByAttribute_management(nl, "NEW_SELECTION", ' "***************" ')
#set scale
df.scale = 7000000
##adds layer variable to mxd
arcpy.mapping.AddLayer(df, nl)
##zooms to layer
df.zoomToSelectedFeatures()
extent=df.extent
for nl in arcpy.mapping.ListLayers(mxd, "", df):
arcpy.mapping.RemoveLayer(df, nl)
arcpy.RefreshActiveView()
#mapDocument
mxd = arcpy.mapping.MapDocument(r"***************************.mxd")
nl2= arcpy.mapping.Layer(r"**********************************")
##setting dataset variable
df = arcpy.mapping.ListDataFrames(mxd)[0]
df.extent=extent
##adds layer variable to mxd
arcpy.mapping.AddLayer(df, nl2)
##exports current map extent to png
arcpy.mapping.ExportToPNG(mxd,r"************************",df,df_export_width=550,df_export_height=480)
... View more
07-11-2013
06:16 AM
|
0
|
0
|
173
|
POST
|
So I am fairly new to python scripting, but I have what seems like it should be a fairly simple script that selects an attribute from a layer, zooms to it, and then clears the selection and exports a png of the map. However, the CLEAR_SELECTION function doesn't actually seem to be doing anything, and all the maps the script outputs still have the selected feature highlighted in blue when it is outputted to the png. # Import arcpy module
import arcpy
# Set Geoprocessing environments
arcpy.env.workspace = "*****"
##overwrites output
arcpy.env.overwriteOutput = True
#mapDocument
mxd = arcpy.mapping.MapDocument(*******.mxd")
#setting layer variable
addLayer = arcpy.mapping.Layer(********.lyr")
##setting dataset variable
df = arcpy.mapping.ListDataFrames(mxd)[0]
#select layer
arcpy.SelectLayerByAttribute_management(addLayer, "NEW_SELECTION", ' *********** ')
#set scale
df.scale = 7000000
##adds layer variable to mxd
arcpy.mapping.AddLayer(df, addLayer)
##zooms to layer
df.zoomToSelectedFeatures()
####unselect point
arcpy.SelectLayerByAttribute_management(addLayer,"CLEAR_SELECTION")
##exports current map extent to png
arcpy.mapping.ExportToPNG(mxd,*************,df,df_export_width=550,df_export_height=480)
... View more
07-10-2013
09:06 AM
|
0
|
5
|
736
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|