GetGenerator() equivalent in a Python Effector



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

    On 11/12/2011 at 18:39, xxxxxxxx wrote:

    Greetings to all.

    Question: does anyone know of a GetGenerator() equivalent for a Python mograph effector?

    Ultimately, I need to be able to figure out how many children are located under a Cloner object, within the effector itself. I need that number to determine the relevant data to feed to MODATA_CLONE to control the index of an object cloned by the cloner. The problem here is that the cloned objects are < then the number of objects parented to the cloner, so GetCount() doesn't do anything for me.

    COFFEE at least has the aforementioned GetGenerator() function and I'm sure you can use that to derive the number of children under the cloner object. However Python doesn't appear to have this function.

    So... What is the best way to figure out the cloner object (so I can in turn figure out how many children it has) from a Python effector?

    Cheers,
    -CMPX



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

    On 18/01/2012 at 04:40, xxxxxxxx wrote:

    Just to bump this

    From what I can see there no connection between a PY Effector and the Cloner(s) that is/are using it?

    Can we get an answer on this one please either way - as the OP was early December.



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

    On 19/01/2012 at 03:58, xxxxxxxx wrote:

    OK Apart from going through the cloners - checking their effector list to see if it is using the Python effector
    is there any other way of getting the Cloner object the effector is attached to?



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

    On 23/01/2012 at 08:31, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    OK Apart from going through the cloners - checking their effector list to see if it is using the Python effector
    is there any other way of getting the Cloner object the effector is attached to?

    GetGenerator() is missing in the Python API and will be implemented in the future.

    Meanwhile, the best workaround is to add a Link user data to the Python Effector and connect the Cloner.
    Then in the Python effector code you could call:

    cloner = op[c4d.ID_USERDATA, 1]
    print cloner
    


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

    On 23/01/2012 at 08:43, xxxxxxxx wrote:

    Thanks for the feedback Yannick

    but I think this will be a problem if you use the effector in more than one cloner
    ie an unspecified number of cloers

    😉

    I'm thinking 
    search OM for cloners
    check effector list
    am I in there?



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

    On 24/01/2012 at 00:53, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    But I think this will be a problem if you use the effector in more than one cloner
    ie an unspecified number of cloners

    You can create as many Link user data as cloners.

    Originally posted by xxxxxxxx

    I'm thinking 
    search OM for cloners
    check effector list
    am I in there?

    Yes, meanwhile this solution may be the best for complex situations.



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

    On 24/01/2012 at 01:52, xxxxxxxx wrote:

    Sebastian just told me that in the Python effector scope there's a variable called "gen"... So we can access the cloner object with this variable.



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

    On 24/01/2012 at 07:25, xxxxxxxx wrote:

    A quick example would save a lot of guesswork pls 
    🙂



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

    On 24/01/2012 at 07:42, xxxxxxxx wrote:

    Basically, 'gen' is the name of a variable (referencing the cloner or generator object) added to the execution of main() function in a Python effector, just as the same as 'doc' (document where the effector resides) and 'op' (effector) variables:

    import c4d
    from c4d.modules import mograph as mo
    #Welcome to the world of Python
      
    def main() :
        md = mo.GeGetMoData(op)
        if md==None: return 1.0
        
        # Print variables added to the scope of main()
        print op
        print gen
        print doc
        
        index = md.GetCurrentIndex()
        mode = md.GetBlendID()
        if mode==c4d.ID_MG_BASEEFFECTOR_POSITION:
            return c4d.Vector(0.5)
        else: return 1.0
    


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

    On 24/01/2012 at 07:55, xxxxxxxx wrote:

    Ah - I see

    got it

    place in a Python Effector and run



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

    On 24/01/2012 at 09:01, xxxxxxxx wrote:

    bingo, that works.

    try again, deepshade.
    ( I think you're still working on a python version of d_PolySize.)
    I just tried :

    cloneobj = gen[c4d.MG_OBJECT_LINK]
    print cloneobj

    and it does return the Object the Cloner's cloning onto correctly,
    although it gets funky when there's multiple cloners referencingthe same Effector

    thanks, yannick



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

    On 24/01/2012 at 12:13, xxxxxxxx wrote:

    multiple cloner issue here too

    douwe - re: d_PolySize - still getting stuck on the coffee poly manipulation
    can you annotate to make conversion (a little) easier



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

    On 04/02/2012 at 05:51, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    Basically, 'gen' is the name of a variable (referencing the cloner or generator object) added to the execution of main() function in a Python effector, just as the same as 'doc' (document where the effector resides) and 'op' (effector) variables:

    import c4d
    from c4d.modules import mograph as mo
    #Welcome to the world of Python
     
    def main() :
        md = mo.GeGetMoData(op)
        if md==None: return 1.0
        
        # Print variables added to the scope of main()
        print op
        print gen
        print doc
        
        index = md.GetCurrentIndex()
        mode = md.GetBlendID()
        if mode==c4d.ID_MG_BASEEFFECTOR_POSITION:
            return c4d.Vector(0.5)
        else: return 1.0
    

    Why
    When the python effector is set to Full Control
    does GEN returns the Cloner

    and
    when the python effector is set to Parameter Control
    does GEN returns the Cloner Object Link
    ???



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

    On 10/02/2012 at 12:12, xxxxxxxx wrote:

    or to put it another way
    is the variable GEN in parameter mode 
    returned incorrectly ie a bug

    If there is a difference - can someone explain why pls - as there is no documentation of the modes working differently other than (from what I can see) the parameter version appears to be hooked to refresh once for every clone count


Log in to reply