POST
|
Hi Robert, I tested your code on a personal geodatabase and I found where it's getting stuck. The arcpy field delimiters function isn't returning the corrector delimiter. Personal geodatabases need square brackets wrapping their fields for SQL queries, but instead it's wrapping with double quotes. I added in a test to detect if the datasource is coming from a .mdb. NOTE - I plan to report to ESRI about the field delimiter bug. This arcpy function shouldn't be behaving in this way. import arcpy, random
def SelectRandomByCount (layer, count):
layerCount = int (arcpy.GetCount_management (layer).getOutput (0))
if layerCount < count:
print "input count is greater than layer count"
oids = [oid for oid, in arcpy.da.SearchCursor (layer, "OID@")]
desc = arcpy.Describe(layer)
if ".mdb" in desc.path:
name = "[" + desc.OIDFieldName + "]"
else:
name = arcpy.AddFieldDelimiters (layer, desc.OIDFieldName)
randOids = random.sample (oids, count)
oidsStr = ", ".join (map (str, randOids))
sql = "{0} IN ({1})".format (name, oidsStr)
arcpy.SelectLayerByAttribute_management (layer, "", sql)
... View more
12-28-2018
06:29 AM
|
3
|
1
|
1166
|
POST
|
Richard - I love all of your good advice on this thread. It's been helpful to think of VB expressions in the dynamic value table like those in the field calculator. I've got a problem that I'm hoping you could help me with. I'd like to use attribute assistant to populate fields according to the properties of the map document. The arcpy mapping module opens these properties up nicely, but I have no idea how to accomplish the same with visual basic. Ideally, I'd like to access the map title, but I'd also settle for the mxd name or version name. Below, I used a python function in the field calculator to accomplish what I want by pulling the map title. How can I get this same logic into the dynamic value table?
... View more
07-22-2016
11:20 AM
|
0
|
1
|
497
|
POST
|
Question for the group - Is there a dynamic value table method to access map document properties? I'd like to have attribute assistant use the map title to auto-populate a field on create, as a means of populating a project ID. Most methods appear to pull info from tables or geometry relationships, but few other file or system properties. Our current workflow has a new version and new MXD created per project ID, and we're thinking that pulling from the map title could be an easy solution for the front end users. Other ideas we've kicked around are MXD name (minus extension), or possibly the version name. I know in layout mode, dynamic text is used to display the map title via: <dyn type="document" property="title"/>. arcpy can also access the map title like this: mxd = arcpy.mapping.MapDocument("CURRENT") mxd.title Is there a method or VB expression to grab the same information? Thanks in advance! mmiller-esristaff timw1984
... View more
07-21-2016
11:17 AM
|
0
|
2
|
624
|
POST
|
"Did you try turning it off and on again?" -IT Crowd I was also having this problem. arcpy.Delete_management(GDB_path) would not remove my GDB, and left a weird folder behind. I attempted the while-loop approach (mentioned above), but that turned out to be an infinite loop, and I had to kill ArcMap to stop it. When I restarted ArcMap, the GDB hadn't been deleted. For fun, I tried running the original command again: arcpy.Delete_management(GDB_path). And it worked! Restart to the rescue again!
... View more
05-27-2016
01:01 PM
|
1
|
0
|
361
|
POST
|
I tried this while loop.... And it's still while-ing, several minutes later. Does this approach actually work, or is this an infinite loop?
... View more
05-27-2016
11:55 AM
|
0
|
1
|
1780
|
POST
|
Can you elaborate? Which storage formats don't work with .reset()?
... View more
03-03-2016
07:56 AM
|
0
|
0
|
1027
|
Title | Kudos | Posted |
---|---|---|
3 | 12-28-2018 06:29 AM | |
1 | 05-27-2016 01:01 PM |
Online Status |
Offline
|
Date Last Visited |
09-14-2021
03:32 PM
|