Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects › Randomly set a value among a set of value

  • Randomly set a value among a set of value

    Posted by Garcia Loic on July 4, 2018 at 9:18 am

    Hello,

    In advance, sorry for my english. I should have been more attentive in class.

    I want to define a random value among a defined set.

    For the dash stroke. If the plot is closed, all values ​​for the dash are not beautiful.
    We often have a dash that is bigger than the others.
    And if we use offset, it’s even more visible.

    I have several hundred identical circle. I would like to define a different Dash size for everyone, from a list.

    I would test to know what value are correct, and I would refer them to a list.

    For more difficulty. I would like to define a specific Gap size, depending on the size of the dash defined above.

    Thank You for you help.

    Garcia Loic replied 8 years, 3 months ago 2 Members · 2 Replies
  • 2 Replies
  • Walter Soyka

    July 4, 2018 at 10:53 am

    Add a Slider Control effect to your layer, Alt+click its Slider stopwatch icon, and paste the following expression:

    // generate one random number for this layer for use elsewhere
    // set the random number generator to remains constant over time, using the layer index as the seed
    seedRandom(index, true);
    random();

    Alt+click the Dash property stopwatch, and paste this expression:
    // define lists of acceptable dashes and gaps.
    // these will work in pairs -- the first gap value will always go with the first dash value, likewise with the second, etc.
    dashes = [100, 150, 200, 250, 300];
    gaps = [25, 20, 15, 10, 5];

    dashes[Math.round(effect("random")("Slider") * (dashes.length-1))];

    Alt+click the Gap property stopwatch, and paste this very similar expression:
    // define lists of acceptable dashes and gaps.
    // these will work in pairs -- the first gap value will always go with the first dash value, likewise with the second, etc.
    dashes = [100, 150, 200, 250, 300];
    gaps = [25, 20, 15, 10, 5];

    gaps[Math.round(effect("random")("Slider") * (gaps.length-1))];

    Of course, you can modify the numbers in the lists to suit the aesthetics of your project, or extend or shorten the lists, but this will allow each layer to pull a separate dash/gap pair from your list of approved values.

    Walter Soyka
    Designer & Mad Scientist at Keen Live [link]
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    @keenlive   |   RenderBreak [blog]   |   Profile [LinkedIn]

  • Garcia Loic

    July 4, 2018 at 11:10 am

    Thank you for your help,
    I will test it here :B

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy