super function doesn't work inside a maya python module

前端 未结 4 1412
一个人的身影
一个人的身影 2021-01-14 01:51

Somehow, this works fine in the Maya/Python script editor, but fails when it\'s inside of my module code. Anyone have any ideas?

class ControlShape(object):
         


        
4条回答
  •  旧时难觅i
    2021-01-14 02:47

    I had this exact same problem. It's definitely not practical to restart maya each time you make a change. I found an answer here that solved this problem for me.

    You should read the linked answer to understand why its only suitable for debugging. But briefly, put this code in userSetup.py, then each time you edit your code run reload_package(my_package)

    import sys, types
    def reload_package(root_module):
        package_name = root_module.__name__
    
        # get a reference to each loaded module
        loaded_package_modules = dict([
            (key, value) for key, value in sys.modules.items() 
            if key.startswith(package_name) and isinstance(value, types.ModuleType)])
    
        # delete references to these loaded modules from sys.modules
        for key in loaded_package_modules:
            del sys.modules[key]
    
        # load each of the modules again; 
        # make old modules share state with new modules
        for key in loaded_package_modules:
            print 'loading %s' % key
            newmodule = __import__(key)
            oldmodule = loaded_package_modules[key]
            oldmodule.__dict__.clear()
            oldmodule.__dict__.update(newmodule.__dict__)
    

提交回复
热议问题