Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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

    Python operator xpresso

    Scheduled Pinned Locked Moved PYTHON Development
    5 Posts 0 Posters 494 Views
    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.
    • H Offline
      Helper
      last edited by

      On 21/03/2013 at 16:16, xxxxxxxx wrote:

      I was planning to add screenshot and c4d file but didn't really get this 1984ish way of doing it. Can I upload directly from my hard drive or do I first have to put it online and then add the url or what? 
      Ok, I know, I apologize, that was a digression.

      I'm new to programming so please bare with me.

      Main problem:
      I'm using Xpresso Python operator (node) with one Input and three Outputs.
      To test the input values I use a Constant xpresso node, and my main prob is getting python operator to read the inputs in the Input1 port. When I define the Input1 (example Input1=0) inside the python operator, its all good.

      This python approach is also me trying to learn Python. I have already solved it with coffee, so I appreciate if you stick also stick to a Python solution🙂

      Super grateful for all help I can get! Stay cool!

      Here is my script:

      import c4d
      #Welcome to the world of Python

      def main() :
          global  Output1, Output2, Output3
        
      Input1=Constant[c4d.GV_CONST_VALUE]  # Just a non working suggestion. This is the value property of                                                                      the constant node. What can I put here in order for the                                                                          phyton operator to start reading values from Input1? #

      if Input1 == 0:
          Output1=0
          Output2=1
          Output3=1

      elif Input1 == 1:
          Output1=1
          Output2=0
          Output3=1
          
      elif Input1 == 2:
          Output1=1
          Output2=1
          Output3=0

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 21/03/2013 at 16:59, xxxxxxxx wrote:

        Hi
        Im not really shure what youre asking but your script doesnt work because your indentation is wrong. And why cant you just pipe in the value from the constant node over the input1 port instead of trying to do it programatically?

        import c4d   
        #Welcome to the world of Python   
          
        def main() :   
            global Output1   
            global Output2   
            global Output3   
          
            #Input1=Constant[c4d.GV_CONST_VALUE]   
               
            if Input1 == 0:   
                Output1=0   
                Output2=1   
                Output3=1   
          
            elif Input1 == 1:   
                Output1=1   
                Output2=0   
                Output3=1   
               
            elif Input1 == 2:   
                Output1=1   
                Output2=1   
                Output3=0
        
        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 21/03/2013 at 17:49, xxxxxxxx wrote:

          i think the missing indentions are caused by the missing code tags arround his code.

          Constant[c4d.GV_CONST_VALUE]

          this line does not work because the variale  _Constant  _is not visible/known for the
          python node. if you want to access object symol values you have to pass the whole
          object with a link port.

          creating such link is a bit tricky, because only god knows why, Maxon restricted creating 
          object ouput ports. the easiest way is to select the the (null) object hosting the xpresso
          tag and create an object node for it. then create and an object output port. as the last
          step replace now the the object reference in your object node with the desired object,
          for your case the constant node.

          you could create a constant object reference node directly by draging the little cogwheel
          icon from the attribute manager constant node display into the xpresso view, but then
          that stupid output port restriction will take effect.

          something like this :

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 22/03/2013 at 02:39, xxxxxxxx wrote:

            Thank you Bonsak. Works like a charm. I'm glad it was something simple due to my lack of programming experience. I'm gonna use it to switch between different outputs in cycle interface in userdata. I'm afraid I didn't understand what you ment by the last thing you mentioned, piping the value and so on.

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 22/03/2013 at 02:57, xxxxxxxx wrote:

              thanks Littledevil for discussing the original approach to my problem. You enlightened me on what the python operator node limits are. I'll play around with your solution.

              Originally posted by xxxxxxxx

              i think the missing indentions are caused by the missing code tags arround his code.

              Constant[c4d.GV_CONST_VALUE]

              this line does not work because the variale  _Constant  _is not visible/known for the
              python node. if you want to access object symol values you have to pass the whole
              object with a link port.

              creating such link is a bit tricky, because only god knows why, Maxon restricted creating 
              object ouput ports. the easiest way is to select the the (null) object hosting the xpresso
              tag and create an object node for it. then create and an object output port. as the last
              step replace now the the object reference in your object node with the desired object,
              for your case the constant node.

              you could create a constant object reference node directly by draging the little cogwheel
              icon from the attribute manager constant node display into the xpresso view, but then
              that stupid output port restriction will take effect.

              something like this :

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