|
POST
|
Perhaps you need to reference the "datasetName" or "dataSource" instead of the layer "name". Which to use may depend on whether you plan to use your tool inside or outside of ArcMap. See this help topic for explanations of these different properties. In code, perhaps you should try "datasetName" or "dataSource". (Since you mentioned an issue with backslashes, perhaps "dataSource" would be the one to try.) LayerList = [r'c:\pathTo\geo.gdb\LayerSource', 'anotherLayer']
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.supports("LABELCLASSES"):
if lyr.dataSource in LayerList:
lyr.showLabels = True
else:
lyr.showLabels = False
... View more
03-06-2017
11:41 AM
|
0
|
1
|
3252
|
|
POST
|
I have used code like: mxd = arcpy.mapping.MapDocument("CURRENT")
LayerList = ['MyLayer']
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.supports("LABELCLASSES"):
if lyr.name in LayerList:
lyr.showLabels = True
arcpy.RefreshActiveView()
... View more
03-06-2017
10:28 AM
|
2
|
3
|
3252
|
|
POST
|
As Darren is suggesting, try: def FindLabel ( [MAINSIZE], [MAINMATERIALTYPE], [SYSTEMMAOP], [INSTALLATIONDATE], [WORKORDERNUMBER], [INSERTEDMAINSIZE], [INSERTEDMAINMATERIAL] ):
return ' '.join(filter(None, ([MAINSIZE],[MAINMATERIALTYPE],[SYSTEMMAOP],'D',([INSTALLATIONDATE][-2:]),[WORKORDERNUMBER], '\n', [INSERTEDMAINSIZE], [INSERTEDMAINMATERIAL])))
... View more
03-01-2017
01:07 PM
|
1
|
0
|
818
|
|
POST
|
As Russ is suggesting, you need to look at the types section in the feature's JSON file. Getting domains to sort (and stay sorted) in collector has been so frustrating, that when I publish a feature layer I add a step to resort items in the types section. I use the REST API to do this, and I briefly describe my process here: Feature type sort order in REST API using Python.
... View more
02-27-2017
09:29 AM
|
0
|
0
|
1051
|
|
POST
|
The Programming ArcGIS with Python Cookbook book looks like a good resource and worth the investment. I have found online resources to be just as valuable, if not more so, than a few good reference books. Knowing what and how to ask Google (etc.) is an invaluable skill.
... View more
02-23-2017
11:46 AM
|
0
|
2
|
2617
|
|
POST
|
Try this article:How To: Batch export attachments from a feature class
... View more
02-22-2017
03:51 PM
|
0
|
0
|
2666
|
|
POST
|
1. Follow Dan Patterson's Py... blog. 2. Check out Some Python Snippets 3. Free online courses like Tutorials Point
... View more
02-22-2017
02:03 PM
|
1
|
4
|
2617
|
|
POST
|
To loop through all the features, you might try the following code. However, if the where clause fails, you may get a count of all records. import arcpy
arcpy.env.workspace = r"d:/TMP/miha_k/zirovnica/novo/test.gdb"
fcs = arcpy.ListFeatureClasses()
for row in fcs:
arcpy.MakeTableView_management(row, "myTableView", "PARCELA LIKE '%/%'")
print row, int(arcpy.GetCount_management("myTableView").getOutput(0))
arcpy.Delete_management("myTableView")
... View more
02-22-2017
10:49 AM
|
0
|
10
|
5992
|
|
POST
|
As Darren suggested, I don't think you would want to cycle through all your features; they might not have the fields you want to query anyway. Here's some code based on this link: arcpy.env.workspace = r"d:/TMP/miha_k/zirovnica/novo/test.gdb"
in_table = "featureToSearch"
# MakeTableView_management (in_table, out_view, {where_clause}, {workspace}, {field_info})
arcpy.MakeTableView_management(in_table, "myTableView", "PARCELA LIKE '%/%'")
count = int(arcpy.GetCount_management("myTableView").getOutput(0)) But, if your features all contain the same field in your where query, you could do a "for row in fcs" loop. You could also add an if "feature in list" line to limit the features used.
... View more
02-22-2017
10:14 AM
|
0
|
11
|
5992
|
|
POST
|
The error message indicates a character encoding problem with the !SPCOMP! field. You might try a decode to ascii. Also, I think your indexing to get "90" in your example should be 2 and 5 not 3 and 6. def getPJ(spcomb):
if 'PJ' in spcomb:
n = spcomb.find('PJ')
return spcomb[n+2:n+5].strip()
else:
return 0
getPJ( !SPCOMP!.decode('ascii') )
... View more
02-06-2017
12:32 PM
|
1
|
1
|
2977
|
|
POST
|
Can you share the script (at least the part that is generating the error) and the error message?
... View more
02-06-2017
11:39 AM
|
1
|
0
|
2977
|
|
POST
|
Your code: output = "NewFires.shp"
# ....
arcpy.CreateFeatureclass_management(work, output, "POINT") I get an error 000354 : The name contains invalid characters (a table in a file geodatabase cannot include a space or a period). But, you are using an Access database? work = "C:\Scripts\Lab 7 Data\WildlandFires.mdb"
... View more
02-06-2017
10:40 AM
|
0
|
1
|
912
|
|
POST
|
Knew there had to be a way using .format. Thanks Dan_Patterson
... View more
02-01-2017
10:43 AM
|
0
|
2
|
2481
|
|
POST
|
To add trailing zeros, try something like: BuildNum = "B37828"
print BuildNum.ljust(11,'0')
print "B2898101".ljust(11,'0')
# for your code
row[1] = row[0].ljust(11,'0')
... View more
02-01-2017
10:01 AM
|
2
|
0
|
2481
|
|
POST
|
Are there any tutorials or samples that would show how to set up views? Thanks.
... View more
01-30-2017
11:31 AM
|
0
|
1
|
1933
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-27-2016 02:23 PM | |
| 1 | 09-09-2017 08:27 PM | |
| 2 | 08-20-2020 06:15 PM | |
| 1 | 10-21-2021 09:15 PM | |
| 1 | 07-19-2018 12:33 PM |
| Online Status |
Offline
|
| Date Last Visited |
02-12-2026
07:13 PM
|