POST
|
Although this is an old post, I thought I was hitting the same problem in 10.4 for an add-in. I was changing the python code and making a new .esriaddin file with makeaddin.py, yet the changes were not reflected. It was not a cache problem, rather it was me not reinstalling the updated esriaddin. After you make the .esriaddin file, you must double-click on it to execute the installation wizard. This registers and makes a copy of your updated .esriaddin file to where ArcMap looks for it. If you skip the last step, you run the old python code. You can verify this by searching for your .esriaddin file, you will find two files. The one that ArcMap looks at is in the directory C:\Users\<User>\Documents\ArcGIS\AddIns\Desktop10.4\{832e6995-0daa-48aa-940f-0b6a04e3a5fe} or similar and is copied there by the installation utility. So to test changed python code: 1) Save the python code (.py) file 2) Run makeaddin.py (which writes the local .esriaddin file, but not the one ArcMap looks at) 3) Double-click on the .ersiaddin file to invoke the add-in installation utility and install (Step 3 was missing in the ESRI docs) The correct version will be available in ArcMap, When debugging, remember to open the ArcMap Python console to see any python code errors.
... View more
05-26-2017
02:41 PM
|
1
|
0
|
286
|
POST
|
Curtis is correct, the original code does function correctly. The problem was with my test mxd which was already zoomed to the desired extent, so no change was reflected in the test. Zooming out on the test mxd, then running the code, zoomed the data frame to the extents of the 'Outline' layer correctly. Thanks to all. To zoom the data frame to the extents of layer 'Outline' the code would be: for lyr in arcpy.mapping.ListLayers(mxd, 'Outline'):
lyr_extent = lyr.getExtent()
df.extent = lyr_extent
... View more
05-13-2017
03:49 PM
|
1
|
0
|
1477
|
POST
|
I am unable to set the data frame extents to the extents of one layer. mxd = arcpy.mapping.MapDocument(r'C:\Projects\G25\MXD\G10001_Aspect.mxd')
df = arcpy.mapping.ListDataFrames(mxd, 'Layers')[0]
print 'df Extent before:', df.extent
for lyr in arcpy.mapping.ListLayers(mxd, 'Outline'):
lyr_extent = lyr.getExtent()
print 'Layer Extent:', lyr_extent
df.extent = lyr_extent
print 'df Extent after:', df.extent
mxd.save()
del mxd
The mxd df extent is not changed (extents printed below) df Extent before: -48.7679994656522 -31.5306864013717 48.4338994650919 37.1648864006445 NaN NaN NaN NaN Layer Extent: -10.5550864009008 -31.5306864013717 10.2209864003405 37.1648864006445 -0.86019999999553 0.806700000001001 NaN NaN df Extent after: -48.7679994656522 -31.5306864013717 48.4338994650919 37.1648864006445 NaN NaN NaN NaN
... View more
05-07-2017
02:20 PM
|
0
|
6
|
2934
|
Title | Kudos | Posted |
---|---|---|
1 | 05-13-2017 03:49 PM | |
1 | 05-26-2017 02:41 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|