Sure, if the distance can be estimated after focus is achieved then it should be possible to drive a lens to a prespecified focus distance. But I’m not aware of any time that actually happens, are you? Your point was scripting using existing commands.