Does MotionBuilder not support class method calls?

I want to encapsulate a custom public class in the motionbuilder, similar to what python code does:
es.py:

class Fun:

def __init__(self, topModel=None, caption='Save Path...', prevdir='', fileName=None, charNList=[], currentFilePath=None,

             FileNames=None, ComponentList=None, CharList=None, Model=None, OpenAnimFilePath=''):  



    self.topModel = topModel

    self.caption = caption

    self.prevdir = prevdir

    self.fileName = fileName

    self.charNList = charNList

    self.currentFilePath = currentFilePath

    self.FileNames = FileNames

    # self.ComponentList = FBComponentList()

    # self.CharList = FBSystem().Scene.Characters

    self.Model = Model

    self.OpenAnimFilePath = OpenAnimFilePath



# 打开文件

def FileOpens(self):

    AnimPath= self.OpenAnimFilePath + '\\' + self.fileName

    print 'AnimPath'

tt.py:
import sys

sys.path.append(‘F:\vs\PyS\Test’)

import es

f = es.Fun(OpenAnimFilePath=‘C:\WildDogFile’)

f.FileOpens()

However, there is an error when the MB environment is running:
TypeError: init() got an unexpected keyword argument ‘OpenAnimFilePath’

I am very strange why so, I do not know how to solve, any friends know what the reason is?
Could you help me out,Thank you very much~~

Mobus python works perfectly fine
Try this simple test:

class simple_class(object):

    def __init__(self):
        super(simple_class, self).__init__()
        self.class_method()

    def class_method(self):
        print("I am a class method")

sc = simple_class()

Thank you. I tested it with your method, and there was no problem. So do you know how to use it in MB’s other python scripts? Yesterday I used FBApplication.ExecuteScript, and the test was normal, but today I tried again in the same way, but failed, and this exception occurred:
Traceback (most recent call last):
File “”, line 5, in
ImportError: No module named es

Es is the file name with the class written on it. Do you have any good Suggestions for this situation?

This code will work properly ( all I have done is clean it up a bit and made it a bit safer to call ):

import os

class Fun(object):

    def __init__(
        self,
        topModel=None,
        caption='Save Path...',
        prevdir='',
        fileName=None,
        charNList=[],
        currentFilePath=None,
        FileNames=None,
        ComponentList=None,
        CharList=None,
        Model=None,
        OpenAnimFilePath=''
    ):

        super(Fun, self).__init__()

        self.topModel = topModel
        self.caption = caption
        self.prevdir = prevdir
        self.fileName = fileName
        self.charNList = charNList
        self.currentFilePath = currentFilePath
        self.FileNames = FileNames
        # self.ComponentList = FBComponentList()
        # self.CharList = FBSystem().Scene.Characters
        self.Model = Model
        self.OpenAnimFilePath = OpenAnimFilePath

    # 打开文件
    def FileOpens(self):

        if not self.OpenAnimFilePath:
            print("self.OpenAnimFilePath is not defined!")
            return

        if not self.fileName:
            print("self.fileName is not defined!")
            return

        AnimPath = os.path.join(self.OpenAnimFilePath, self.fileName)
        print(AnimPath)
        return AnimPath

So all that leaves is how your environment is setup as your package name is not found on import.
What is the folder structure your class is living in?
Make sure you have an empty init .py file in the root of the package folder.
Try use the site module to add your packages parent path to the environment:

import site
site.addsitedir(<package parent path>)

Thank you~~ Using the method you said,I can call it ^^~