|
POST
|
Thanks, but that didn't seem change my outputs. -Steven
... View more
03-24-2016
10:53 AM
|
0
|
0
|
1571
|
|
POST
|
Thanks Dan, That seems to do what I need albeit the file naming convention. I can go into your script and change that to what I need it to. Still curious as to why my model doesn't work right. Maybe someone from esri will chime in. Thanks, -Steven
... View more
03-24-2016
10:05 AM
|
0
|
2
|
1571
|
|
POST
|
I have a model that iterates over unique field values and uses the select tool to output features as shapefiles using the unique value as the naming convention. It works....sort of. It runs through the entire iteration but only outputs the first 2 results. The first 2 results are correct but where are the rest of my files going?! Attached is my toolbox. You can use any data you want in it. Using version 10.2.2. -Steven
... View more
03-24-2016
09:35 AM
|
0
|
14
|
4495
|
|
POST
|
I have a script that uses selected feature attributes and pushes them out to a pdf map. The issue is that when a value is Null, the export PDF doesn't work. I've been trying various methods to ignore Null values but I can't get it to work right. Here is the error ArcMap is throwing: return setattr(self._arc_object, attr_name, cval(val)) RuntimeError: TextElementObject: Error in setting text Here's the code pushing out the attributes to the layout pdf. It works right when the value isn't Null. # Set the layer name from the Table of Contents
layer = arcpy.mapping.ListLayers(mxd, "Levee Centerline (Segment Only)")[0]
# create a cursor and grab the first row in the feature class for the layer specified above
rows = arcpy.SearchCursor(layer)
row = rows.next()
#Change title text
titleElement = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT","TitleText")[0]
titleElement.text = row.getValue("FC_SYSTEM.System_Name") Any ideas? -Steven
... View more
03-10-2016
12:26 PM
|
0
|
1
|
2106
|
|
POST
|
Does it need to be a specific shape? If not, just use feet instead. Convert your 180 acres to Sq Ft. When editing, you can right click the map and an option is to specify a length when drawing a polygon. 180 Acres = 7,840,800 Sq Ft. A polygon could be 2700 ft x 2904 ft -Steven
... View more
03-09-2016
03:43 PM
|
0
|
0
|
2633
|
|
POST
|
I created a python add-in that allows the user to search within the map extent and populate a drop down of features. Once you click on a feature in the drop down, it zooms you to it. There is also a clear selection button and an export to PDF button that is hooked up to text elements in map layout view. I've only tested in 10.2.2. You will need to open the file in the install folder to modify and then run the makeaddin.py to commit your changes to the addin. The following pieces will need to be changed for your use: Layer Name, Data Frame Name and all Field Names. Thanks to Wes Miller for the help. Let me know if you see any areas for improvement. -Steven
... View more
03-09-2016
09:00 AM
|
0
|
0
|
3293
|
|
POST
|
Here's my full code. This is for use within an esri addin. The first button allows you to select the features that are within the extent. The combobox has unique values of a specified field from the features within the extent. Select a feature to zoom to it. The 'X' button clears selected results. The PDF export button isn't functional yet. The PDF button will be for exporting the selected feature as a PDF map while dynamically adding attributes to the pdf map. I don't know if this is possible yet. I'll probably be opening another thread for that part. Thanks for the help this far -Steven import arcpy
import pythonaddins
class selectByLocation(object):
"""Implementation for LeveeSearch_addin.ExportPDF (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
self.mxd = arcpy.mapping.MapDocument('current')
df = arcpy.mapping.ListDataFrames(self.mxd, "Region VII") [0]
layer = arcpy.mapping.ListLayers(self.mxd, "Levee Centerline (Segment Only)")[0]
extent = df.extent
extentPoly = arcpy.Polygon(arcpy.Array([arcpy.Point(extent.XMin, extent.YMin), arcpy.Point(extent.XMin, extent.YMax), arcpy.Point(extent.XMax, extent.YMax), arcpy.Point(extent.XMax, extent.YMin)]))
arcpy.SelectLayerByLocation_management(layer, 'intersect', extentPoly)
class LeveeSystemSelector(object):
"""Implementation for LeveeSearch_addin.LeveeSystemName (ComboBox)"""
def __init__(self):
self.items = []
self.editable = True
self.enabled = True
self.dropdownWidth = 'WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW'
self.width = 'WWWWWW'
def onEditChange(self, text):
pass
def onFocus(self, focused):
global layer
global df
self.mxd = arcpy.mapping.MapDocument('current')
layer = arcpy.mapping.ListLayers(self.mxd, "Levee Centerline (Segment Only)")[0]
df = arcpy.mapping.ListDataFrames(self.mxd, "Region VII") [0]
self.items = []
values = [row[0] for row in arcpy.da.SearchCursor(layer, ["FC_SYSTEM.System_Name"])]
for uniqueVal in sorted(set(values)):
self.items.append(uniqueVal)
def onSelChange(self, selection):
arcpy.SelectLayerByAttribute_management(layer, "NEW_SELECTION", "FC_SYSTEM.System_Name = '" + selection + "'")
df.zoomToSelectedFeatures()
arcpy.RefreshActiveView()
def onEnter(self):
pass
def refresh(self):
pass
class ClearSelection(object):
"""Implementation for LeveeSearch_addin.ClearSelected (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
arcpy.SelectLayerByAttribute_management(layer, "CLEAR_SELECTION")
class PDFExport(object):
"""Implementation for LeveeSearch_addin.exportPDF (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
pass
... View more
03-08-2016
11:27 AM
|
2
|
0
|
389
|
|
POST
|
Thanks! I was in the process of moving the location search to a button and now it seems to be functioning right. I will test some more and post my code. -Steven
... View more
03-08-2016
10:10 AM
|
0
|
0
|
389
|
|
POST
|
I was wanting it to repopulate the combo box after clearing the selection but it's not. After the entire script runs, the only piece that runs is the selection by location. The combobox never repopulates so I can select a new value and zoom to. -Steven
... View more
03-08-2016
09:23 AM
|
0
|
2
|
1593
|
|
POST
|
Guess I should clarify a bit more. The Location search fires every time, but the unique field values only get pushed to the combobox the first time. I have a button set to clear selection. Here's my script. It's a bit different from my original. import arcpy
import pythonaddins
class LeveeSystemName(object):
"""Implementation for LeveeSearch_addin.LeveeSystemName (ComboBox)"""
def __init__(self):
self.items = []
self.editable = True
self.enabled = True
self.dropdownWidth = 'WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW'
self.width = 'WWWWWW'
def onEditChange(self, text):
pass
def onFocus(self, focused):
global layer
global df
self.mxd = arcpy.mapping.MapDocument('current')
layer = arcpy.mapping.ListLayers(self.mxd, "Levee Centerline (Segment Only)")[0]
df = arcpy.mapping.ListDataFrames(self.mxd, "Region VII") [0]
extent = df.extent
extentPoly = arcpy.Polygon(arcpy.Array([arcpy.Point(extent.XMin, extent.YMin), arcpy.Point(extent.XMin, extent.YMax), arcpy.Point(extent.XMax, extent.YMax), arcpy.Point(extent.XMax, extent.YMin)]))
arcpy.SelectLayerByLocation_management(layer, 'intersect', extentPoly )
self.items = []
values = [row[0] for row in arcpy.da.SearchCursor(layer, ["FC_SYSTEM.System_Name"])]
for uniqueVal in sorted(set(values)):
self.items.append(uniqueVal)
arcpy.RefreshActiveView()
def onSelChange(self, selection):
self.mxd = arcpy.mapping.MapDocument('current')
arcpy.SelectLayerByAttribute_management(layer, "NEW_SELECTION", "FC_SYSTEM.System_Name = '" + selection + "'")
df.zoomToSelectedFeatures()
arcpy.RefreshActiveView()
def onEnter(self):
pass
def refresh(self):
pass
class ClearSelected(object):
"""Implementation for LeveeSearch_addin.ClearSelected (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
arcpy.SelectLayerByAttribute_management(layer, "CLEAR_SELECTION") -Steven
... View more
03-08-2016
09:13 AM
|
1
|
4
|
1593
|
|
POST
|
Nevermind, It does populate the unique values in the combobox for the select by location query. It seems to only run once though. Going to test some more. -Steven
... View more
03-08-2016
08:29 AM
|
0
|
6
|
1593
|
|
POST
|
That selects all the features, but it doesn't push the field unique values to the combobox. Wonder if I need to create a temporary layer from the select by location results to populate the combobox with the unique values. -Steven
... View more
03-08-2016
08:25 AM
|
0
|
7
|
1593
|
|
POST
|
So basically I need to do the following: -Select my layer based on location (which would be the extent of the map) -Push those field values from the selected into the combobox -Then select by attributes -Steven
... View more
03-08-2016
07:43 AM
|
0
|
9
|
1593
|
|
POST
|
I'm using this thread as the base for my python addin toolbar.How to populate Add-In Combo Box with attributes I was wondering if it was possible to limit the field unique values to whats in the map extent. There are thousands of unique values which doesn't take long to populate the combobox but to help the end user I would like to limit those to what's in the map extent. Here's my python code so far. You select the specific layer, then it sorts and pushes the unique values to a combobox. Once you select a feature from the drop down, it selects and zooms to that feature. import arcpy
import pythonaddins
class leveeLayerListSelector(object):
"""Implementation for LeveeSearch_addin.comboboxLayerList (ComboBox)"""
def __init__(self):
self.items = []
self.editable = True
self.enabled = True
self.dropdownWidth = 'WWWWWWWWWWWWWWWWWWWWWWWWWW'
self.width = 'WWWWWW'
def onEditChange(self, text):
pass
def onFocus(self, focused):
if focused:
self.mxd = arcpy.mapping.MapDocument('current')
layers = arcpy.mapping.ListLayers(self.mxd)
self.items = []
for layer in layers:
self.items.append(layer.name)
def onEnter(self):
pass
def refresh(self):
pass
def onSelChange(self, selection):
global fc
fc = arcpy.mapping.ListLayers(self.mxd, selection)[0]
class leveeSystemSelector(object):
"""Implementation for LeveeSearch_addin.comboboxLeveeSystem (ComboBox)"""
def __init__(self):
self.items = []
self.editable = True
self.enabled = True
self.dropdownWidth = 'WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW'
self.width = 'WWWWWW'
def onSelChange(self, selection):
self.mxd = arcpy.mapping.MapDocument('current')
df = arcpy.mapping.ListDataFrames(self.mxd, "Layers") [0]
arcpy.SelectLayerByAttribute_management(layer, "NEW_SELECTION", "System_Name = '" + selection + "'")
df.zoomToSelectedFeatures()
arcpy.RefreshActiveView()
def onEditChange(self, text):
pass
def onFocus(self, focused):
self.mxd = arcpy.mapping.MapDocument('current')
global layer
layer = arcpy.mapping.ListLayers(self.mxd, fc)[0]
self.items = []
values = [row[0] for row in arcpy.da.SearchCursor(layer, ["System_Name"])]
for uniqueVal in sorted(set(values)):
self.items.append(uniqueVal)
def onEnter(self):
pass
def refresh(self):
pass -Steven
... View more
03-07-2016
08:37 AM
|
0
|
12
|
6213
|
|
POST
|
Hmm, I'm curious how you got IIS 6 on there. With Windows 2012 the default version is IIS 8. -Steven
... View more
03-05-2016
05:47 PM
|
1
|
0
|
2260
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-18-2015 12:38 PM | |
| 1 | 08-28-2015 09:13 AM | |
| 1 | 02-25-2016 03:51 PM | |
| 1 | 09-12-2014 08:32 AM | |
| 1 | 05-21-2015 10:12 AM |
| Online Status |
Offline
|
| Date Last Visited |
09-03-2021
11:21 AM
|