I think your not calling the base class method here. So thats why you
have the recursion.
def create(self, name='file', addPlace2dTexture=True):
self.create(name=name)
>From the python docs...
An overriding method in a derived class may in fact want to extend
rather than simply replace the base class method of the same name.
There is a simple way to call the base class method directly: just
call BaseClassName.methodname(self, arguments). This is occasionally
useful to clients as well. (Note that this only works if the base
class is defined or imported directly in the global scope.)
Hope this helps.
-Dave
On Jun 18, 8:52 pm, sberger <[email protected]> wrote:
> Hi guys, I have this problem that i have no idea how to fix.
>
> I have a base class:
> class texture(shadingNode):
> def __init__(self, node=''):
> shadingNode.__init__(self, node)
> self.nodeType = 'texture'
> def create(self, name='texture'):
> return self.__init__(mc.shadingNode(self.nodeType,
> asTexture=True,
> name=name))
>
> Then I have a second class that inherit from the first one.
> Now I would like to override the create method to add an argument.
> I have no idea how to create this method override
>
> This is what I have now...
> class file(texture):
> """ my maya file node class """
> def __init__(self, node=''):
> texture.__init__(self, node)
> self.nodeType = 'file'
> self.place2dTexture = ''
> self.setDefaultOutput('outColor')
> def create(self, name='file', addPlace2dTexture=True):
> self.create(name=name)
> if addPlace2dTexture:
> self.addPlace2dTextureNode()
> return self
>
> But when I call it like that:
> myFile = file().create()
>
> I get recursion error from python.
>
> Anyone know how to do this?
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---