我让这个类继承了curve类并用super()调用它,但是模块中的代码太长了所以我决定将它们分开。但是,我仍然需要将初始化变量传递给曾经是其父级的模块。我通常将所有模块实例分配给类外的变量。但是,因为我需要将在 init 中初始化的变量传递给模块曲线,所以我能做到的唯一方法是在 init 中定义它并创建一个实例变量而不是全局变量。
这是一种标准或好的方法吗?或者有更好的方法来实现这一目标。 (变量是代码的最后一行 self.crvs = neo_curves.Curves(self.axis,self.safemode)
from pymel.core import *
import neo_name
import neo_curves
nc = neo_name.Name()
class Proxy(object):
"""Contains methods to create a generic proxy chain. Used as a blueprint
to create more specific types of chains, such as an arm, spine, or leg.
Keyword Arguments:
name -- (list) names for the chain
axis -- (string) axis at which rig is created, e.g. yz
safemode -- (boolean) determines whether scene nodes will be locked or not.
"""
def __init__(self, name=['proxy'], axis='yz', safemode=True):
self.customname = name
self.axis = axis
self.safemode = safemode
self.crvs = neo_curves.Curves(self.axis, self.safemode)