POST
|
when I want to convert from featureclass to CAD DXF it takes too long how can I improve the speed This is part of my code that does the conversion. gp.ExportCAD_conversion(exportParameter, "DXF_R2000", outputDXFName, "Ignore_Filenames_in_Tables", "Overwrite_Existing_Files", "")
... View more
05-17-2012
06:10 AM
|
0
|
1
|
327
|
POST
|
Hey guys, i am some how new to python programing. I created a sript that selects a polygon tile/grid and uses the tile to clip all data feature classes in the tile. The cliped data will then beconverted into a dxf and dropped in a folder. But when I batch the process so it could go over 5 or more grids, it stops at the second grid and gives me this error message. Any help will be appreciated. (See code below) import sys, arcgisscripting gp = arcgisscripting.create() gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Conversion Tools.tbx") gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx") gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Analysis Tools.tbx") gp.overwriteOutput = 1 #grid feature class gridFC = gp.getParameterAsText(0) #gdb holding all feature classes to be clipped mapNo = gp.getParameterAsText(1) inputGDB = gp.getParameterAsText(2) #final output folder outputFolderRoot = gp.getParameterAsText(3) #list of feature classes gp.Extent = "1336418.000000 556751.000000 1504418.000000 748751.000000" exportNames = ['Building','Contours','Rec','Communication_Towers','Cultural','Rail','Road','Transmission','Vegetation'] gridCursor = gp.searchCursor(gridFC, "MAPNO = '" + mapNo + "'") currentGrid = gridCursor.next() scratchGDB = outputFolderRoot + "\\Scratch.gdb" if gp.Exists(scratchGDB): gp.Delete_management(scratchGDB) gp.addMessage("Creating scratch database...") gp.CreateFileGDB(outputFolderRoot, "Scratch.gdb") currentMapNo = currentGrid.MAPNO gp.CreateFolder_management(outputFolderRoot, currentMapNo) outputFolderName = outputFolderRoot + "\\" + currentMapNo whereClause = "MAPNO = '" + currentGrid.MAPNO + "'" currentClip = scratchGDB + "\\currentGridClip" #create clipped map to use to clip all feature classes gp.addMessage("Selecting MAPNO = " + currentMapNo) gp.Select_analysis(gridFC, currentClip, whereClause) for exportName in exportNames: gp.addMessage("Clipping " + exportName + " for MAPNO = " + currentMapNo) inputFC = inputGDB + "\\" + exportName if gp.Exists(inputFC): inputAnno = inputFC + "_Anno" outputClipName = scratchGDB + "\\" + exportName + "_" + currentMapNo outputDWGName = outputFolderName + "\\" + exportName + "_" + currentMapNo + ".DWG" try: gp.Clip_analysis(inputFC, currentClip, outputClipName) if gp.Exists(outputClipName): if gp.Exists(inputAnno): #include anno if it exists outputClipAnnoName = scratchGDB + "\\" + exportName + "Anno_" + currentMapNo gp.addMessage("Clipping " + exportName + "Anno for MAPNO = " + currentMapNo) gp.Clip_analysis(inputAnno, currentClip, outputClipAnnoName) exportParameter = outputClipName + ';' + outputClipAnnoName gp.addMessage("Converting " + exportName + " to CAD...") gp.ExportCAD_conversion(exportParameter, "DWG_R2000", outputDWGName, "Ignore_Filenames_in_Tables", "Overwrite_Existing_Files", "") else: #skip anno gp.addMessage("Converting " + exportName + " to CAD...") gp.ExportCAD_conversion(outputClipName, "DWG_R2000", outputDWGName, "Ignore_Filenames_in_Tables", "Overwrite_Existing_Files", "") except: gp.addMessage("Clipping of " + exportName + " failed. Moving on.") hydroLine = inputGDB + "\\Hydrology_Line" hydroPoly = inputGDB + "\\Hydrology_Poly" outputDWGName = outputFolderName + "\\hydro_" + currentMapNo + ".DWG" gp.addMessage("Converting hydro to CAD...") if gp.Exists(hydroLine): if gp.Exists(hydroPoly): #both poly and line exist exportParameter = hydroLine + ';' + hydroPoly gp.ExportCAD_conversion(exportParameter, "DWG_R2000", outputDWGName, "Ignore_Filenames_in_Tables", "Overwrite_Existing_Files", "") else: #if line exists but not poly gp.ExportCAD_conversion(hydroLine, "DWG_R2000", outputDWGName, "Ignore_Filenames_in_Tables", "Overwrite_Existing_Files", "") else: #line does not exist if gp.Exists(hydroPoly): #poly exists, but not line gp.ExportCAD_conversion(hydroPoly, "DWG_R2000", outputDWGName, "Ignore_Filenames_in_Tables", "Overwrite_Existing_Files", "") gp.Delete_management(scratchGDB)
... View more
05-02-2012
05:40 AM
|
0
|
0
|
343
|
POST
|
Use a Search Cursor to loop through the grid cells (I assume your grid is a grid of polygons...?) to get the cell's value. Then, inside the loop, incorporate the cell value into a path string, then use that string inside os.mkdir(). yes it is a polygon
... View more
02-23-2012
09:54 AM
|
0
|
0
|
346
|
POST
|
thanks all. I will start trying it out and see how it work. definetly this is new to me but I will surely get it right. thanks again
... View more
02-23-2012
09:53 AM
|
0
|
0
|
346
|
POST
|
thanks, How can i have it create 500 folders with different names
... View more
02-23-2012
07:32 AM
|
0
|
0
|
346
|
POST
|
I am trying to create folders and each folder will have a name from a field in my grid layer. My grid has 500 tiles and I need to create 500 folders. The naming convention is like 001A1, 001A2, 001A3, 001B1, 001B2, 001B3, 001C1, 001C2, 001C3, 002A1................... My code starts like this import sys, string, os, arcgisscripting, traceback gp = arcgisscripting.create() env.workspace = "C:\Backup Files\Backup Files\GISPROJECTS\Python_Practice" # Set local variables output_folder_path= "C:\Backup Files\Backup Files\GISPROJECTS\Python_Practice"out_name = "folder1" output_folder_name = foldername # Execute CreateFolder
... View more
02-23-2012
07:18 AM
|
0
|
6
|
794
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|