[x3d-public] Question about a Python and x3d.py Error message
John Carlson
yottzumm at gmail.com
Wed Jan 15 08:12:20 PST 2025
Aaron, AFAIK, you need “self” as the first parameter in your instance
methods (not functions, of course). I don’t know about class methods.
If you’re familiar with Java or C++, this is similar to “this”.
On Wed, Jan 15, 2025 at 10:02 AM Bergstrom, Aaron via x3d-public <
x3d-public at web3d.org> wrote:
> I need help troubleshooting a x3d.py error message.
>
>
>
> In developing a Python version of the Rawkee X3D exporter plugin for Maya,
> I am attempting to create nodes that inherit from both the Maya Python API
> 2.0 and x3d.py
>
>
>
> As such, I have a question about python and multiple class inheritance,
> and an error I am seeing. Admittedly, I am not the strongest Python
> programmer.
>
>
>
> I am getting the following error when I execute the Python code in Maya,
> and I’m pretty sure I do not of the __init__() function setup correctly.
>
>
>
> # Error: TypeError: file C:\Users\user.name\AppData\Roaming\Python\Python311\site-packages\x3d\x3d.py
> line 14984: Scene.hasChild() missing 1 required positional argument: 'self'
> #
>
>
>
> Can anyone with some Python experience give me an idea of what I am doing
> wrong here?
>
>
>
> Here is the code:
>
> #################################################################
>
> import x3d
>
>
>
> import maya.api.OpenMaya as aom
>
> import maya.api.OpenMayaUI as aomui
>
> import maya.api.OpenMayaRender as aomr
>
>
>
> # import xmltodict
>
> # import json
>
>
>
> class X3DScene (aom.MPxNode, x3d.Scene):
>
> TYPE_NAME = "Scene"
>
> TYPE_ID = aom.MTypeId(0x00108FFF)
>
> PROFILE_TYPE = "Full"
>
> VERSION = "4.0"
>
>
>
> def __init__(self):
>
> super(X3DScene, self).__init__()
>
>
>
> @classmethod
>
> def creator(cls):
>
> return X3DScene()
>
>
>
> @classmethod
>
> def initialize(cls):
>
> cls.x3dDoc = x3d.X3D(profile=cls.PROFILE_TYPE, version=cls.VERSION)
>
> cls.x3dDoc.Scene = cls
>
> #######################################################
>
> # Test dump to make sure the class works as expected
>
> #print(json.dumps(xmltodict.parse(cls.x3dDoc.XML()), indent=4))
>
> print(cls.x3dDoc.XML())
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20250115/1068778e/attachment-0001.html>
More information about the x3d-public
mailing list