If my question does not make sense or needs clarification please let me know. I am struggling to solve it so I was struggling to phrase it into a question.
I have this code here:
import arcpy,os
from arcpy import env
#Name .gdb and set location. This will create the .gdb
out_folder_path = ("C:/Users..../Documents/test")
out_name= "Test.gdb"
arcpy.CreateFileGDB_management(out_folder_path, out_name)
# This will load the .xml into the .gdb created above
target_gdb = "C:/Users/..../Documents/test/Test.gdb"
in_file = "C:/Users..../MASTER.xml"
import_type = "DATA"
config_keyword = "DEFAULTS"
# Execute ImportXMLWorkspaceDocument
arcpy.ImportXMLWorkspaceDocument_management(target_gdb, in_file, import_type)
I am struggling to convert this into a tool. The problem I am encountering is I want the user to just set the .env settings, then input the database name and then location. Then the tool will take over and create the file gdb and then load the .xml workspace into it. The .xml workspace has been hardcoded to a certain location. I am just struggling with the target_gdb for the .xml import. It does work as is with hardcoded locations and for one time use. But for those who do are not python saavy having to change code everytime is not feasible. Again I want this to become a tool.
I did find this formum: Automating script to set geodatabase?
but this just confused me even more.
Updated code:02/4/14
import arcpy,os
from arcpy import env
Name .gdb and set location. This will create the .gdb
out_folder_path = arcpy.GetParameterAsText(0)
out_name= arcpy.GetParameterAsText(1)
arcpy.CreateFileGDB_management(out_folder_path,out_name)
This will load the .xml into the .gdb created above
target_gdb = out_folder_path + os.path.basename(out_name)
in_file = "C:/Users/.../MASTER.xml"
import_type = "DATA"
config_keyword = "DEFAULTS"
Execute ImportXMLWorkspaceDocument
arcpy.ImportXMLWorkspaceDocument_management(target_gdb, in_file, import_type)