|
POST
|
Try passing a full path including '.mxd' rather than the folder name.
... View more
11-09-2016
01:43 PM
|
1
|
7
|
3818
|
|
POST
|
mxd = arcpy.mapping.MapDocument(os.path.join(root,file)) Explanation: root = the root folder (everything except the filename and extension) for the current mxd file, produced by os.walk file = the filename and extension for the current mxd file, produced by os.walk os.path.join(root,file) = the full path to the current mxd file (root + file) arcpy.mapping.MapDocument(os.path.join(root,file)) = an arcpy map document object for the current mxd file If it makes it easier, you can split those lines apart like this: mxd_path = os.path.join(root,file)
mxd = arcpy.mapping.MapDocument(mxd_path)
... View more
11-09-2016
12:02 PM
|
1
|
10
|
3818
|
|
POST
|
I've done this for hundreds of mxds using a script like below: import arcpy, os
workspace = r'C:\blahblahblah' # starting directory
for root, dirs, files in os.walk(workspace, topdown=True): # starting traversing directories
for file in files: # loop through file names
if file.endswith('.mxd'): # if it's an mxd
mxd = arcpy.mapping.MapDocument(os.path.join(root,file))
els = arcpy.mapping.ListLayoutElements(mxd, 'TEXT_ELEMENT')
for el in els:
if 'old text' in el.text:
el.text = el.text.replace('old text','new text')
mxd.save()
del mxd I suspect your problem is that your text box text doesn't equal '2016' but it contains '2016'.
... View more
11-09-2016
10:49 AM
|
1
|
12
|
3818
|
|
POST
|
Sorry for recycling the same old instructions I've posted here, but it does work for me: 1.) Make your extension in the add-in wizard 2.) Customize the code: import arcpy
import pythonaddins
class ExtensionClass1(object):
"""Implementation for addin_test_addin.extension2 (Extension)"""
def __init__(self):
# For performance considerations, please remove all unused methods in this class.
self.enabled = True
def startup(self):
pythonaddins.MessageBox('Startup!', 'INFO', 0)
def openDocument(self):
pythonaddins.MessageBox('Open document!', 'INFO', 0) 3.) Install the add-in 4.) Open ArcMap and enable the extension: 5.) Open a document to test the openDocument method. Restart ArcMap to test the startup method. They both work for me. I did notice one tricky part, and completely agree with your point that debugging add-ins is a pain. Once you've made the .esriaddin file by running makeaddin.py, the .esriaddin file does not automatically update itself. So, you need to run makeaddin.py and then .esriaddin if you want to see your new changes take effect in ArcMap.
... View more
11-08-2016
04:49 PM
|
1
|
5
|
3171
|
|
POST
|
Glad you figured it out. If you want to save yourself this headache in the future, you can get the unique ID field dynamically like this: >>> fc = 'myFeatureLayer'
... print arcpy.Describe(fc).OIDFieldName
...
FID
... View more
11-08-2016
03:51 PM
|
2
|
0
|
1945
|
|
POST
|
Okay, it sounds like everything (both data layers and the data frame) is in the same CRS and it overlaps on the screen. Check the extent and mask environment just to be sure it hasn't been set to some other part of the world. Other than that, try restarting ArcGIS. Finally, try going for a coffee and coming back later (sometimes it helps ). It does sound like you've got a handle it, though, since you've done several of these already. Is this case different in some way, other than the first time around used the wrong CRS?
... View more
11-08-2016
02:16 PM
|
1
|
1
|
1559
|
|
POST
|
Are you trying to overwrite the old file or start with a new file? Delete the old file, start from scratch, get everything into the correct CRS, and try again.
... View more
11-08-2016
02:02 PM
|
1
|
3
|
1559
|
|
POST
|
I know this is an old thread, but it popped up to the top, so here's a quick answer. The equivalent of if/then/else logic for rasters is the Con tool/statement. Con(condition,do this if true, do this if false)
... View more
11-08-2016
01:33 PM
|
0
|
0
|
1819
|
|
POST
|
I don't know much (anything) about connection files, but the help (and example within) indicates that the connection string should end in '.ags'. Can you try: con = 'GIS Servers/arcgis on MYSERVER.nuim.ie_6080 (admin).ags'
... View more
11-08-2016
11:35 AM
|
1
|
0
|
2081
|
|
POST
|
Try using AddFieldDelimiters to handle the quotes: >>> fc = 'points'
... sort_field = 'FID'
... w_clause = arcpy.AddFieldDelimiters(fc, sort_field) + ' < ' + str(5) # or str(i+1)
... arcpy.SelectLayerByAttribute_management(fc,"NEW_SELECTION",w_clause)
... View more
11-08-2016
11:17 AM
|
1
|
0
|
1945
|
|
POST
|
Thanks for taking the time to reply, Dan and Jayanta. As far as I can tell, the problem had to do with a setting in the virus scanner, which was set to cache files locally to avoid a separate but related problem where the virus scanner locks up open map documents so I can't save them (this is all done by IT, so I don't quite understand it). We've reversed that setting, so I'll just have to deal with the virus scanner locking up my MXDs on occasion (convenient!).
... View more
11-08-2016
10:54 AM
|
1
|
0
|
1545
|
|
POST
|
Yes, that is the latest version I downloaded, but I don't think it's necessarily specific to that file. For example, I could load the old file last week but now cannot (I haven't edited or otherwise touched that file). I downloaded the new file as a check for whether the old file might have become corrupt somehow, but unless both the old and new file are corrupt in the same way, I don't think that's it.
... View more
11-07-2016
03:39 PM
|
0
|
1
|
1545
|
|
POST
|
Throughout the years, I have made many, many maps based on the same map template (spanning version 10.0 to, now, 10.4.1). The template includes several base mapping layers, like an imagery WMS, roads, pipelines, wellsites, land parcels, etc. At some point last week, ArcMap decided it would no longer load the roads layer. It's quite a large feature class by my standards although I doubt it's considered "big data" (285MB), but it used to load no problem. Now, it starts to load and soon after goes "not responding". I made a map using this template on November 1, with no problem. Now, I can't successfully open it. Here are some things I've tried: - brand new mxd, won't load feature class (goes "not responding") - other machines also can't load the feature class - deleted Normal.mxt - restarted computer - this happens with fresh download and archived version , which used to work As far as I know, I haven't installed any Windows updates since November 1. Also, I upgraded to Windows 10/ArcGIS 10.4.1 a couple of months with no major issues. Is there any sort of cache I should clear or setting in ArcMap that might cause a problem rendering a large feature class? If anyone's interested, the feature class I'm trying to load can be found here: Digital Road Atlas (DRA) - Master Partially-Attributed Roads - Datasets - Data Catalogue
... View more
11-07-2016
03:14 PM
|
0
|
5
|
2025
|
|
POST
|
If you've successfully created the extension add-in, it should appear in the extension list. Step six enables the extension, similar to enabling Spatial Analyst, 3D Analyst, etc.
... View more
11-02-2016
04:54 PM
|
0
|
1
|
2316
|
|
POST
|
Find/replace all the spaces to underscores in your field names and you should be good to go.
... View more
11-01-2016
10:00 AM
|
1
|
0
|
2300
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-30-2013 02:22 PM | |
| 1 | 04-12-2011 11:19 AM | |
| 1 | 09-17-2021 09:43 AM | |
| 1 | 04-04-2012 12:05 PM | |
| 2 | 07-16-2020 11:31 AM |
| Online Status |
Offline
|
| Date Last Visited |
07-15-2023
12:11 AM
|