Ajasra
8/10/2019 - 1:45 PM

generate menu with python decorators

automatic generate menu for custom parameters based on the COMP name

# use - me.mod.menuLabelMOD.menuItems(me, 'base_calibration')

class menuItems:

	def __init__(self, me, base_str):

		self.My_op = me
		self.Base_str = base_str
		self.Wild_card_name = '{}*'.format(base_str)

	def get_ops(self):
		target_ops = self.My_op.findChildren(type=baseCOMP, depth=1, name=self.Wild_card_name)
		return target_ops

	@property
	def menuLabels(self):
		menuLabels = [each_op.name[len(self.Wild_card_name):] for each_op in self.get_ops()]
		return menuLabels

	@property
	def menuNames(self):
		menuNames = [each_op.path for each_op in self.get_ops()]
		return menuNames
# Parameter execute dat - OP '..'
# Make sure the corresponding toggle is enabled in the Parameter Execute DAT.

stoner = op('stoner')
stoner_select = op('select_for_ui')
calibration_base = '../base_assets/null_chan{}'

def onValueChange(par, prev):
	# use par.eval() to get current value

	stoner.par.Project = par.eval()
	texture_digits = tdu.digits(par.eval())
	select_ui_top = calibration_base.format('{0:03d}'.format(texture_digits))
	stoner_select.par.top = select_ui_top

	return