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

    exec() for node output

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 377 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

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

      On 01/12/2011 at 07:28, xxxxxxxx wrote:

      Hey people,

      here's another expression node port related question:
      I am making a simple script to help someone out, but running in to this: the node has a bunch of output ports, Port1, Port2, Port3 etc, and I use the exec() statement to calculate a value for the variables Port1 etc. I use a counter to name the Ports and assign the value of an array to it in a for loop, so i am not directly assigning a value with 'Port1=whatever".

      Like so:
      Outcode="Port"+str(counter+1)+" = TheArray[counter]"
      exec(Outcode)

      If I check the value for Port1, it is fine, but I get an error:
      NameError: Could not find port value for 'Port1' in node 'Python'.

      The whole idea is not to have to assign values to ports in the code, but to have the code still work when the user adds more ports manually following the same naming convention.

      Any ideas?

      Regards,
      Dr. Scarlett

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

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

        On 01/12/2011 at 07:37, xxxxxxxx wrote:

        That was weird. The minute I posted this, I received answer elsewhere.

        Thanks, Nux!

        Here's the link.

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

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

          On 01/12/2011 at 08:39, xxxxxxxx wrote:

          And this is what it was about

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