POST
|
When trying to use the arcpy.env.autoCancelling feature I seem unable to call arcpy.Delete_management() after cancellation without encountering a 000582 error. The code below replicates the error when used as an ArcToolbox Python script if the Cancel button is pressed during the process. The sleep delay is probably unnecessary but gives some breathing space. The code is a simplified and parameter/input free version of the ESRI example here. The workspace variable needs to be modified prior to set up. import time
import arcpy
arcpy.env.autoCancelling = False
def my_function():
temp_tables = ['replicant_1', 'replicant_2', 'replicant_3', 'replicant_4']
workspace = r'C:/Users/username/Documents/ArcGIS/Default.gdb'
try:
for fc_name in temp_tables:
arcpy.CreateFeatureclass_management(workspace, fc_name, 'POINT')
arcpy.AddMessage('WAITING')
time.sleep(3)
arcpy.AddMessage('FINISHED')
if arcpy.env.isCancelled:
raise Exception('Tool has been cancelled')
except Exception as err:
arcpy.AddError(err)
finally:
# If tool is cancelled or finishes successfully, clean up
if temp_tables:
for temp_table in temp_tables:
arcpy.AddMessage(temp_table)
try:
arcpy.Delete_management(temp_table)
except Exception as err:
arcpy.AddError('DELETE FAILED')
arcpy.AddError(err)
if __name__ == '__main__':
my_function() I've tried checking that the data exists and that there are no locks and neither of these seem to be the issue. I've also tried as background and foreground geoprocessing. It fails in both ArcMap 10.5 and ArcGIS Pro 2.4 (the code is good to switch between Python 2.x and 3.x) Interestingly if I run the Toolbox again immediately after and at least one of the created files exists and arcpy.env.overwriteOutput is False this causes an error which is caught by the general exception handler and all of the existing files are deleted as expected. This indicates to me that the parameters are valid which is at least half the issue found in the 000582 Error Explanation so maybe it is the Execute Implementation?
... View more
12-18-2019
06:41 PM
|
0
|
0
|
571
|
POST
|
Hi Riyas, So far I have managed to get away with not using "dojo.require" at all in my project. My understanding was that including lines like /*global dojox*/ should be the same as require. Relatively new to Javscript at the moment so am quite likely making basic errors. I tried including dojo.require("dojox.charting.Chart"); in the first line of the createLineChart function with no success but not sure if that is the right place to do it.
... View more
10-06-2014
09:59 PM
|
0
|
2
|
418
|
POST
|
I am having trouble accessing some of the features of Dojo via the ESRI js. I have used several links to no avail http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/ http://js.arcgis.com/3.10/ http://js.arcgis.com/3.11/ ) When I try to use dijit.form.Form I hit an undefined error. I notice that this is not referenced in any of the above links. I resolved this problem by using dijit.layout.ContentPane. Notably I could use dijit.form.Button and dijit.form.TextBox so it is not an issue with dijit.form. Now I am hitting a similar error with dojox.charting however I do not appear to be able to hit dojox.charting at all. Once again I notice that it is not referenced in the linked Javascript. I have minimal HTML scripting as I am building nearly everything programatically: <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="http://js.arcgis.com/3.11/"></script> My Javascript looks like this: /*global esri*/ /*global dojo*/ /*global dijit*/ /*global dojox*/ function createLineChart(startMeasure, elevations) { var lineChart = new dojox.charting.Chart("simplechart"); lineChart.addPlot("default", {type: "Lines"}); lineChart.addAxis("x"); lineChart.addAxis("y", {vertical: "true"}); lineChart.addSeries("SERIES X", elevations); lineChart.render(); } The error is on the first line of the function where Chart is undefined, charting is also undefined as is Chart2D. I am perplexed as to why everything else works but I do not seem to be hit a number of functions from the Dojo toolkit when I can use other functions in the same namespace.
... View more
10-06-2014
08:53 PM
|
0
|
4
|
885
|
POST
|
When using arcpy.Append_management and using "NO_TEST" we only map to those fields that are identical. However when we use arcpy.FieldMappings() we seem to lose all of the automatic mappings and all fields must be explicitly mapped. Is there a way to keep the automated mapping and just map those that aren't identical OR overwrite ones that need to be updated?
... View more
09-04-2014
06:45 PM
|
0
|
0
|
820
|
POST
|
NIM101698 NIM099971 NIM096788 Most were generated between November 2013 and May 2014. I haven't had the opportunity/motivation to go back and check the status recently.
... View more
08-12-2014
09:26 PM
|
0
|
2
|
1487
|
POST
|
I have had issues using Python to accomplish a very similar task. I eventually rewrote my MXD script in C# and found that the errors that were killing Python were coming from deeper errors in the ESRI DLL's. Likewise they would kill my C# code and the resident application. On the upside this generated a 'Application Error' incident in 'Event Viewer -> Window Logs -> Application' which pointed directly to the DLL in question. From here I was able to at least target the specific dataset or function causing the error. This may be generated under Python also but I never checked. I have a few bugs logged with ESRI for these issues at the moment. These relate to errors in the GDAL library with reading some files, CadEngine.dll, a TsbleUI.dll issue and some others I can't recall off the top of my head. Any of these may be issues you are getting also. One of the fun things with scanning an MXD is that you run throughs all your data in its many different forms which tends to trigger the undocumented features of the software.
... View more
08-12-2014
06:49 PM
|
0
|
4
|
1487
|
POST
|
No solution as yet. Bug #NIM078454 The work around provided doesn't work so I wouldn't bother with that either.
... View more
02-03-2013
03:49 PM
|
0
|
0
|
621
|
POST
|
Ironically, exporting to GRID does not work when I use Data --> Export Data however TIFF works perfectly that is no rounding of digits. This is due to the limitations in GRID export. Pixel, type, number of bands or colour map. In the GRID export it notes a 32bit value rather than 64bit for TIFF. On the other hand when I use SaveAs, GRID is the only one I can get to work. TIF completes okay and seems to reference a 10Mb file when I open it in ArcMap. However there is no data and the TIF and TDW files in the file system only take up 1Kb each. Data in TDW looks fine though. Also, when I query using the Identify tool within the expected bounds it comes up as 'No Data' rather than not displaying because the Identify query is outside the bounds. Likewise IMAGINE Image seems to export okay using Data --> Export Data. Like TIFF however in ArcObjects it does not fail causing an error but completes with empty data. Also, yes, pixel is decreasing from 13x17 to 13x13
... View more
03-01-2012
07:40 PM
|
0
|
0
|
859
|
POST
|
Cheers Priyanka, that works about 95%. Will give you an upvote because I think it should work 100%. Unfortunately I am getting rounded values in my resampled raster. e.g. 10.1 becomes 10 as does 10.6. I have removed the entire resampling section. This seems to export exactly the same data as when it was there. It appears that SaveAs2 is responsible for rounding the data. I have no idea why or how to fix.
... View more
02-29-2012
05:09 PM
|
0
|
0
|
859
|
POST
|
Pretty basic code. Straight out of help.
//Open MXD and get first dataframe then get the first layer from the data frame.
MapDocument tempMxd = new MapDocument();
tempMxd.esri_new("E:/OutputDirectory/tempmxd.mxd");
IMap map = tempMxd.getMap(0);
ILayer layer = map.getLayer(0);
//Create a workspace so we can work with the data
WorkspaceFactory wkspf = new RasterWorkspaceFactory();
IWorkspace wksp = wkspf.openFromFile("E:/outputDir/", 0);
IRasterLayerExport3 rle = new RasterLayerExport();
IRasterLayer rl = (IRasterLayer) layer;
//Tweak how we want to export (at least as far as possible)
rle.setRasterLayerByRef(rl);
rle.setExtent(rl.getAreaOfInterest());
rle.setForce2RGB(false);
//Don't compress
IRasterStorageDef rsd = new RasterStorageDef();
rsd.setCompressionType(esriRasterCompressionType.esriRasterCompressionUncompressed);
rle.setStorageDefByRef(rsd);
//Export.
rle.export(wksp, "exportLayer.bil", "BIL");
//Note: No other file types work here either but I am willing to accept any uncompressed raster type besides BIL if it works
... View more
02-26-2012
01:31 PM
|
0
|
0
|
859
|
POST
|
Yeah, bad explanation. Sorry. Basically by non-standard I mean the input pixel width isn't a square e.g. 13x13 rather it is 17x13. That is the only thing non-standard about it. I think it is the resampling here that may be the problem. But of course maybe not. I think it forces the renderer to be used. ArcGIS automatically resamples and outputs as 13x13 grid so that is fine though I have tried forcing to 13x13 also with the same effect.
... View more
02-23-2012
09:37 PM
|
0
|
0
|
859
|
POST
|
Probably led you down the garden path with RE. Sorry about that. I have tried for a bit to solve the problem seeming as the data is openly available. It seems to be really unrespsonsive to the point where I can't achieve it manually. My gues is that if it can't be done manually it can't be done. I even tried replicating the problem locally however I cannot create feature class names with a forward slash. I would probably give it a miss or even contact the service provider and tell them about the problem. They may even appreciate knowing their data is inaccessible.
... View more
02-23-2012
05:43 PM
|
0
|
0
|
300
|
POST
|
I am trying to use IRasterLayerExport3 to export a non-standard raster, pixel width 17x13, to a standard format, 13x13 via ArcObjects. The problem is that every attempt I make brings the data down to a value in the range 0-255 as opposed to the floating point numbers contained in the original data. It appears that the Raster Renderer is being forced though it is unselected by default when using Data-->Export in ArcGIS --> Use Renderer. The Developer Help page states "If you don�??t want to use the raster renderer to filter the pixel values during the export, remove the raster renderer from the raster layer before passing it to the RasterLayerExport object." http://resources.esri.com/help/9.3/arcgisengine/ArcObjects/esriCarto/IRasterLayerExport_RasterLayer.htm However it is not explained how this could be achieved. The simples solution as I see it using the command 'rasterLayer.setRendererByRefto(null);' crashes the program with an Invalid Pointer Automation Exception. I am using ArcGIS 10 however I could only find reference to the renderer info in the 9.3 version so that is why I have chosen that link.
... View more
02-23-2012
04:30 PM
|
0
|
9
|
5411
|
POST
|
Have you tried using regular expressions? http://docs.python.org/library/re.html
... View more
02-14-2012
04:42 PM
|
0
|
0
|
300
|
Title | Kudos | Posted |
---|---|---|
2 | 09-05-2011 08:13 PM | |
1 | 09-14-2011 08:00 PM |
Online Status |
Offline
|
Date Last Visited |
01-07-2024
04:01 PM
|