djriff

workspace within a workspace

Discussion created by djriff on Dec 21, 2011
Latest reply on Dec 22, 2011 by mdenil
ok despite the obvious inception reference i'm at a loss in my newest script.
I am trying to create a geodatabase in a user specified folder, with a user specified name, and then create a feature class inside of that that the user also specifies the name of. I can get that to work like a charm, my next step is to add fields to this newly created feature class and for that reason I have been trying to get my script to see where it is at. I recreated the script and model builder and it worked like a charm, however while that is a solution I still want to know how I can make my script work. Here is my script:

import arcpy
from arcpy import env

outputG = arcpy.GetParameterAsText(0)
outputgN = arcpy.GetParameterAsText(1)
polypro = arcpy.GetParameterAsText(2)

arcpy.CreateFileGDB_management(outputG, outputgN, "")
arcpy.AddMessage("FileGDB created = " + outputgN)
env.workspace = outputG
#That is not my actualy coordinate system, just keeping to short for trouble shooting purposes
arcpy.CreateFeatureClass_management(outputgN + ".gdb", polypro, "POLYGON", "", "DISABLED", "DISABLED", "WGS1984.prj", "", "", "", "")
#I tried using outputgN for the specific name but that gave me a 999999 error everytime I ran the script
workspaces = arcpy.ListWorkspaces("*", "FileGDB")
for workspace in workspaces:
  fclist = arcpy.ListFeatureClasses()
  arcpy.AddMessage("TEST")
  for fc in fclist:
    arcpy.AddField_management(fc, "TEST", "TEXT", "", "", 50, "", "NULLABLE", "REQUIRED")


Is there a way to combine my user inputed folder with the File GDB name? I've tried something along the lines of
env.workspace = outputN + "/" outputgN


that didn't work. Any ideas?

Outcomes