timer(msg) and Expression Plugin Tags



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 06/01/2007 at 12:21, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   9.6 
    Platform:   Windows  ;   
    Language(s) :   C.O.F.F.E.E  ;

    ---------
    Does anyone know whether it's possible to make a COFFEE expression plugin tag spontaneously access time() at regular intervals? According to the SDK, this function returns the number of milliseconds since CINEMA 4D was started.

    It seems that something like timer(msg) might work but this is only available in the GeUserArea and GeDialog classes.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 06/01/2007 at 13:37, xxxxxxxx wrote:

    I can only think of two possible directions here:

    1. Have your COFFEE code open a 'dummy' dialog (as minimal as possible) and use the timer there.

    2. Do your own timer somehow.
       a. This actually might require a separate plugin (COFFEE doesn't have threading support) - possibly a Message plugin.
       b. Or create a clever busy looping poll which only acts when a set time has passed (using time() delta for instance) with some form of 'messaging'.

    For (2b), the biggest concern is that the loop becomes your entire plugin - everything must happen from there once the loop is entered in the same way that a GUI loop polls the interface for any user activity. The only way to avoid this is if you only need the timer under certain circumstances - but the termination conditions must be rigorous.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 06/01/2007 at 20:25, xxxxxxxx wrote:

    Thanks for the prompt response, Robert.

    I need the timer to run for as long as the tag is loaded. Time values stored in a global variable would tell the tag whether it has been freshly loaded each time the expression runs so that persistent global variables could be refreshed. So with time stored at one second intervals, I could have something like:
    if(abs(time() - storedTime) > 1) globalVariable = refreshed;
    storedTime = time();

    Two other ways of detecting whether the tag has been freshly loaded are storing a unique ID in each host object's base container, and checking the object's position in the hierarchy. However, this does not work for a copy of the host object in the same hierarchy position as the original, or reloading the tag onto the same object. Polling the time value would work in all circumstances.

    Anyway, you've given me some good leads to work with. Thanks again.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 09/01/2007 at 03:56, xxxxxxxx wrote:

    Hi David, is this for your Symmetry plugin? If so maybe a object oriented approach would be better than storing some global variables? I in your case would to explore the possibilities of using a class member variable and the Message function.

    cheers,
    Matthias


Log in to reply