MakeXYEventLayer or FeatureClassToFeatureClass_conversion Cause Crash

761
11
12-10-2019 11:21 AM
guillaumemure
New Contributor

I am new to coding in python, my problems is the machine crashing halfway through first loop, and yet another five with its modulesScript .

i have "Serious Application Error" with the opportunity to send info to Esri.

i use script in toolbox, i have arcmap 10.6 .

Thanks.

0 Kudos
11 Replies
DanPatterson_Retired
MVP Emeritus

Could you format your code so that there are line numbers and indentation can be checked

/blogs/dan_patterson/2016/08/14/script-formatting 

0 Kudos
guillaumemure
New Contributor

The script launches is carried out a first step [1/5] without XY event and Feature Class conversion, and in step 2/5 at the level of xy event and feature class crash conversion because the text file is created.

Thanks,

0 Kudos
guillaumemure
New Contributor

can be a memory problem, with the selections of different objects in different layers, is possible?

0 Kudos
RandyBurton
MVP Alum

Can you describe what you want your script tool to do?  A description of the tool's function may assist in getting an answer to your question.

I would suggest that you do some testing of the code before putting it in a script tool.  This will help debug the script as error messages will display and help pinpoint the source of the problem.

I've retyped your code as Dan Patterson‌ has suggested (using the syntax highlighter).  This format will give some line numbers to aid in the discussion.

import arcpy, math, os

arcpy.env.workspace = arcpy.GetParameter(0)
arcpy.env.overwriteOutput = True
ParemListFea = arcpy.GetParameter(1)
ParemSpat = arcpy.GetParameter(2)
try:
    SpatRef = ParemSpat
    SelectMob = arcpy.SelectLayerByAttribute_management(MobFeat, "NEW_SELECTION", "nom = '1105'")
    ComMob = arcpy.GetCount_management(SelectMob)

    MobFeat = "Mobilier_Urbain_L" 
    OutMob = "Mobilier0"
    OutTempMob = "MobilierTemp"
    Dbf_Mob = "Mobilier_Urbaine_L.dbf"
    OutTxt_Mob = "Mobilier_U_L.txt"
    if ListFeatIn == "Mobilier_Urbain_L.shp" and ComMob > 0:
        arcpy.TableToTable_conversion(Dbf_mob, arcpy.env.workspace, OutTxt_Mob)
        arcpy.MakeXYEventLayer_management(OutTxtMob, FieldX1, FieldY1, OutTempMob, ParemSpat, FieldZ1)
        arcpy.FeatureClassToFeatureClass_conversion(OutTempMob, arcpy.env.workspace, OutMob) 

From the code snippet above, I notice that several variables are referenced before they are defined.

In line 9, MobFeat is being referenced, but it is not defined until line 12. Perhaps line 12 should be moved before line 9 ?

And in line 17 the value of ListFeatIn is being checked to see if it matches the name of a shape file.  Perhaps ListFeatIn is supposed to be ParemListFea ?  I do not see a reference to ParemListFea being used later in the script.

Line 17 also references ConMob.  This value will be zero or None if the SelectLayerByAttibute fails at line 9.  The where clause in line 9 is referencing a field nom and checking for a certain text string '1105' that may be a number 1105.  This will affect what is being returned by the query.

These are just a few quick observations.  Please tell us more about your project.

0 Kudos
guillaumemure
New Contributor

I want my script to make some layers, with different orientations, the input layer is always of type line, * _L, the orientation varies according to the layer. it is for the purpose of automation, that's why I check if the layer contains objects because all the objects of the layers are not to orientate.

Yes it's true, it's a short extract copy, you were right for line 9 normally in my script it is after, copy paste a little too fast ...
and for line 17 yes ListFeatIn
ListFeat = ParemListFea
for ListFeatIn in ListFeat :
   if ListFeatIn == "Mobilier_Urbain_L.shp" and ComMob > 0:
the process starts without reporting an error except when I run it in the background select layer announces an error.
Thank   
0 Kudos
DanPatterson_Retired
MVP Emeritus

don't run it in the background, fails have been reported in that environment when things work in the foreground and that is the recommended solutioin

0 Kudos
guillaumemure
New Contributor

Ok, i tested my code with an orientation operation and no problem but with 5 crashes, and i have in toolbox Windows, that message: [< geoprocessing value object at 0x30AC4F98>, <geoprocessing value object object at 0x30AC4FE0>] when 5 operation.

Thanks,

0 Kudos
RandyBurton
MVP Alum

Thank you for the additional description of your project.  I am still trying to understand the work flow.

Is arcpy.GetParameter(1) around line 5 fetching a list of shapefiles, such as [ 'Mobilier_Urbain_L.shp', 'M_U_L.shp', ....] ?

And starting around line 15 to 19, is the .dbf file being converted to a text file and then into an XY layer file?  Since the .dbf would be part of the shape file, is there a reason to do an XY conversion?   Perhaps it would be better to converting the shape file to a feature layer with MakeFeatureLayer and then saving it with FeatureClassToFeatureClass?

tmplyr = arcpy.MakeFeatureLayer_management(r'C:\path\to\shapefile.shp','tmplyr')

arcpy.FeatureClassToFeatureClass_conversion("tmplyr",r'C:\path\to\file.gdb','shp_conv')

Thanks.

0 Kudos
guillaumemure
New Contributor

I need to transform lines into points, because my X1Y1 are the center of the objects and X2Y2 allows me to calculate the orientation of the future symbol

is it possible to do it with makeFeature?
0 Kudos