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

    Using exec() to deal with python node ports

    Scheduled Pinned Locked Moved PYTHON Development
    2 Posts 0 Posters 293 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 28/02/2017 at 04:36, xxxxxxxx wrote:

      I made this bit of code to see if I could easily address loads of ports from a python node in xpresso.
      It seems to work perfectly, but I have this feeling like maybe I shouldn't be doing this.. would anyone mind having a look and letting me know?

      https://dl.dropboxusercontent.com/u/24304389/exec.png

      the code:
      import c4d

      def main() :
          
          for s in xrange(9) :
              out = int(s+Input1)    
              print out
              parse = "global Output"+str(s+1)+";"
              parse2 = "Output"+str(s+1)+" = "+str(out)
              exec(parse+parse2)

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

        On 01/03/2017 at 02:20, xxxxxxxx wrote:

        Hi,

        We can't recommend using exec() inside a Python XPresso node.
        That's not safe and could crash Cinema, depending on the code you pass to exec().

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