# Import arcpy module
import arcpy
import string
import os
# Local variables:
#Set workspace
arcpy.env.workspace = "C:\\DWG\\FOLDER\\FOLDER*"
Polyline = "\Polyline"
LineShp = "C:\\DWG\\FOLDER\\Shape\\"
# Process: Select
for i in arcpy.ListFiles ("*.dwg"):
x = i.strip('.dwgDWG')
fileout = LineShp + x + ".shp"
print "Processing:" + arcpy.env.workspace + "\\" + Polyline + "To:" + fileout
print "Processing:" + arcpy.env.workspace + "\\" + Polyline + "To:" + fileout
Try posting your entire code. All I see it doing is print this line for every iteration of your loop
By no means is this answer going to be complete, but when specifying a file location (as in C:\DWG.....) you only need to use the double backslash after the C:\\ - so it would look like "C:\\DWG\...." or you can use single forward (/) slashes instead, which admittedly is annoying if you are doing a copy/paste of an address. another way to reference file paths is to put an r in front of it, so like: r"C:\DWG\... ["/QUOTE]
Thanks for reminding me of this. I had forgotten.RPI_Bryan;199036 wrote:
There is a free online course you can take for python in the training section.
I did this about 2 years ago but I should probably run through it again.
import arcpy, os
from arcpy import env
env.workspace = r"C:\temp\python"
for (path, dirs, files) in os.walk(env.workspace):
for file in files:
# find all DWG files in folder and all subfolders
if ".dwg" in file.lower()[-4:]:
dwg_path = os.path.join(path, file) + "\Polyline"
# set the MXD
mxd = arcpy.mapping.MapDocument("CURRENT")
# set the Dataframe
df = arcpy.mapping.ListDataFrames(mxd,"*")[0]
# create a new layer
newlayer = arcpy.mapping.Layer(dwg_path)
# add the layer to the map
arcpy.mapping.AddLayer(df, newlayer,"AUTO_ARRANGE")
del mxd