[x3d-public] Question about a Python and x3d.py Error message
Bergstrom, Aaron
aaron.bergstrom at und.edu
Wed Jan 15 08:45:52 PST 2025
John,
Actually, I think a solution by moving the code from the initialize method into the “def postConstructor(self):” method.
Thanks,
Aaron
From: x3d-public <x3d-public-bounces at web3d.org> On Behalf Of Bergstrom, Aaron via x3d-public
Sent: Wednesday, January 15, 2025 10:36 AM
To: Extensible 3D (X3D) Graphics public discussion <x3d-public at web3d.org>
Cc: Bergstrom, Aaron <aaron.bergstrom at und.edu>
Subject: Re: [x3d-public] Question about a Python and x3d.py Error message
John,
Thanks for responding.
So in the case of the code below, would the instance method be the “def creator(cls):” method? If so, would I think do the following: “def creator(cls, self):”
Or am I not understanding what you are saying?
Thanks,
Aaron
From: John Carlson <yottzumm at gmail.com<mailto:yottzumm at gmail.com>>
Sent: Wednesday, January 15, 2025 10:12 AM
To: Extensible 3D (X3D) Graphics public discussion <x3d-public at web3d.org<mailto:x3d-public at web3d.org>>
Cc: Bergstrom, Aaron <aaron.bergstrom at und.edu<mailto:aaron.bergstrom at und.edu>>
Subject: Re: [x3d-public] Question about a Python and x3d.py Error message
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<mailto: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<http://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<mailto: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/4f3d31f7/attachment-0001.html>
More information about the x3d-public
mailing list