Hi Padmasiri,Try replacing your sys.argv arguments with arcpy.GetParameterAsText. Attached is an example.
# Import arcpy module import arcpy import os from arcpy import env import shutil import sys import time # Local variables: Cad_File = arcpy.GetParameterAsText(1)#J:\Gampaha\510272\51027202.dwg Pro_File = arcpy.GetParameterAsText(2)#I:\Projections\ProSriLanka99_5 Folder_Loca = arcpy.GetParameterAsText(3)#J:\Gampaha VDate = "time.strftime('" + arcpy.GetParameterAsText(4) + "')" Folder_Name = os.path.splitext(os.path.basename(Cad_File))[0]#51027202 Out_folder = os.path.join(Folder_Loca, Folder_Name)#J:\Gampaha\51027202 Gdb_Name = "CAD" + Folder_Name#CAD51027202 Gdb_Name1 = "CM" + Folder_Name#CM51027202 Gdb_Path = os.path.join(Out_folder, Gdb_Name)#J:\Gampaha\51027202\CAD51027202 Gdb_Path1 = os.path.join(Out_folder, Gdb_Name1)#J:\Gampaha\51027202\CM51027202 Fea_Dset_Name = "CAD" + Folder_Name#CAD51027202 Fea_Dset_Name1 = "CM" + Folder_Name#CAD51027202 Fea_Class_Path = os.path.join(Gdb_Path1 + ".gdb", Fea_Dset_Name1)#J:\Gampaha\51027202\CM51027202.gdb\CM51027202 if os.path.isdir(Out_folder): arcpy.env.workspace = Out_folder Gdb_List = arcpy.ListWorkspaces("", "FileGDB") for GDB in Gdb_List: arcpy.Delete_management(GDB) shutil.rmtree(Out_folder) Ws_Path = Gdb_Path + ".gdb" + os.sep + Gdb_Name arcpy.DefineProjection_management(Cad_File, Pro_File) arcpy.CreateFolder_management(Folder_Loca, Folder_Name)#J:\Gampaha\510272\51027202 arcpy.env.workspace = Out_folder arcpy.CreateFileGDB_management(Out_folder, Gdb_Name, "CURRENT")#J:\Gampaha\51027202\CAD51027202.gdb arcpy.CreateFileGDB_management(Out_folder, Gdb_Name1, "CURRENT")#J:\Gampaha\51027202\CM51027202.gdb arcpy.CreateFeatureDataset_management(Gdb_Path1 + ".gdb", Fea_Dset_Name1, Pro_File)#J:\Gampaha\51027202\CM51027202.gdb\CAD51027202 env.workspace = Gdb_Path + os.sep + Fea_Dset_Name #arcpy.env.Scratchworkspace = Gdb_Path arcpy.CADToGeodatabase_conversion(Cad_File, Gdb_Path + ".gdb", Fea_Dset_Name, "2000") arcpy.CreateTopology_management(Fea_Class_Path, "PCL_LN_Topology", 0.01) Polyline = Ws_Path + os.sep + "Polyline" Pnt = Ws_Path + os.sep + "Point" PLN_Topology = Fea_Class_Path + os.sep + "PCL_LN_Topology" Fea_Class = Fea_Class_Path + os.sep + "BLD_LN" #NL #Creating Structure Feature Class env.workspace = Fea_Class_Path #NL arcpy.FeatureClassToFeatureClass_conversion(Polyline, Fea_Class_Path, "BLD_LN", " \"Layer\" = 'OBJ-MAN-MADE' ") arcpy.FeatureToPolygon_management(Fea_Class, Fea_Class_Path + os.sep + "BLD_PG", 0.01, "ATTRIBUTES", "") arcpy.AddField_management("BLD_PG", "BLD_PG_NM", "TEXT", "", "", "50", "Building Name", "NULLABLE", "NON_REQUIRED", "") arcpy.AddField_management("BLD_PG", "BLD_PG_CD", "SHORT", "", "", "", "BLD SD Code", "NULLABLE", "NON_REQUIRED", "") SubType_Dict = {"0": "Permanent Building", "1": "Temporary Building", "2": "Building Underconstruction"} arcpy.SetSubtypeField_management("BLD_PG", "BLD_PG_CD") for code in SubType_Dict: arcpy.AddSubtype_management("BLD_PG", code, SubType_Dict) arcpy.SetDefaultSubtype_management("BLD_PG", "0") arcpy.AddField_management("BLD_PG", "BLD_PG_DT", "DATE", "", "", "", "Validity Date", "NULLABLE", "NON_REQUIRED", "") arcpy.CalculateField_management("BLD_PG", "BLD_PG_DT", VDate, "PYTHON_9.3", "")
For some reason, I could not get this to work with 'sys.argv' but I was able to with arcpy.GetParameterAsText. Are you able to use the GetParameterAsText rather than sys.argv?
Can you post your entire code? Be sure to wrap it in the appropriate tags.
tags.
Here is an example:VDate = "time.strftime('05/02/2014')"
VDate = "time.strftime('05/02/2014')"
Hi Padmisiri,You will want to format the date like the following:time.strftime('05/02/2014')Ex:arcpy.CalculateField_management("BLD_PG", "BLD_PG_DT", "time.strftime('05/02/2014')", "PYTHON")
arcpy.CalculateField_management("BLD_PG", "BLD_PG_DT", "time.strftime('05/02/2014')", "PYTHON")
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.