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
    • Register
    • Login

    Classes

    PYTHON Development
    0
    2
    379
    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
      Helper
      last edited by

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

      On 23/02/2011 at 07:38, xxxxxxxx wrote:

      Hi there,

      i created a class for several calculation. But there is a problem and I can't fiure it out. 😞

      import c4d  
      import math  
        
      class distr_functions() :  
        def __init__(self) :  
            pass  
        def CalcLin(x,xmax) :  
            return x/xmax  
        def CalcPot(x,xmax) :  
            return math.pow(x/xmax,2)  
        def CalcExp(x,xmax,strength = 200) :  
            return math.pow(strength,x/xmax)/strength  
        def CalcCos(x,xmax,puls = 1) :  
            return (-0.5)*math.cos(x/xmax*pi*puls)+0.5  
        def CalcSwitch(x,xmax,switch,third = 1) :  
            if switch == 0:  
                return self.CalcLin(x,xmax)  
            elif switch == 1:  
                return self.CalcPot(x,xmax)  
            elif switch == 2:  
                return self.CalcExp(x,xmax,third)  
            elif switch == 3:  
                return self.CalcCos(x,xmax,third)  
            else: return  
        
        
      def main() :  
        df = distr_functions()  
        print df.CalcLin(4,4)  
        
      if __name__ == "__main__":  
        main()  
      

      The console tells me:

      CalcLin() takes exactly 2 arguments, 3 given
      

      But it works perfectly if i don't put these functions into a class.
      What did i wrong in defining the class ?

      And can i import a module for a class , like for eg the math module ?

      Thanks, nux

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

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

        On 23/02/2011 at 14:06, xxxxxxxx wrote:

        Hi, you forgot the 'self' reference:

        def CalcLin(self,x,xmax) :

        Cheers, Sebastian

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