I have set my workspace, but when I run a simple clip. It just makes a shapefile in the folder location not the geodatabase I have set. The geodatabase is created in the location the user specifies. But it is dumping it into the folder not the geodatabase.
I am working pin Python 2.7, and ArcMap 10.6
here is my code.
# Seting up folder path parameters from ArcGIs Tool Box
FolderPath = arcpy.GetParameterAsText(4)
# Naming the Geodatabase for the user.
WorkGDB = "MTAP_Data"
tempdata = os.path.join(FolderPath, WorkGDB)
# Ensuring if rerun that the output can be overwritten
arcpy.env.overwriteOutput = True
# make sure gdb does not already exist
if arcpy.Exists(tempdata):
arcpy.env.workspace = tempdata
else:
# Create the new file geodatabase and or overwrite if there is one in place already
arcpy.CreateFileGDB_management(FolderPath, WorkGDB)
# Set the working environment for Project
arcpy.env.workspace = tempdata
# set up outputwork space outWS
outWS = tempdata
# Send Arcpy message to verify workspace has been set.
arcpy.AddMessage("Workspace has been set to: " + str(arcpy.env.workspace))
# Message for tool box outputs - shows location of folder to user
arcpy.AddMessage("Geodatabase has been created here:" + FolderPath)
# ----------------- End of Geodatabase and folder creation --------------------#
# -------------Gather Global base data and Clip to user areas -----------------#
## Issue with workspace - it is not saving into the workspace, as well as it is not saving the right name.
# User defined input for clipping the regions. (can be Operating areas, or one Op Area
# clipInput = arcpy.GetParameterAsText(1)
clipInput = r'\\scripts\Data\Data.gdb\AOI'
OLD = r'Database Connections\my.sde\'OLDData'
arcpy.Clip_analysis(OLD,clipInput,outWS)