|
POST
|
Thanks. It is still not working though I do believe the Delete management had to do with it. What I did was drag around a boundary and nothing comes out..so I modifty to see what happens and this only works... so I put number sign next to 04 and 05 . See here: def onRectangle(self, rectangle_geometry):
extent = rectangle_geometry
arcpy.env.workspace = r"c:\ArcpyBook\Ch11"
#if arcpy.Exists('randompts.shp'):
#arcpy.Delete_management('randompts.shp')
randompts = arcpy.CreateRandomPoints_management(arcpy.env.workspace,'randompts.shp',"",rectangle_geometry)
arcpy.RefreshActiveView()
#return randompts
pass This was from the book I have on page 231 from Programming ArcGIS 10.1 with Python cookbook. I know probably it has change since then. The book was published in 2013.
... View more
03-01-2015
08:55 AM
|
0
|
2
|
2215
|
|
POST
|
You mean I just deleted was because of the same name ? I am still struggled with it and trying to do many different method even I looked at the CreateRandomPoints help on arcgis 10.1.
... View more
02-28-2015
08:35 PM
|
0
|
0
|
2215
|
|
POST
|
import arcpy
import pythonaddins
class ToolClassRandom(object):
"""Implementation for GenerateRandomPoints_addin.tool (Tool)"""
def __init__(self):
self.enabled = True
self.cursor = 3
self.shape = 'Rectangle' # 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):
pass
def onMouseUp(self, x, y, button, shift):
pass
def onMouseUpMap(self, x, y, button, shift):
pass
def onMouseMove(self, x, y, button, shift):
pass
def onMouseMoveMap(self, x, y, button, shift):
pass
def onDblClick(self):
pass
def onKeyDown(self, keycode, shift):
pass
def onKeyUp(self, keycode, shift):
pass
def deactivate(self):
pass
def onCircle(self, circle_geometry):
pass
def onLine(self, line_geometry):
pass
def onRectangle(self, rectangle_geometry):
extent = rectangle_geometry
arcpy.env.workspace = "c:\ArcpyBook\Ch11"
if arcpy.Exists("randompts.shp"):
arcpy.Delete_management("randompts.shp")
randompts = arcpy.CreateRandomPoints_management(arcpy.env.workspace,"randompts","randompts.shp","POINT",rectangle_geometry)
arcpy.RefreshActiveView()
return randompts Been trying to run this code to create an addin for the Generate Random Points. It gave me the error that says: Traceback (most recent call last): File "C:\Users\Pollock\AppData\Local\ESRI\Desktop10.1\AssemblyCache\{A6309427-3034-2E61-07C7-2A592C101F22}\GenerateRandomPoints_addin.py", line 41, in onRectangle return randompts UnboundLocalError: local variable 'randompts' referenced before assignment
... View more
02-28-2015
03:38 PM
|
0
|
6
|
5859
|
|
POST
|
So when I write this code df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0] print df.extent In return the numbers showed me 238135.744094489 3606562.79790026 494041.255905512 3787829.20209974 NaN NaN NaN NaN What does NaN NaN NaN NaN mean ? Is it laughing at me ?? No, I know ! what does it mean, BTW ! Thanks
... View more
02-27-2015
11:17 AM
|
0
|
3
|
4839
|
|
POST
|
When you add the python add in wizard, should it be saved under \USERS|your name|\Desktop\folder name ? Can I save it anywhere in C hard drive ? Thanks
... View more
02-27-2015
07:48 AM
|
0
|
1
|
1756
|
|
POST
|
My question IS how can we know if Pyscripter and ArcMap can communicate to each other BUT what if I want just run like a debug first before the actully work in ArcMap ? For example, you write the code and test it and shows it work and then you can run it either in Python Window or Pyscripter to get the results done ?
... View more
02-26-2015
01:07 PM
|
0
|
0
|
2992
|
|
POST
|
The imagery are set to NAD 1983 UTM Zone 13 N and the code I wrote are done in Pyscripter
... View more
02-26-2015
09:19 AM
|
0
|
1
|
2319
|
|
POST
|
Jake Skinner I tried to set the extent numbers in UTM but it would not allow me to... even I set the df as well... #Set the df to refresh the "Set Extent" df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] arcpy.env.extent ="MAXOF" newExtent = df.extent newExtent.XMin, newExtent.YMin = 210000,360000 newExtent.XMax, newExtent.YMax = 550000,400000 df.extent = newExtent
... View more
02-26-2015
08:28 AM
|
0
|
1
|
2319
|
|
POST
|
Hi evreyone, I am working on this exercise I am not sure of...but I believe there is an error in it. This is from the Programming ArcGIS 10.1 with Python cookbook on page 222 that says: import arcpy
import pythonaddins
class ButtonClassImportWildfires(object):
"""Implementation for WildfireAddIn_addin.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
pass Does it seem correct to you ? Then it says: Remove the pass statement from the onClick event. In Chapter 7, you created a custom script tool that loads wildfire data from a text file to a feature class. Inside the onClick event, call this Load Wildfires from Text custom script tool so that it displays the user interface for selecting the text file, template, and feature class to write to. def onClick(self): LoadWildfires_wildfire() Save the file. When I open that addin to my ArcMap and I can only see this :
... View more
02-25-2015
11:52 AM
|
0
|
4
|
5367
|
|
POST
|
I am trying to set the extent of the ArcMap where I want to add the raster to my ArcMap but this does not work... #Set the Scale extent arcpy.Extent(147806,3495023,584371,3899368) I have looked at the ArcGIS 10.1 help about this but not sure which one is the correct way to display them .
... View more
02-23-2015
10:56 AM
|
0
|
6
|
6657
|
|
POST
|
I took care of it and now it is working that I am enable to connect the server without any problems.
... View more
02-22-2015
03:11 PM
|
0
|
0
|
1070
|
|
POST
|
I am working on loading several NAIP l to my ArcMap and writing a script to call them ...now I am curious if there is an extent that can I get able to work to set them to extent overview ? I looked at the extent but not sure which one is the right one. Can anyone help me out ? Thanks, Robert
... View more
02-18-2015
05:16 PM
|
0
|
1
|
4265
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | a week ago | |
| 1 | 04-08-2026 10:11 AM | |
| 1 | 09-01-2022 03:43 PM | |
| 1 | 09-28-2020 09:34 AM | |
| 2 | 09-24-2025 09:48 AM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|