Select to view content in your preferred language

Preventing ModelBuilder model from working on/after particular date?

603
3
06-20-2018 04:01 AM
PradipSwain
New Contributor

I am working in ModelBuilder in ArcGIS Desktop.

I have a project of road network with administrative Boundary. In this project, I have created some models through ModelBuilder. I want to stop models from working after the project over.

Is there any script to stop models from working a particular date/time?

0 Kudos
3 Replies
TedKowal
Honored Contributor

I have never done this in a model but to get you started perhaps:

1. Create a starting custom script in the model that runs at the beginning

 2. That script checks the system data or some other stored date ie project date from your dataset?  

3. Compare dates if current date later than checked date then stop model....

Some help references to get you started:

Stop—Help | ArcGIS for Desktop 

Using a Python Startup/Shutdown Script or PythonCaller to Perform Geoprocessing with Arcpy - FME Kno... 

RichardDaniels
Frequent Contributor

Since you are already using a Model I would just create a Python script 'model' to add to the end that does the date check and returns a boolean. In your model check the return value, if true End, otherwise loop to the beginning of your model (or reschedule the model to execute at future time).

The script would be along the lines of:#python.

____

import sys

import datetime

now = datetime.datetime.now()
theCurrentDate =  now.strftime('%y/%m/%d')

//** example of string format to send in =  '2018/06/30'    **//

theEndDate = datetime.strftime(sys.argv[1], '%y/%m/%d')

if theCurrentDate > theEndDate:

   return true

return false

___________

Rich

PradipSwain
New Contributor

I tried to make a model but I do not succeed. Below is the snapshot. Please help .

0 Kudos