Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    [XPresso] How to add numeric data from an In-/Exclusion Userdata?

    Cinema 4D SDK
    python r19
    2
    3
    993
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • eZioPanE
      eZioPan
      last edited by

      Hi,

      I have a Null Object with an In-/Exclusion Userdata attached. In In-/Exclusion Userdata some Mograph Effector have been added. I want to use Sample Node to get all Strength of Mograph Effector, then add output Strength together. How can I do?

      Here is the snapshot of the scene.

      0_1545379610503_ss.jpg

      The problem I meet is that I can't use Python to sample the output of a Mograph Effector(Sample Node With Python), and I haven't found a way to cumulate output of an Object List Node.

      Thanks!

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Hi @eZioPan, first of all, I would like to remind you, we do not have the purpose to help you with Xpresso and we normally do not have the purpose to help you on algorithm question.

        With that's said, consider this as a Christmas present 😉.
        You need to store everything yourself, so a map of effector and result. Then you can do the calculation.

        import c4d
        #Welcome to the world of Python
        
        listEffector = list()
        
        class Effector(object):
        
            def __init__(self, eff, mat):
                self.eff = eff
                self.mat = mat
        
        def main():
            global finalMat, listEffector
        
            effectorInList = None
            for e in listEffector:
                if e.eff == eff:
                    effectorInList = e
                    break
        
            if not effectorInList:
                newEff = Effector(eff, mat)
                listEffector.append(newEff)
            else:
                effectorInList.mat = mat
        
        
            finalMat = c4d.Matrix()
            for e in listEffector:
                finalMat *= e.mat
        

        Find this script in the Gvnode of this file. 0_1545392377324_effectorSampling.c4d

        Note that all effector offer the possibility to be used as a Deformer by switching the Deformation Mode to Object.

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        eZioPanE 1 Reply Last reply Reply Quote 1
        • eZioPanE
          eZioPan @m_adam
          last edited by

          Hi, @m_adam

          Thank you for your kindness and the inspiring answer! It's a GREAT Christmas present for me!

          So sorry asking XPresso related questions in this forum.
          The problem I faced is a little bit complex than this: I need sample Effectors' total Output Strengths in the position from a Polygon Object's Points, and store the result into a Vertex Color Map attached for further use.
          This problem bothers me for months, and I didn't find any clue until your post. I have never think about using Python Node with global variable in XPresso Network can keep the data as I need and do the magic!

          From the bottom of my heart, I want to say THANK YOU.
          The answer you give not only solve this problem, but also inspire me re-thinking of ObjectList Node and Python Node, and how these nodes executed in an XPresso Network.

          Just let me THANK YOU AGAIN!

          Best wishes for you to have a wonderful holiday!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post