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
    • Recent
    • Tags
    • Users
    • Login

    Dynamic Variable Name?

    Scheduled Pinned Locked Moved SDK Help
    5 Posts 0 Posters 464 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 05/04/2011 at 00:37, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   12 
      Platform:   Windows  ;   
      Language(s) :   C.O.F.F.E.E  ;

      ---------
      Hi everyone.

      Is there a way to dynamically construct a variable name?

      E.g. I have variables Title1, Title2, Title3, and so on (it's a big list).

      I want to use a loop to set each Title variable rather than manually specify each Title.

      Is there a way for me to construct the variable name and then assign a value to it?

      Just to clarify, arrays won't work for me because these Title(n) variables are outputs on an Xpresso COFFEE node.

      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 05/04/2011 at 01:58, xxxxxxxx wrote:

        No, that's not possible.

        cheers,
        Matthias

        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 05/04/2011 at 02:47, xxxxxxxx wrote:

          Hello Eikonoklastes,

          Because all your outputs are defined in the node, you can do this:

            
          Output(number, data)  
          {  
              switch (number)  
              {  
                  case 0:  
                      Output0=data;  
                  case 1:  
                      Output1=data;  
                  case 2:  
                      Output2=data;  
                  case 3:  
                      Output3=data;  
                  default:  
                    break;  
              }  
          }  
            
          main()  
          {  
              var i;  
              var myArray = new(array,4);  
              myArray[0] = 123;  
              myArray[1] = 0.456;  
              myArray[2] = 11.1;  
              myArray[3] = -234;  
            
              for(i=0; i<4;i++)  
              {  
                  Output(i, myArray[i]);      
              }  
          }  
          
          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 05/04/2011 at 03:21, xxxxxxxx wrote:

            This is possible in Python. You can iterate over ports of a node(to get the name) or any variable in any scope and read/set it's values.

            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 28/04/2011 at 04:10, xxxxxxxx wrote:

              Just some samplecode (Python) :

                
              \>>>locs = locals()   
              \>>>for i in range(20) :   
                     locs['number%s'%i] = i   
              \>>>print number1,number5,number17,number19   
              1 5 17 19   
              \>>>print number20   
              <type 'exceptions.NameError'>   
              name 'number20' is not defined   
              <traceback object at 0x5fca7d4>   
              
              1 Reply Last reply Reply Quote 0
              • First post
                Last post