DataTools.py
def execute(self, parameters, messages):
        """The source code of the tool."""
        source = parameters[0].valueAsText
        referenceScale = parameters[1].value
        coordinateSystem = parameters[2].valueAsText
        import os
        # make a file gdb in source
        arcpy.CreateFileGDB_management(source, "CAD2FGDB.gdb")
        for root, dirs, files in os.walk(source):
            for fname in files:
                if fname[-3:] in ["dgn", "dwg"]:
                    for i in ["-", " ", "(", ")"]:  # check for illegal characters in name
                        if i in fname:
                            oldName = root + "\\" + fname
                            newName = root + "\\" + fname.replace(i, "_")
                            os.rename(oldName, newName)  # rename file if illegal characters found
                            cadFile = newName
                            outName = newName[:-4]
                        else:
                            cadFile = root + "\\" + fname
                            outName = fname[:-4]
                    outGDB = source + "\\CAD2FGDB.gdb"
                    arcpy.CADToGeodatabase_conversion(cadFile, outGDB, outName, referenceScale, coordinateSystem)
The source code of the tool.
The source code of the tool.
The source code of the tool .
def execute(self, parameters, messages):
        source = parameters[0].valueAsText
        referenceScale = parameters[1].value
        coordinateSystem = parameters[2].valueAsText
        import os
        arcpy.CreateFileGDB_management(source, "CAD2FGDB.gdb")
        for root, dirs, files in os.walk(source):
            for fname in files:
                if fname[-3:] in ["dgn", "dwg"]:
                    for i in ["-", " ", "(", ")"]:  
                        if i in fname:
                            oldName = root + "\\" + fname
                            newName = root + "\\" + fname.replace(i, "_")
                            os.rename(oldName, newName)  
                            cadFile = newName
                            outName = newName[:-4]
                        else:
                            cadFile = root + "\\" + fname
                            outName = fname[:-4]
                    outGDB = source + "\\CAD2FGDB.gdb"
                    arcpy.CADToGeodatabase_conversion(cadFile, outGDB, outName, referenceScale, coordinateSystem)
def execute ( self , parameters , messages ) : source = parameters [ 0 ] . valueAsText referenceScale = parameters [ 1 ] . value coordinateSystem = parameters [ 2 ] . valueAsText import os arcpy . CreateFileGDB_management ( source , "CAD2FGDB.gdb" ) for root , dirs , files in os . walk ( source ) : for fname in files : if fname [ - 3 : ] in [ "dgn" , "dwg" ] : for i in [ "-" , " " , "(" , ")" ] : if i in fname : oldName = root + "\\" + fname newName = root + "\\" + fname . replace ( i , "_" ) os . rename ( oldName , newName ) cadFile = newName outName = newName [ : - 4 ] else : cadFile = root + "\\" + fname outName = fname [ : - 4 ] outGDB = source + "\\CAD2FGDB.gdb" arcpy . CADToGeodatabase_conversion ( cadFile , outGDB , outName , referenceScale , coordinateSystem )
The source code of the tool.
The source code of the tool .
"""The source code of the tool.""" # make a file gdb in source # check for illegal characters in name # rename file if illegal characters found
self
parameters
messages