sylvain -  I suspect when you got this error, you did:

texture.create(name=name)

NOT

texture.create(self, name=name)

as Chris suggested.

(The difference gets into the details between bound / unbound class
methods... one of the trickier details in python.)

- Paul

On Thu, Jun 18, 2009 at 1:02 PM, Sylvain Berger<[email protected]> wrote:
> already tried this.... gives me this error:
> # TypeError: unbound method create() must be called with texture instance as
> first argument (got nothing instead) #
>
> On Thu, Jun 18, 2009 at 3:59 PM, Chris G <[email protected]> wrote:
>>
>> Try this:
>>
>>        def create(self, name='file', addPlace2dTexture=True):
>>                texture.create(self,name=name)
>>
>>
>>
>> On Thu, Jun 18, 2009 at 3: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?
>>>
>>>
>>
>>
>>
>
>
>
> --
> "A pit would not be complete without a Freeman coming out of it."
> The Vortigaunt
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---

Reply via email to