DAT gate using a Script DAT

The code below, when attached to a Script DAT, takes an input DAT, either as an input or referenced by the “Source” parameter, and when the “Update” parameter is pulsed, it copies over that source data into the Script DAT as well as another optional DAT referenced by the “Dest” parameter.

This allows you to control when data flows down a pipeline instead of having everything downstream update whenever the source data changes. With a few minor changes, it could also be used in a Script CHOP or SOP.

def setupParameters(dat):
	page = dat.appendCustomPage('Gate')
	page.appendDAT('Source', label='Source DAT')
	page.appendDAT('Dest', label='Destination DAT')
	page.appendPulse('Update')

def onPulse(par):
	dat = par.owner
	src = dat.par.Source.eval()
	if not src and len(dat.inputs) > 0:
		src = dat.inputs[0]
	if src:
		dat.copy(src)
		dst = dat.par.Dest.eval()
		if dst:
			dst.copy(src)

def cook(dat):
	pass