|
POST
|
There is a workaround for the crash. Create a tool for one of the geometry types - in there, in OnMouseDownMap create a point its x, y parameters. In OnMouseUpMap create another point. Essentially, you will click a point, hold down the mouse and release it at another location. Your rectangle will be created with these two points as opposite corner. In case of a circle, the first point will be the center and distance between two points will be the radius. Here is my code for rectangle class: class RectangleToolClass(object):
"""Implementation for AlternativeGeometries_addin.rect_tool (Tool)"""
def __init__(self):
self.enabled = True
self.shape = "NONE"
def onMouseDownMap(self, x, y, button, shift):
self.point1 = arcpy.Point(x, y)
def onMouseUpMap(self, x, y, button, shift):
self.point2 = arcpy.Point(x, y)
array = arcpy.Array()
array.add(self.point1)
array.add(arcpy.Point(self.point2.X, self.point1.Y))
array.add(self.point2)
array.add(arcpy.Point(self.point1.X, self.point2.Y))
array.add(self.point1)
g = arcpy.Polygon(array)
arcpy.CopyFeatures_management(g, r"in_memory\rectangle")
Your onMouseUp method for circle could be: def onMouseUpMap(self, x, y, button, shift):
self.point2 = arcpy.Point(x, y)
pt1 = arcpy.PointGeometry(self.point1)
pt2 = arcpy.PointGeometry(self.point2)
buff_dist = pt1.distanceTo(pt2)
arcpy.Buffer_analysis(pt1, r"in_memory\circle", buff_dist)
The line is simplest 🙂 def onMouseUpMap(self, x, y, button, shift):
self.point2 = arcpy.Point(x, y)
array = arcpy.Array()
array.add(self.point1)
array.add(self.point2)
g = arcpy.Polyline(array)
arcpy.CopyFeatures_management(g, r"in_memory\line")
... View more
06-26-2012
04:49 PM
|
0
|
0
|
2891
|
|
POST
|
Add an Extension along with your button. Here is the code example: import arcpy
import pythonaddins
class ButtonClass1(object):
"""Implementation for StopStartEdits_addin.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
# your button event logic is here
class ExtensionClass2(object):
"""Implementation for StopStartEdits_addin.extension3 (Extension)"""
def __init__(self):
# For performance considerations, please remove all unused methods in this class.
self.enabled = True
def onStartEditing(self):
button.enabled = False
def onStopEditing(self, save_changes):
button.enabled = True The button gets disabled when the user clicks Start Editing and is enabled when the user selects Stop Editing. Enable/Disable is just for example but you can do whatever you want to.
... View more
06-25-2012
05:58 PM
|
0
|
0
|
832
|
|
POST
|
The Make Feature Layer creates a layer, say named "2004_ELB", from the source feature class YearFC. This layer actually is same as the YearFC but lives in memory - it has (in fact, refers to) same number of records and fields. It's just an image of the feature class. So, the Make Feature Layer is not creating any "empty layer" 🙂 Then you make selection from that layer and so on. Note: if this solves your issue please mark the thread as "answered" 🙂
... View more
06-25-2012
02:40 PM
|
0
|
0
|
1378
|
|
POST
|
Curtis, sorry for my mistake. You are right - calculate Value IS available in 9.3. Hi Jose, the tool is under Data Management Tools > General toolset. Click on the link if the message of Curtis to get to tool help.
... View more
06-25-2012
11:30 AM
|
0
|
0
|
1221
|
|
POST
|
Hi Curtis, the model-only tools (such as Calculate Value) were not available in 9.3 or 9.3.1. The only option available was to use a script tool. Here is an example: http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Branching:_Implementing_if-then-else_logic
... View more
06-24-2012
08:28 PM
|
0
|
0
|
1221
|
|
POST
|
Hover over your cursor on the red cross symbol - you'll see a brief error message as tooltip. Now, click on the error symbol - you'll get a little elaborate message along with a number. If you click on the number you'll be taken the relevant help topic. If you get an error sign even before you interact with the tool dialog then it is a defect. Which version of ArcGIS you are using? What type (point, line or polygon) feature class you are trying to use? Are you getting expected result? Follow same steps to get detail on the warning. Generally, you can ignore the warning - if, after reading the message, you think it can be ignored.
... View more
06-24-2012
08:12 PM
|
0
|
0
|
2085
|
|
POST
|
My 9.2 code still works in 10.1. The .create(9.3) makes the new functionalities in 9.3 available to the script. import arcgisscripting
gp = arcgisscripting.create()
rows = gp.SearchCursor(r"C:\data\fgdb.gdb\lines")
row = rows.next()
while row:
print row.getValue("MYFIELD")
row = rows.next()
del row
del rows
... View more
06-24-2012
10:50 AM
|
0
|
0
|
712
|
|
POST
|
You need to create a Python script tool and chain the tool with the GetCount's output. The script tool will intercept the output of GetCount return true or false based on your condition.
... View more
06-24-2012
10:03 AM
|
0
|
0
|
1221
|
|
POST
|
Here is your code simplified - at the end I'm calling Copy Features tool. In your case you need to Point Density tool. import arcpy
# set workspace environment
arcpy.env.workspace = r"C:\data\my.gdb"
#Set OverWrite if files already exist
arcpy.env.overwriteOutput = True
#Create a list of years to iterate through to enable selection of each year
yrlist = [2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011]
YearFC = "myfc"
for year in yrlist:
Year_layer = str(year) + "_ELB"
arcpy.MakeFeatureLayer_management(YearFC, Year_layer)
arcpy.SelectLayerByAttribute_management (Year_layer, "NEW_SELECTION", "\"Yr\" = %d" % (year))
arcpy.CopyFeatures_management(Year_layer, "fc_" + str(year))
... View more
06-24-2012
12:22 AM
|
0
|
0
|
1378
|
|
POST
|
Here is a forum thread - you can take some idea from it. This is similar to what Boone has suggested: Cutting a grid into a smaller grid and retaining values
... View more
06-23-2012
02:26 PM
|
0
|
0
|
1493
|
|
POST
|
Hi Mark, this code works for me. I select few features I want to delete and click on the Button. The selected features get deleted and active view is updated. class ButtonClass1(object):
"""Implementation for UndoRedo_addin.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
edit = arcpy.da.Editor(r'C:\addin\projects\EditSession\f.gdb')
edit.startEditing()
edit.startOperation()
arcpy.DeleteFeatures_management("fishparcels_line")
arcpy.RefreshActiveView()
edit.stopOperation()
edit.stopEditing(True)
arcpy.RefreshActiveView() May be I don not understand what you are trying to do. But, you see both stopEditing and stopOperation are available through the Editor class.
... View more
06-23-2012
02:21 PM
|
0
|
0
|
2219
|
|
POST
|
Sorry Mike and thanks for pointing out the issue. The issue is resolved and will be available in the next service pack (10.1 SP1). Could you please elaborate on "we need more cursors" - if possible with some use cases?
... View more
06-23-2012
12:39 PM
|
0
|
0
|
2891
|
|
POST
|
Very interesting study 🙂 I want to assess the effect of physical proximity of nest boxes on almond production. This could be thought of as a "circle of influence" of a nest box, where there could be overlapping circles for any particular almond tree; or as quantifying almond production as a function of distance(s) from nest box(es). Please clarify: In which area you need help with - which tools to use or how to forumlate methods? How do you want to assess the effect? Have you already decided the 'how' part and need help with the GIS techniques to get a result?
... View more
06-23-2012
12:28 PM
|
0
|
0
|
803
|
|
POST
|
It is not how long arcgisscripting will be around - it is how soon you will be using the new functionalities of arcpy package 😄 For example, in 10.1, there is a data access module in the ArcPy site package. This module makes data processing way faster than using the existing cursors.
... View more
06-22-2012
07:09 PM
|
0
|
0
|
712
|
|
POST
|
You can try creating a script tool with the Python script as the source. You can add Python code to show progression (by %) and show messages on tool dialog. If you use a script tool you won't have to worry about validation - the framework takes care of validation. You can even customize validation if necessary. You can use such a tool just like any system tool. If you are interested start here: A quick tour of creating script tools Basically, you use either argv or arcpy.GetParameterAsText(index) to capture user input. You keep the user updated with messages using arcpy.AddMessage("message text"). To show progression, you can use SetProgressor, ResetProgressor and other progressor methods of arcpy.
... View more
06-22-2012
06:33 PM
|
0
|
0
|
569
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-25-2012 08:20 AM | |
| 1 | 12-18-2019 03:56 PM | |
| 1 | 05-06-2020 01:18 PM | |
| 1 | 07-23-2021 10:33 AM | |
| 1 | 07-28-2020 09:10 AM |
| Online Status |
Offline
|
| Date Last Visited |
10-25-2021
03:13 PM
|