POST
|
However, in my next step, I want to take the name of that selected layer and get a field value Stream_Name = arcpy.da.SearchCursor(lyrs, "GNIS_Name", "Any value", "") I get the error RuntimeError: 'in_table' is not a table or a featureclass Am I taking the wrong approach? it seems to pass as a layer and not a feature class.
... View more
05-01-2019
11:56 AM
|
0
|
16
|
3538
|
POST
|
I am using python in ArcPro and relearning a few things. I have a feature selected in the dataframe. I want to determine the name of that layer that has a selection and return the value of the selected object in the field called "GNIS_Name" . aprx = arcpy.mp.ArcGISProject("CURRENT")
#get selected layer
m = aprx.listMaps(aprx)
refLyr = m.listLayers(aprx)
sel_lyrs = refLyr.getSelectionSet(aprx)
# get name of selected stream
Stream_Name = arcpy.da.SearchCursor(sel_lyrs, "GNIS_Name", "Any value", "") currently I get the error on line 5: 'list' object has no attribute 'listLayers'
... View more
04-30-2019
11:38 AM
|
0
|
19
|
5340
|
POST
|
add #page=4 after the .pdf in the URL "4" being whatever page you need
... View more
01-27-2017
02:37 PM
|
0
|
0
|
651
|
POST
|
Just changing the data frame units does not change the units in the edit sketch window for me. The only thing that will changes seems to be to set it to projection such as GCS_WGS_1984 that has angular units rather than linear units. Units in the sketch properties window and the guide that shows up in the lower left when editing seem to be controlled only by the coordinate system and not the data frame units
... View more
08-22-2014
03:47 PM
|
0
|
0
|
800
|
POST
|
The units default to meters, can they be changed to Decimal degrees?
... View more
08-15-2014
10:46 AM
|
0
|
2
|
800
|
POST
|
Is it possible to change the units of the XY in the edit sketch properties window?
... View more
08-15-2014
10:19 AM
|
0
|
4
|
5178
|
POST
|
Check this out http://www.arcgis.com/home/item.html?id=ee27a893c7914598983a7fb3ed5244ac Coordinate System: Alaska Polar Stereographic (WKID 5936)
... View more
07-08-2014
05:06 PM
|
1
|
4
|
2168
|
POST
|
I found it, so simple [HTML] uniqueValues = sorted(set(values))[/HTML]
... View more
03-13-2014
03:54 PM
|
0
|
0
|
383
|
POST
|
I have tried many ways to sort that work, but then I can't get unique values. The following works to return unique values, it would seem I need to add something to the onFocus part to make it work. any suggestions? Rng = [] for row in arcpy.SearchCursor("X:\JasonGraham\Landstatus\Data\ls2014.gdb\BaseData\Townships"): Rng.append(row.RNG_NUMC) class ComboBoxClass7(object): #Collect Range from list of unique values gathered from the layer """Implementation for MTR_addin.combobox_3 (ComboBox)""" def __init__(self): self.value = "000" self.items = (Rng) self.editable = True self.enabled = True self.dropdownWidth = 'WWWW' self.width = 'WWWW' def onSelChange(self, selection): self.sel = selection def onEditChange(self, text): pass def onFocus(self, focused):#show only unique values if focused: values = (Rng) uniqueValues = set(values) self.items = [] for uniqueValue in uniqueValues: self.items.append(uniqueValue)
... View more
03-13-2014
02:23 PM
|
0
|
2
|
745
|
POST
|
And remember when you access your combobox you need to first have assign it properties through the class level self variables. You might be missing this part in your combobox class. def onSelChange(self, selection):
self.sel = selection
Then get the selection in your other classes like this. combobox.sel Awesome, I got it to work! The whole code works great now, thanks for the help. How about a bonus round? This is just a portion of the code, with this I populate the combobox with only unique values from the attributes, I want it sorted but something isn't working there, any ideas? Twp = []
for row in arcpy.SearchCursor("X:\JasonGraham\Landstatus\Data\ls2014.gdb\BaseData\Townships"):
Twp.append(row.TWP_NUMC)
class ComboBoxClass5(object): #Collect Township from list of unique values gathered from the layer
"""Implementation for MTR_addin.combobox_1 (ComboBox)"""
def __init__(self):
self.value = "000"
self.items = sorted(Twp)
self.editable = True
self.enabled = True
self.dropdownWidth = 'WWWW'
self.width = 'WWWW'
def onSelChange(self, selection):
self.sel = selection
#global valName
#val = (self.items, selection)[1]
#valName = str(val)
def onEditChange(self, text):
pass
def onFocus(self, focused):#show only unique values
if focused:
values = sorted(Twp)
uniqueValues = set(values)
self.items = []
for uniqueValue in uniqueValues:
self.items.append(uniqueValue)
def onEnter(self):
pass
def refresh(self):
pass
... View more
03-13-2014
08:57 AM
|
0
|
0
|
176
|
POST
|
print combobox? Are you trying to run this in an IDE? That won't work for addins. You'll only be able to reference the class values via the ID when it is installed as an addin. What is your end goal for this addin? ok, here is the whole code. The original code works as a script but I decided to try making an addin tool. I am not a great coder, trying to learn. This tool references a township and range layer, with the comboboxs the user can select meridain, township, north/south, range, east/west. much of the code works to populate the pull down from the attributes with unique values but doesnt seem to sort. I am able to pass the values for my Twp and Rng but not the M, NS, EW that have a list of values, I could populate like the other two but it seems to bog down, suggestions?( no longer a simple question i guess) alot of stuff on the bottom blocked out that I am working on. # ---------------------------------------------------------------------------
# Township Selector
# Created on: 2014-02-24 15:28:23.00000
# Create by Jason Graham
# Usage: <NS> <EW> <Rng> <Twp> <M> <MTR> <MTRsel>
# Description:Add-in tool to easily select a township then zoom to the selection
# ---------------------------------------------------------------------------
import arcpy
import pythonaddins
from arcpy import env
env.workspace = r"X:\JasonGraham\Landstatus\Data\ls2014.gdb\BaseData"
mxd = arcpy.mapping.MapDocument("CURRENT")
class ComboBoxClass4(object):
"""Implementation for MTR_addin.combobox (ComboBox)"""
def __init__(self):
self.value = "S"
self.items = ("C", "F", "K", "S", "U")
self.editable = True
self.enabled = True
self.dropdownWidth = 'WWW'
self.width = 'WWW'
def onSelChange(self, selection):
pass
def onEditChange(self, text):
pass
def onFocus(self, focused):
pass
def onEnter(self):
pass
def refresh(self):
pass
Twp = []
for row in arcpy.SearchCursor("X:\JasonGraham\Landstatus\Data\ls2014.gdb\BaseData\Townships"):
Twp.append(row.TWP_NUMC)
class ComboBoxClass5(object):
"""Implementation for MTR_addin.combobox_1 (ComboBox)"""
def __init__(self):
self.value = "010"
self.items = sorted(Twp)
self.editable = True
self.enabled = True
self.dropdownWidth = 'WWWW'
self.width = 'WWWW'
def onSelChange(self, selection):
global valName
val = (self.items, selection)[1]
valName = str(val)
def onEditChange(self, text):
pass
def onFocus(self, focused):#show only unique values
if focused:
values = sorted(Twp)
uniqueValues = set(values)
self.items = []
for uniqueValue in uniqueValues:
self.items.append(uniqueValue)
def onEnter(self):
pass
def refresh(self):
pass
class ComboBoxClass6(object):
"""Implementation for MTR_addin.combobox_2 (ComboBox)"""
def __init__(self):
self.value = "N"
self.items = ("N", "S")
self.editable = True
self.enabled = True
self.dropdownWidth = 'WWW'
self.width = 'WWW'
def onSelChange(self, selection):
pass
def onEditChange(self, text):
pass
def onFocus(self, focused):
pass
def onEnter(self):
pass
def refresh(self):
pass
Rng = []
for row in arcpy.SearchCursor("X:\JasonGraham\Landstatus\Data\ls2014.gdb\BaseData\Townships"):
Rng.append(row.RNG_NUMC)
class ComboBoxClass7(object):
"""Implementation for MTR_addin.combobox_3 (ComboBox)"""
def __init__(self):
self.value = "010"
self.items = sorted(Rng)
self.editable = True
self.enabled = True
self.dropdownWidth = 'WWWW'
self.width = 'WWWW'
def onSelChange(self, selection):
global valName
val = (self.items, selection)[1]
valName = str(val)
def onEditChange(self, text):
pass
def onFocus(self, focused):#show only unique values
if focused:
values = sorted(Rng)
uniqueValues = set(values)
self.items = []
for uniqueValue in uniqueValues:
self.items.append(uniqueValue)
def onEnter(self):
pass
def refresh(self):
pass
class ComboBoxClass8(object):# Collect East/west
def __init__(self):
self.value = "E"
self.items = ("E", "W")
self.editable = True
self.enabled = True
self.dropdownWidth = 'WWW'
self.width = 'WWW'
def onSelChange(self, selection):
selection
def onEditChange(self, text):
pass
def onFocus(self, focused):
pass
def onEnter(self):
pass
def refresh(self):
self.refresh()
#concatenate inputs
#MTRsel = combobox + Twp + combobox_2() + Rng(selected) + combobox_4()
#print ComboBoxClass8(self)
class ButtonClass3(object):
"""Implementation for MTR_addin.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
pass
#arcpy.SelectLayerByAttribute_management("Townships","NEW_SELECTION",'"MTR" =' + "'%s'" %MTRsel)
#arcpy.mapping.ListDataFrames(mxd)[0].zoomToSelectedFeatures()
return None
# Select user input value
#arcpy.SelectLayerByAttribute_management("Townships","NEW_SELECTION",'"MTR" =' + "'%s'" %MTRsel) #gets error "ExecuteError: ERROR 000358: Invalid expression
#arcpy.SelectLayerByAttribute_management("Townships","NEW_SELECTION",'"MTR" =' + MTRsel) gets error "TypeError: cannot concatenate 'str' and 'list' objects"
#arcpy.SelectLayerByAttribute_management("Townships","NEW_SELECTION",MTRsel) gets error RuntimeError: Object: Error in executing tool
#Zoom to selection
#arcpy.mapping.ListDataFrames(mxd)[0].zoomToSelectedFeatures()
... View more
03-12-2014
01:56 PM
|
0
|
0
|
917
|
POST
|
Then you probably changed it manually. Check in the addin assistant what the ID is for your combo box class. All you need are in the help docs. http://resources.arcgis.com/en/help/main/10.2/index.html#/combo_box/014p00000028000000/ - <Toolbar caption="MTR Select" category="Township Select" id="MTR_addin.toolbar" showInitially="true">
- <Items>
<Button refID="MTR_addin.button" />
<ComboBox refID="MTR_addin.combobox" />
<ComboBox refID="MTR_addin.combobox_1" />
<ComboBox refID="MTR_addin.combobox_2" />
<ComboBox refID="MTR_addin.combobox_3" />
<ComboBox refID="MTR_addin.combobox_4" />
</Items>
</Toolbar>
</Toolbars> I did not change it, it is combobox, but if I try 'print combobox' I get the error ' combobox not defined
... View more
03-12-2014
01:31 PM
|
0
|
0
|
917
|
POST
|
You need to use the ID from the addin assistant. In your case it is called 'combobox' Nope, says combobox not defined. Do you know of any better resources for arcpy addin, the python is different from scrpting
... View more
03-12-2014
01:09 PM
|
0
|
0
|
917
|
Title | Kudos | Posted |
---|---|---|
1 | 08-23-2019 11:21 AM | |
1 | 07-20-2023 03:02 PM | |
1 | 07-08-2014 05:06 PM |
Online Status |
Offline
|
Date Last Visited |
a month ago
|