Flex Repeater Instances

I am using Ignition v8.1.5. I am trying to create a binding that would allow a user to set a value that would create a set of instances without having to go through each and every single instance creation manually.
I basically have a set of offshoots stacked horizontally like the image below using a Flex Repeater and a path that uses a template offshoot. Here I have 27 for an example but sometimes there are hundreds and creating each extra instance when there are that many gets extremely tedious and slow. Is it possible to create a binding of some kind that allows a user to set a value such as “OffshootCount: 100” and then 100 instances be created within the flex repeater?

You could have a number entry field where the user enters the amount of instances that they would like. You then bind the flex repeater instances property to that number field value and add a transform script where it builds the needed data for each instance.

transform script would be:

	if value > 0:
		instances = [{'instanceStyle':{'classes':''}, 'instancePosition':{}} for x in xrange(value)]
		instances = []
	return instances

which should give the flex repeater the most basic values for each instance. If you have additional values that need to be passed to the instances, they need to be included in this part: {'instanceStyle':{'classes':''}, 'instancePosition':{}}. Just add the additional dictionary keys and values.

1 Like

That works perfectly!

Why check for value > 0 ?

[{} for _ in range(0)]

should already return an empty list.

1 Like

Prevent it from running on a negative number entry.

passing a negative number to range also results in an empty list:

[{} for _ in range(-3)]


1 Like