HI!
I have large model made in ModelBuilder in ArcMap. First step is to create GDB where all of the outputs are saved. I need to the final output save in another output location. So I add "if data exists" this final output and I connect Yes (like precondition) with Delete that GDB. But it does not work.
When I run just Delete GDB - it works, but with those "if..." not.
What is the problem?
I know about scratch workspaces or in memory, but I need it this way in case it crash..
You can't delete objects that have been validated in ModelBuilder because there are file locks in play.
Have you tried using scratchGDB instead of in_memory? That way if you have a crash the scratch data will still be there after the model fails.
I can´t figure it out. So I set the output location everywhere like C://User/username/Documents/scratch.gdb/base_name? Or C://User/username/Documents/%scratchGDB%/base_name? And then it should work?
The model variable %scratchGDB% or %scratchFolder% will be replaced with a current writable location, normally a GDB or folder named scratch in the current project folder. For details, see the help for these environment variables.
didn´t work either. i don´t understand why is that when it is connected like "if data exists" in model, it won´t delete. but when i run model just for deleting, it works. i wanted to make it like "after model finish, than delete gdb"
yes i tried it. nothing again. i am thinking maybe about creating submodel? or i will give up and create another model just for "cleaning up" 🙂
If you simply want to delete the file geodatabase if it exists, using Exists is unnecessary because Delete returns success whether the file geodatabase exists or not. Delete will return a warning if the geodatabase does not exist, but it returns "success" whether the GDB exists or not.
yes I know, but that model is based on:
when output of copy features "ID" is created and saved in another gdb (not Ka.gdb), after then it can delete Ka.gdb. that is why i include that "if exist"
Ah, OK, I thought you were checking for the existence of the GDB you were deleting and not another GDB.