|
POST
|
It's for a script tool. I'm using a string parameter with a value list. Right now the value list is generated in teh script tool but could be created using validation class I guess? I have 6 string values that I'd like to set by default to True or Checked. So when the script tool is opened the multivalue string check boxes are selected. I'm not stuck on string as a type, I could easily select another data type and work with that. Using individual Boolean parameters makes the script tool extend too far (too much screen space), unless there's a way to arrange Boolean within the script tool? Thanks Jon
... View more
03-16-2013
12:58 PM
|
0
|
0
|
1537
|
|
POST
|
Hi all, is there a way to set the default values in a multivalue Parameter to True or Selected? Thanks
... View more
03-14-2013
04:18 PM
|
0
|
4
|
3625
|
|
POST
|
Setup a python script in a toolbox, then call the script using pythonaddins.GPToolDialog(toolboxname, scriptname)
... View more
02-27-2013
01:30 PM
|
0
|
0
|
1582
|
|
POST
|
Working this problem some more this morning, I thought I MUST be passing bad coordinates and pointing to a location where there is indeed have no data. I've tried several ways to manually enter the location points, still no luck though, cellvalue still returns �??noData�?? From a python IDE session
rasterLayer = <map layer u'grdn35w121_13'>
>>> rasterLayer.isRasterLayer
True
x = '213860'
y = '3835693'
>>> place = '%s %s' % (x,y)
>>> place
'213860 3835693'
cellvalue = arcpy.management.GetCellValue(rasterLayer, place)
>>> cellvalue
<Result 'NoData'>
From the screen shot there is data at these x, y points. Not sure where I'm going wrong here, the arcmap �??help�?? doesn't exactly provide much help either. [ATTACH=CONFIG]22174[/ATTACH]
... View more
02-26-2013
07:24 AM
|
0
|
0
|
2539
|
|
POST
|
Been struggling with this for a couple of days now and could use a fresh set of eyes on the problem. I'm trying to get an elevation spot value for a DEM file. When I inspect any point with the Information Tool I get a pixel value of elevation. However when I try tp pull the value using arcpy.management.GetCellValue() I always get a NoData. This is pretty generic code that was pulled form Google searches, it reports the X and Y correctly just not the pixel value. Any help would be appreciated Thanks
class ToolClass10(object):
"""Implementation for MapSARElevation_addin.tool_1 (Tool)"""
def __init__(self):
self.enabled = True
self.shape = "NONE" # Can set to "Line", "Circle" or "Rectangle" for interactive shape drawing and to activate the onLine/Polygon/Circle event sinks.
def onMouseDown(self, x, y, button, shift):
pass
def onMouseDownMap(self, x, y, button, shift):
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
layers = arcpy.mapping.ListLayers(mxd, None, df)
rasterlayer = None
for layer in layers:
if layer.isRasterLayer:
rasterlayer = layer
break
if rasterlayer:
cellvalue = arcpy.management.GetCellValue(rasterlayer, "{} {}".format(x, y)).getOutput(0)
pythonaddins.MessageBox("XY: {}, {}\nCell Value: {}".format(x, y, cellvalue), "Results")
... View more
02-25-2013
08:01 PM
|
0
|
4
|
4486
|
|
POST
|
I have written an add-in with the new pythonaddins class, I want code to execute when editing is stopped AND data saved, not when editing is stopped and edits NOT saved. Here's an extract of the code, the script doesn't appear to honor the save_changes option and runs whenever editing has been stopped. Any insights would be appreciated.
class ExtensionClass1(object):
"""Implementation for MakeMaps_addin.extension_1 (Extension)"""
def __init__(self):
# For performance considerations, please remove all unused methods in this class.
self.enabled = True
def onStopEditing(self, save_changes):
try:
# Local variables:
Other code to execute goes here
... View more
02-06-2013
02:57 PM
|
0
|
0
|
807
|
|
POST
|
Try looking into attribute assistant, it's part of the GIS for local government.
... View more
01-04-2013
05:46 AM
|
0
|
0
|
2597
|
|
POST
|
Perfect Wayne! I'll keep this little function in my toolbox from now on. Thanks again for all your help Jon
... View more
12-20-2012
08:43 AM
|
0
|
0
|
883
|
|
POST
|
I'm getting a syntax error when using arcpy.SelectLayerByAttribute_management but the actual query works perfectly when running from within an attribute table and using Select By Attribute.. Thanks Wayne Jon
... View more
12-20-2012
03:32 AM
|
0
|
0
|
2341
|
|
POST
|
Guys, I'm hung up on one more of these, jeeze! querying a text field for fields that are not empty. My search string that works in the attribute table is iField = arcpy.AddFieldDelimiters(fc, "Area_Name") iQuery = iField+ " IS NOT NULL" This doesn't want to work in arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", iQuery) Killin' me !
... View more
12-19-2012
07:42 PM
|
0
|
0
|
2341
|
|
POST
|
Ok I think all this was a corrupt MXD file, interesting.
... View more
12-19-2012
01:40 PM
|
0
|
0
|
1346
|
|
POST
|
Update: This is happening with all my scripts so isn't code dependent. I've re installed SP1 for 10.1 Next is to see if the DB or mxd is corrupt
... View more
12-19-2012
12:49 PM
|
0
|
0
|
1345
|
|
POST
|
And here's my parameters code in case the bug lies here
import arcpy
from arcpy import env
class ToolValidator(object):
"""Class for validating a tool's parameter values and controlling
the behavior of the tool's dialog."""
def __init__(self):
"""Setup arcpy and the list of tool parameters."""
self.params = arcpy.GetParameterInfo()
def initializeParameters(self):
"""Refine the properties of a tool's parameters. This method is
called when the tool is opened."""
subjects = []
fc = "PLS_Subject_Information"
field = "Name"
cursor = arcpy.SearchCursor(fc)
for i in cursor:
sName = i.getValue(field)
subjects.append(sName)
self.params[6].filter.list = subjects
self.params[6].value = subjects[0]
return
def updateParameters(self):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
def updateMessages(self):
"""Modify the messages created by internal validation for each tool
parameter. This method is called after internal validation."""
return
[ATTACH=CONFIG]20085[/ATTACH]
... View more
12-19-2012
12:20 PM
|
0
|
0
|
1345
|
|
POST
|
Thanks very much! Now I "get it" the arcpy.AddFieldDelimiters and the help from Wayne did the trick. Thanks !!
... View more
12-19-2012
09:16 AM
|
0
|
0
|
2341
|
|
POST
|
Not sure how else to say it, but after running the code below, the processing window just flashes continually and the script doesn't ever appear to end. I have to kill ArcMap process to get out of the script. I'm posting my entire code snippet below, hopefully someone can point out my error. Warning, new Python coder here, please don't laugh "too hard' at my brute force coding attempts 😛 # Jon Pedder # MapSAR - 12/15/12 # Make Briefing Map import arcpy, os, glob # Set enviroment # from arcpy import env # Gather input parameters from user # 0. TargetFile mxd - string # 1. Folder to store pdf product - string # 2. Title of the Map - string # 3. Name of saved map - string # 4. Map Scale - string # 5. Center map on - list, string # 6. Use base data in current map - boolean TargetFile = arcpy.GetParameterAsText(0) PDFlocation = arcpy.GetParameterAsText(1) aMapTitle = arcpy.GetParameterAsText(2) aMapName = arcpy.GetParameterAsText(3) aMapScale = arcpy.GetParameterAsText(4) aCenterMapOn = arcpy.GetParameterAsText(4) aBase_Data = arcpy.GetParameterAsText(6) # Set Vars and overwrite option to true arcpy.env.overwriteOutput = True Targetmxd = None mxd = None arcpy.AddMessage("Base data = " + aBase_Data) ######################################## ###### BASE DATA COPY STARTS HERE # ######################################## # Gather information to copy over base_data if aBase_Data == "true": # Define vars mxdlayer = "14 Base_Data_Group" LayerFile = "C:\MapSAR\TempDir\Base_Layer" LayerName = LayerFile + '.lyr' # Save base_data layer file to disk in c:\MapSAR\TempDir from current mxd. # If directory does not exist create it if os.path.exists('c:\MapSAR\TempDir'): arcpy.SaveToLayerFile_management(mxdlayer,LayerFile,"RELATIVE") else: os.makedirs('c:\MapSAR\TempDir') arcpy.SaveToLayerFile_management(mxdlayer,LayerFile,"RELATIVE") # Message to user arcpy.AddMessage("Base Data Saved as "+ LayerFile) Targetmxd = arcpy.mapping.MapDocument(TargetFile) # Check for existing Base_Data layers in target. If present remove them for df in arcpy.mapping.ListDataFrames(Targetmxd): for lyr in arcpy.mapping.ListLayers(Targetmxd, "", df): if 'Base_Data' in lyr.name: arcpy.mapping.RemoveLayer(df,lyr) # Message to user that layers have been removed from target arcpy.AddMessage('removing '+ str(lyr) + ' from '+TargetFile) # Message to user arcpy.AddMessage('Loading Base_Data '+ LayerName +' from disk') # Check if the layer exists on disk if os.path.isfile(LayerName): addLayer = arcpy.mapping.Layer(LayerName) arcpy.mapping.AddLayer(df, addLayer, "BOTTOM") Targetmxd.save() else: # If not alert user of an error arcpy.AddMessage(LayerName +' does not exist') ######################################## ###### BASE DATA COPY ENDS HERE # ######################################## ######################################## ###### EXPORT MAP STARTS HERE # ######################################## MapTitle = aMapTitle MapName = aMapTitle + ".pdf" MapLocation = PDFlocation + "/" + aMapName + ".pdf" arcpy.AddMessage("Generating Briefing Map " + MapName) mxd = arcpy.mapping.MapDocument(TargetFile) for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT","MapTitle"): elm.text = "<BOL> " + MapTitle + "</BOL>" for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT","MapName"): elm.text = MapName fc = "PLS_Subject_Information" # iQuery = "Name =" + aCenterMapOn iQuery = ' "Name" = \'Jon Pedder\' ' df = arcpy.mapping.ListDataFrames(mxd, "MapSAR")[0] lyr = arcpy.mapping.ListLayers(mxd, "PLS_Subject_Information", df)[0] arcpy.AddMessage("Panning to center on PLS for "+ aCenterMapOn) # Use the SelectLayerByAttribute tool to select PLS Subject and # zoom to the selection arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", iQuery) df.zoomToSelectedFeatures() df.scale = aMapScale # Export the map to a .pdf arcpy.mapping.ExportToPDF(mxd,MapLocation) ######################################## ###### EXPORT MAP ENDS HERE # ######################################## # Clear vars del mxd, Targetmxd
... View more
12-19-2012
08:59 AM
|
0
|
3
|
1617
|
| Title | Kudos | Posted |
|---|---|---|
| 3 | 07-11-2013 02:09 PM | |
| 2 | 07-31-2012 09:51 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|