Checking for Character Key Sets part 3

We’ve already seen two ways to get at the IsCharacterKeySet parameter: 1) using the GetValue command, and 2) using XSICollection.Items.

Now, here’s a third way, using Dictionary.GetObject(). Dictionary.GetObject takes a string name and returns the corresponding object:

var oProp = Selection(0);
var oParam = Dictionary.GetObject( oProp + ".IsCharacterKeySet" );
LogMessage( oParam.Value );

So what’s the best way to get IsCharacterKeySet? One thing to consider is that GetValue and Dictionary.GetObject both fail if the string does not resolve to an object. XSICollection.Items, on the other hand, won’t fail; you just have to check the .Count property after to see whether you got the parameter.

Using the Modulo node

The Modulo operation gives the remainder after division. For example, 14 modulo 12 gives you 2, because 12 goes into 14 once, with 2 left over.

You can use the Modulo node to generate a sequence of numbers that continually wraps around. For example, the sequence 0,1,2,0,1,2,0,1,2,… is the result of applying “modulo by 3” to the sequence 0,1,2,3,4,5,6,7,8,…

0 = 0 modulo by 3
1 = 1 modulo by 3
2 = 2 modulo by 3
0 = 3 modulo by 3
1 = 4 modulo by 3
2 = 5 modulo by 3
0 = 6 modulo by 3

In an ICE tree, you could use Modulo to sequentially assign instances from a group:


You could also use Modulo to do something to every Nth particle. For example, in the “modulo by 3” sequence “0,1,2,0,1,2,0,1,2,…”, note that every third number is a “2”. So if you wanted to do something to every third particle, you would set up this ICE tree:


Modulo arithmetic is sometimes called “clock arithmetic”. Consider that when you add 5 hours to 9am, you end up with 2pm, which is an example of modulo 12 arithmetic:

9:00 + 5 hours = 2:00
9 + 5 = 2
2 = 14 modulo by 12 (12 goes into 14 once, with 2 left over)

Here’s some visual displays of modular arithmetic.